修改禅道已知bug
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
heartCheck: null,
|
||||
formData: {},
|
||||
openPath: '',
|
||||
timer:''
|
||||
timer: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -77,36 +77,34 @@
|
||||
return parseInt(this.msg1Count)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
created() {
|
||||
this.loadData()
|
||||
// this.timerFun();
|
||||
this.initWebSocket()
|
||||
this.heartCheckFun()
|
||||
},
|
||||
mounted() {
|
||||
// this.loadData()
|
||||
// this.timerFun();
|
||||
// this.initWebSocket()
|
||||
// this.heartCheckFun()
|
||||
},
|
||||
beforeDestroy() {
|
||||
if(this.timer){
|
||||
clearInterval(this.timer)
|
||||
}
|
||||
|
||||
},
|
||||
destroyed: function() { // 离开页面生命周期函数
|
||||
this.websocketOnclose()
|
||||
clearInterval(this.timer)
|
||||
},
|
||||
methods: {
|
||||
loadData() {
|
||||
try {
|
||||
// 获取系统消息
|
||||
getAction(this.url.listCementByUser).then((res) => {
|
||||
if (res.success) {
|
||||
this.announcement1 = res.result
|
||||
this.msg1Count = res.result.length
|
||||
this.msg1Title = this.$t('MessageNotification') + '(' + res.result.length + ')'
|
||||
}
|
||||
}).catch(error => {
|
||||
this.stopTimer = true
|
||||
})
|
||||
} catch (err) {
|
||||
getAction(this.url.listCementByUser).then((res) => {
|
||||
if (res.success) {
|
||||
this.announcement1 = res.result
|
||||
this.msg1Count = res.result.length
|
||||
this.msg1Title = this.$t('MessageNotification') + '(' + res.result.length + ')'
|
||||
}
|
||||
}).catch(error => {
|
||||
this.stopTimer = true
|
||||
}
|
||||
})
|
||||
},
|
||||
fetchNotice() {
|
||||
if (this.loadding) {
|
||||
@@ -138,7 +136,7 @@
|
||||
initWebSocket: function() {
|
||||
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
||||
var userId = store.getters.userInfo.id
|
||||
var url = window._CONFIG['domianWebSocketURL'].replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId
|
||||
var url = window._CONFIG['domianWebSocketURL'].replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/'+userId
|
||||
this.websock = new WebSocket(url)
|
||||
this.websock.onopen = this.websocketOnopen
|
||||
this.websock.onerror = this.websocketOnerror
|
||||
@@ -146,7 +144,17 @@
|
||||
this.websock.onclose = this.websocketOnclose
|
||||
},
|
||||
websocketOnopen: function() {
|
||||
console.log('WebSocket连接成功')
|
||||
// 添加心跳检测,每10秒发一次数据,防止连接断开(这跟服务器的设置有关,如果服务器没有设置每隔多长时间不发消息断开,可以不进行心跳设置)
|
||||
let self = this
|
||||
this.timer = setInterval(() => {
|
||||
try {
|
||||
self.websock.send('test')
|
||||
console.log('发送消息');
|
||||
} catch (err) {
|
||||
console.log('断开了:' + err)
|
||||
self.connection()
|
||||
}
|
||||
}, 10000)
|
||||
},
|
||||
websocketOnerror: function(e) {
|
||||
console.log('WebSocket连接发生错误')
|
||||
@@ -158,13 +166,11 @@
|
||||
this.loadData()
|
||||
},
|
||||
websocketOnclose: function(e) {
|
||||
console.log('connection closed (' + e + ')')
|
||||
if (e) {
|
||||
console.log('connection closed (' + e.code + ')')
|
||||
}
|
||||
this.reconnect()
|
||||
console.log(e)
|
||||
this.websock.close()
|
||||
},
|
||||
websocketSend(text) { // 数据发送
|
||||
console.log(text)
|
||||
try {
|
||||
this.websock.send(text)
|
||||
} catch (err) {
|
||||
@@ -178,7 +184,6 @@
|
||||
that.lockReconnect = true
|
||||
//没连接上会一直重连,设置延迟避免请求过多
|
||||
setTimeout(function() {
|
||||
console.info('尝试重连...')
|
||||
that.initWebSocket()
|
||||
that.lockReconnect = false
|
||||
}, 5000)
|
||||
@@ -218,8 +223,9 @@
|
||||
.header-notice-wrapper {
|
||||
top: 50px !important;
|
||||
}
|
||||
.tabs .ant-tabs-nav .ant-tabs-tab-active{
|
||||
color: #000F16!important;
|
||||
|
||||
.tabs .ant-tabs-nav .ant-tabs-tab-active {
|
||||
color: #000F16 !important;
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user