li.shaoyi 5 달 전
부모
커밋
b01f2397c1
1개의 변경된 파일11개의 추가작업 그리고 6개의 파일을 삭제
  1. 11 6
      src/packages/mobile/App.vue

+ 11 - 6
src/packages/mobile/App.vue

@@ -24,7 +24,7 @@ import { formatDate } from '@/filters'
 import { useLogin } from '@/business/login'
 import { Language } from '@/constants/language'
 import { useNavigation } from './router/navigation'
-import { i18n, useNoticeStore } from '@/stores'
+import { i18n, useNoticeStore, useLoginStore } from '@/stores'
 import eventBus from '@/services/bus'
 import plus from '@/utils/h5plus'
 import Notify from '@mobile/components/base/notify/index.vue'
@@ -49,6 +49,7 @@ const props = defineProps({
 const { userLogout } = useLogin()
 const { backHome } = useNavigation()
 
+const loginStore = useLoginStore()
 const noticeStore = useNoticeStore()
 
 // 消息弹窗
@@ -57,11 +58,16 @@ const message = reactive({
   index: 0
 })
 
+// 获取用户阅读状态的唯一键
+const getUserReadKey = () => {
+  const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
+  return `${loginStore.loginId}@${today}`
+}
+
 // 消息列表
 const messageList = computed(() => {
-  const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
-  const readDay = localStorage.getItem('readDay')
-  const showUnread = props.showUnread && today !== readDay // 未读消息一天内只会弹框一次
+  const readKey = localStorage.getItem('userReadKey')
+  const showUnread = props.showUnread && getUserReadKey() !== readKey // 未读消息一天内只会弹框一次
 
   return noticeStore.noticeList.filter((e) => (showUnread && !e.readed) || e.isforcedisplay)
 })
@@ -139,8 +145,7 @@ watch(() => noticeStore.isInitialized, () => {
   const [firstMessage] = messageList.value
 
   if (firstMessage) {
-    const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
-    localStorage.setItem('readDay', today) // 记录当前日期
+    localStorage.setItem('userReadKey', getUserReadKey()) // 记录用户已读状态
     message.index = 0
     message.show = true
     noticeStore.updateNoticeReaded(firstMessage.autoid)