关闭通知,有消息时自动弹通知
parent
e5ec6bc20f
commit
0cc507fbc5
|
|
@ -51,7 +51,8 @@ export default {
|
||||||
async pollMsg() {
|
async pollMsg() {
|
||||||
//3秒轮询一次
|
//3秒轮询一次
|
||||||
this.pollingTimer = setInterval(async () => {
|
this.pollingTimer = setInterval(async () => {
|
||||||
const data = {msg:'友仓智慧物流,软件定义物流。',msgType:'INFO'}
|
const data = {msg: '友仓智慧物流,软件定义物流。', msgType: 'INFO'}
|
||||||
|
console.log(data)
|
||||||
this.createOrUpdateNotification(data)
|
this.createOrUpdateNotification(data)
|
||||||
}, 3000);
|
}, 3000);
|
||||||
},
|
},
|
||||||
|
|
@ -114,8 +115,13 @@ export default {
|
||||||
message: data.msg,
|
message: data.msg,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
offset: 100,
|
offset: 100,
|
||||||
duration: 0
|
duration: 0,
|
||||||
|
onClose: this.onNotificationClose // 关闭时调用的方
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
onNotificationClose() {
|
||||||
|
this.showNotification = false;
|
||||||
|
this.notificationInstance = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
|
@ -126,7 +132,10 @@ export default {
|
||||||
this.websock.close();
|
this.websock.close();
|
||||||
}
|
}
|
||||||
if (this.notificationInstance) {
|
if (this.notificationInstance) {
|
||||||
|
console.log(111)
|
||||||
this.notificationInstance.close(); // 关闭通知
|
this.notificationInstance.close(); // 关闭通知
|
||||||
|
this.showNotification = false;
|
||||||
|
this.notificationInstance = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue