|
|
@@ -58,16 +58,17 @@ const message = reactive({
|
|
|
index: 0
|
|
|
})
|
|
|
|
|
|
-// 获取用户阅读状态的唯一键
|
|
|
-const getUserReadKey = () => {
|
|
|
- const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
|
|
|
- return `${loginStore.loginId}@${today}`
|
|
|
-}
|
|
|
+// 获取用户阅读状态
|
|
|
+const getUserReadStatus = () => ({
|
|
|
+ key: 'user_' + loginStore.loginId,
|
|
|
+ value: formatDate(new Date().toISOString(), 'YYYY-MM-DD')
|
|
|
+})
|
|
|
|
|
|
// 消息列表
|
|
|
const messageList = computed(() => {
|
|
|
- const readKey = localStorage.getItem('userReadKey')
|
|
|
- const showUnread = props.showUnread && getUserReadKey() !== readKey // 未读消息一天内只会弹框一次
|
|
|
+ const { key, value } = getUserReadStatus()
|
|
|
+ const localValue = localStorage.getItem(key)
|
|
|
+ const showUnread = props.showUnread && localValue !== value // 未读消息一天内只会弹框一次
|
|
|
|
|
|
return noticeStore.noticeList.filter((e) => (showUnread && !e.readed) || e.isforcedisplay)
|
|
|
})
|
|
|
@@ -145,7 +146,8 @@ watch(() => noticeStore.isInitialized, () => {
|
|
|
const [firstMessage] = messageList.value
|
|
|
|
|
|
if (firstMessage) {
|
|
|
- localStorage.setItem('userReadKey', getUserReadKey()) // 记录用户已读状态
|
|
|
+ const { key, value } = getUserReadStatus()
|
|
|
+ localStorage.setItem(key, value) // 记录用户已读状态
|
|
|
message.index = 0
|
|
|
message.show = true
|
|
|
noticeStore.updateNoticeReaded(firstMessage.autoid)
|