li.shaoyi 5 miesięcy temu
rodzic
commit
96e9f8d07d
1 zmienionych plików z 8 dodań i 4 usunięć
  1. 8 4
      src/packages/mobile/App.vue

+ 8 - 4
src/packages/mobile/App.vue

@@ -1,7 +1,8 @@
 <template>
   <router-view />
   <Notify v-model:show="notify.show" :title="notify.title" :content="notify.content" />
-  <Dialog class="g-dialog-message" v-model:show="message.show" theme="round-button" confirm-button-text="关闭">
+  <Dialog class="g-dialog-message" v-model:show="message.show" theme="round-button" confirm-button-text="关闭"
+    @closed="onClosed">
     <template #title>
       <div class="g-dialog-message__header">
         <h4>{{ currentMessage?.title }}</h4>
@@ -60,7 +61,7 @@ const message = reactive({
 
 // 获取用户阅读状态
 const getUserReadStatus = () => ({
-  key: 'user_' + loginStore.loginId,
+  key: 'read_' + loginStore.loginId,
   value: formatDate(new Date().toISOString(), 'YYYY-MM-DD')
 })
 
@@ -81,10 +82,14 @@ const changeMessage = (value: number) => {
   const i = message.index + value
   if (i > -1 && i < messageList.value.length) {
     message.index = i
-    noticeStore.updateNoticeReaded(currentMessage.value.autoid)
   }
 }
 
+// 关闭消息弹窗
+const onClosed = () => {
+  messageList.value.forEach((e) => noticeStore.updateNoticeReaded(e.autoid))
+}
+
 // 顶部通知
 const notify = reactive({
   show: false,
@@ -150,7 +155,6 @@ watch(() => noticeStore.isInitialized, () => {
     localStorage.setItem(key, value) // 记录用户已读状态
     message.index = 0
     message.show = true
-    noticeStore.updateNoticeReaded(firstMessage.autoid)
   }
 })