|
|
@ -73,6 +73,7 @@ import Search from '@/components/HeaderSearch' |
|
|
|
import Avatar from '@/assets/images/avatar.png' |
|
|
|
import NoticeIcon from '@/views/system/notice/NoticeIcon.vue' |
|
|
|
import NoticeIconReader from '@/views/system/notice/NoticeIconReader.vue' |
|
|
|
import i18n from '@/i18n' |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { |
|
|
@ -95,6 +96,7 @@ export default { |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.initLang() |
|
|
|
this.initWebSocket() |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
...mapGetters([ |
|
|
@ -162,6 +164,35 @@ export default { |
|
|
|
this.$store.dispatch('LogOut').then(() => { |
|
|
|
location.reload() |
|
|
|
}) |
|
|
|
}, |
|
|
|
initWebSocket() { |
|
|
|
// const wsUri = (process.env.VUE_APP_WS_API === '/' ? '/' : (process.env.VUE_APP_WS_API + '/')) + 'messageInfo' |
|
|
|
const wsUri = process.env.VUE_APP_WS_API + '/webSocket/' + 'messageInfo' |
|
|
|
this.websock = new WebSocket(wsUri) |
|
|
|
this.websock.onerror = this.webSocketOnError |
|
|
|
this.websock.onmessage = this.webSocketOnMessage |
|
|
|
}, |
|
|
|
webSocketOnError(e) { |
|
|
|
this.$notify({ |
|
|
|
title: i18n.t('common.Tip14'), |
|
|
|
type: 'error', |
|
|
|
duration: 0 |
|
|
|
}) |
|
|
|
}, |
|
|
|
webSocketOnMessage(e) { |
|
|
|
const data = JSON.parse(e.data) |
|
|
|
if (data.msgType === 'INFO') { |
|
|
|
// console.log('data', data) |
|
|
|
this.$bus.emit(data.msg.data, data.msg.msgType) |
|
|
|
} else if (data.msgType === 'ERROR') { |
|
|
|
this.$notify({ |
|
|
|
title: '', |
|
|
|
message: data.msg, |
|
|
|
dangerouslyUseHTMLString: true, |
|
|
|
type: 'error', |
|
|
|
duration: 0 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|