li.shaoyi 3 hónapja
szülő
commit
c70bc44615

+ 21 - 18
src/packages/mobile/App.vue

@@ -65,7 +65,7 @@ if (locale in languageMap) {
 }
 
 const { userLogout } = useLogin()
-const { backHome } = useNavigation()
+const { backHome, route } = useNavigation()
 
 const loginStore = useLoginStore()
 const noticeStore = useNoticeStore()
@@ -128,23 +128,26 @@ eventBus.$on('LogoutNotify', (msg) => {
   })
 })
 
-watch(() => noticeStore.isInitialized, () => {
-  const readKey = 'read_' + loginStore.loginId
-  const readValue = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
-
-  const storageValue = localStorage.getItem(readKey)
-  const showUnread = props.showUnread && storageValue !== readValue // 未读消息一天内只会弹框一次
-
-  // 过滤数据
-  const filteredData = noticeStore.localizedDataList.filter((e) => (showUnread && !e.readed) || e.isforcedisplay)
-  // 浅拷贝,防止数据引用
-  message.dataList = filteredData.map((e) => ({ ...e }))
-
-  if (message.dataList.length) {
-    localStorage.setItem(readKey, readValue) // 记录用户已读日期
-    message.index = 0
-    message.show = true
-    noticeStore.updateNoticeReaded(message.dataList[0].autoid)
+watch(() => [noticeStore.isInitialized, route.name], ([isInitialized, routeName]) => {
+  if (routeName !== 'boot' && isInitialized) {
+    const readKey = 'read_' + loginStore.loginId
+    const readValue = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
+
+    const storageValue = localStorage.getItem(readKey)
+    const showUnread = props.showUnread && storageValue !== readValue // 未读消息一天内只会弹框一次
+
+    // 过滤数据
+    const filteredData = noticeStore.localizedDataList.filter((e) => (showUnread && !e.readed) || e.isforcedisplay)
+    // 浅拷贝,防止数据引用
+    message.dataList = filteredData.map((e) => ({ ...e }))
+
+    if (message.dataList.length) {
+      localStorage.setItem(readKey, readValue) // 记录用户已读日期
+      message.index = 0
+      message.show = true
+      noticeStore.updateNoticeReaded(message.dataList[0].autoid)
+      noticeStore.setUninitialized()
+    }
   }
 })
 

+ 4 - 3
src/packages/tss/views/boot/index.less

@@ -36,9 +36,10 @@
         footer {
             position: absolute;
             bottom: 0;
-            left: 0;
-            width: 100%;
-            padding: 10px 20px;
+            left: 50%;
+            transform: translateX(-50%);
+            width: 80%;
+            padding: 20px 0;
         }
     }
 }

+ 10 - 3
src/stores/modules/notice.ts

@@ -48,7 +48,6 @@ export const useNoticeStore = defineStore(() => {
             state.dataList = res.data
         } finally {
             state.loading = false
-            state.isInitialized = true
             // 轮询查询系统通知
             timerTask.setTimeout(() => {
                 fetchDataList()
@@ -70,16 +69,23 @@ export const useNoticeStore = defineStore(() => {
         }
     }
 
+    // 重置初始化状态
+    const setUninitialized = () => {
+        state.isInitialized = false
+    }
+
     // 接收登入请求数据
     eventBus.$on('LoginNotify', () => {
-        fetchDataList()
+        fetchDataList().finally(() => {
+            state.isInitialized = true
+        })
     })
 
     // 接收登出通知清空数据
     eventBus.$on('LogoutNotify', () => {
         timerTask.clearTimeout('systemNotice')
         state.dataList = []
-        state.isInitialized = false
+        setUninitialized()
     })
 
     return {
@@ -88,5 +94,6 @@ export const useNoticeStore = defineStore(() => {
         unreadCount,
         fetchDataList,
         updateNoticeReaded,
+        setUninitialized
     }
 })