前端当网页不可见时,延迟加载房间

pull/140/head
John Smith 1 year ago
parent 7e656ebe09
commit b1916608ee

@ -77,26 +77,42 @@ export default {
} }
}, },
mounted() { mounted() {
this.initConfig() if (document.visibilityState === 'visible') {
this.initChatClient() this.init()
this.initTextEmoticons() } else {
if (this.config.giftUsernamePronunciation !== '') { // OBSOBS
this.pronunciationConverter = new pronunciation.PronunciationConverter() document.addEventListener('visibilitychange', this.onVisibilityChange)
this.pronunciationConverter.loadDict(this.config.giftUsernamePronunciation)
} }
//
this.$message({
message: 'Loaded',
duration: 500
})
}, },
beforeDestroy() { beforeDestroy() {
document.removeEventListener('visibilitychange', this.onVisibilityChange)
if (this.chatClient) { if (this.chatClient) {
this.chatClient.stop() this.chatClient.stop()
} }
}, },
methods: { methods: {
onVisibilityChange() {
if (document.visibilityState !== 'visible') {
return
}
document.removeEventListener('visibilitychange', this.onVisibilityChange)
this.init()
},
init() {
this.initConfig()
this.initChatClient()
this.initTextEmoticons()
if (this.config.giftUsernamePronunciation !== '') {
this.pronunciationConverter = new pronunciation.PronunciationConverter()
this.pronunciationConverter.loadDict(this.config.giftUsernamePronunciation)
}
//
this.$message({
message: 'Loaded',
duration: 500
})
},
initConfig() { initConfig() {
let locale = this.strConfig.lang let locale = this.strConfig.lang
if (locale) { if (locale) {

Loading…
Cancel
Save