diff --git a/src/components/Notice/Index.vue b/src/components/Notice/Index.vue index 8cac023..352e31f 100644 --- a/src/components/Notice/Index.vue +++ b/src/components/Notice/Index.vue @@ -2,15 +2,16 @@
+
全部已读
@@ -20,12 +21,14 @@
{{ dayjs(item.create_time).format('YYYY-MM-DD') }}
+ +
@@ -38,13 +41,13 @@
{{ formatTime(item.chatTime) }}
+
前往通知中心
-
全部已读
@@ -52,10 +55,13 @@ @@ -76,11 +82,14 @@ const noticeList = computed(() => { return useSocketStore().noticeList }) const noticeDot = computed(() => { - return useSocketStore().noticeDot + return useSocketStore().getAllDotNum() }) const chatList = computed(() => { return useSocketStore().getSessionList(useUserStore().userId) }) +const chatDotNum = computed(() => { + return useSocketStore().newChat +}) const info = ref({}) function handleDetails(item, type) { show.value = true @@ -93,7 +102,11 @@ function handleDetails(item, type) { // 全部已读点击 function onAllReadClick() { newsDot.value = false - proxy.$modal.msg('请自行实现!!!') + if (noticeType.value == 1) { + useSocketStore().readAll() + } else { + proxy.$modal.msg('请自行实现!!!') + } } // 前往通知中心点击 function onGoToGiteeClick() { @@ -102,29 +115,11 @@ function onGoToGiteeClick() { + diff --git a/src/store/modules/socket.js b/src/store/modules/socket.js index 4f821ee..2e3b4e8 100644 --- a/src/store/modules/socket.js +++ b/src/store/modules/socket.js @@ -2,7 +2,7 @@ import useUserStore from './user' import signalR from '@/signalr/signalr' const useSocketStore = defineStore('socket', { persist: { - paths: ['chatMessage', 'chatList', 'sessionList'] //存储指定key + paths: ['chatMessage', 'chatList', 'sessionList', 'newChat'] //存储指定key }, state: () => ({ onlineNum: 0, @@ -28,6 +28,9 @@ const useSocketStore = defineStore('socket', { }, getSessionList(state) { return (userid) => state.sessionList[userid] || [] + }, + getAllDotNum(state) { + return () => state.newChat } }, actions: { @@ -70,6 +73,7 @@ const useSocketStore = defineStore('socket', { data.self = data.userId == selfUserId this.chatList[sessionId].push(data) if (selfUserId == data.userId) return + this.newChat++ if (this.sessionList[selfUserId] == undefined) { this.sessionList[selfUserId] = [] @@ -90,6 +94,9 @@ const useSocketStore = defineStore('socket', { console.error(err.toString()) }) }) + }, + readAll() { + this.newChat = 0 } } })