|
|
|
@ -77,6 +77,28 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
if (document.visibilityState === 'visible') {
|
|
|
|
|
this.init()
|
|
|
|
|
} else {
|
|
|
|
|
// 当前窗口不可见,延迟到可见时加载,防止OBS中一次并发太多请求(OBS中浏览器不可见时也会加载网页,除非显式设置)
|
|
|
|
|
document.addEventListener('visibilitychange', this.onVisibilityChange)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
document.removeEventListener('visibilitychange', this.onVisibilityChange)
|
|
|
|
|
if (this.chatClient) {
|
|
|
|
|
this.chatClient.stop()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
onVisibilityChange() {
|
|
|
|
|
if (document.visibilityState !== 'visible') {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
document.removeEventListener('visibilitychange', this.onVisibilityChange)
|
|
|
|
|
this.init()
|
|
|
|
|
},
|
|
|
|
|
init() {
|
|
|
|
|
this.initConfig()
|
|
|
|
|
this.initChatClient()
|
|
|
|
|
this.initTextEmoticons()
|
|
|
|
@ -91,12 +113,6 @@ export default {
|
|
|
|
|
duration: 500
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
if (this.chatClient) {
|
|
|
|
|
this.chatClient.stop()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
initConfig() {
|
|
|
|
|
let locale = this.strConfig.lang
|
|
|
|
|
if (locale) {
|
|
|
|
|