From 5add11320c42dc7641bdad9018799ec0989583b0 Mon Sep 17 00:00:00 2001 From: fuguobin Date: Mon, 25 Mar 2024 10:03:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A5=E5=BF=97=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/user.ts | 12 ++++---- src/views/dashboard/index.vue | 53 ++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 15cc8c3..b602162 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -16,7 +16,7 @@ export const useUserStore = defineStore('user', () => { const userInfo = useSessionStorage('userInfo', {}); const nickname = ref(''); const avatar = ref(''); - // const webVersion = useSessionStorage('webVersion', ''); + const webVersion = useSessionStorage('webVersion', ''); const roles = ref>([]); // 用户角色编码集合 → 判断路由权限 const perms = ref>([]); // 用户权限编码集合 → 判断按钮权限 @@ -57,11 +57,11 @@ export const useUserStore = defineStore('user', () => { roles.value = data.roles; perms.value = data.permissions; userInfo.value = user; - // if (data.notice === null) { - // webVersion.value = ''; - // } else { - // webVersion.value = JSON.stringify(data.notice); - // } + if (data.notice === null) { + webVersion.value = ''; + } else { + webVersion.value = JSON.stringify(data.notice); + } // useStorage('userInfo', user); resolve(data); }) diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index a0c7b4e..d4b1e8e 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -116,7 +116,7 @@ const isCurrentRoute = ref(true); const userStore = useUserStore(); const duration = 5000; const userNumber = ref(2800); -// const notice = ref({}); +const notice = ref({}); // const vsitsNumber = transitionNum(720, 5000); const currentTime = useDateFormat(useNow(), 'YYYY-MM-DD HH:mm:ss'); const hoursNow = useNow().value.getHours(); @@ -196,32 +196,33 @@ onMounted(() => { getWeatherData(); getCardData(); // socket.initialize(wsUrl); - // const webVersion = sessionStorage.getItem('webVersion'); - // if (webVersion != '' && webVersion != null) { - // const version = JSON.parse(webVersion); - // notice.value = ElNotification({ - // title: version.noticeTitle, - // dangerouslyUseHTMLString: true, - // customClass: 'notice', - // duration: 0, - // message: version.noticeContent.replace(/\n/g, '
'), - // onClose: () => { - // noticeCloce(version.noticeId); - // } - // }); - // } + const webVersion = sessionStorage.getItem('webVersion'); + if (webVersion != '' && webVersion != null) { + const version = JSON.parse(webVersion); + notice.value = ElNotification({ + // title: version.noticeTitle, + title: '更新日志', + dangerouslyUseHTMLString: true, + customClass: 'notice', + duration: 0, + message: version.noticeContent.replace(/\n/g, '
'), + onClose: () => { + noticeCloce(version.noticeId); + } + }); + } }); -// function noticeCloce(id: any) { -// //更新日志关闭事件 -// const params = { -// versionId: id -// }; -// userVersionRelation(params).then((res: any) => { -// if (res.code === 200) { -// console.log('更新日志关闭!'); -// } -// }); -// } +function noticeCloce(id: any) { + //更新日志关闭事件 + const params = { + versionId: id + }; + userVersionRelation(params).then((res: any) => { + if (res.code === 200) { + console.log('更新日志关闭!'); + } + }); +} function getCardData() { //卡片数据 getHeatSupplyAreaApi().then((res: any) => {