关闭通知,有消息时自动弹通知

main
HUOJIN\92525 2024-09-14 17:54:41 +08:00
parent e5ec6bc20f
commit 0cc507fbc5
1 changed files with 11 additions and 2 deletions

View File

@ -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;
} }
} }
} }