From d48866b2486e7c0c0cf87877d1b5e07d47dbf89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Wed, 27 Sep 2023 21:35:46 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=E6=B6=88=E6=81=AF=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=BA=A2=E7=82=B9=E3=80=81=E5=B7=B2=E8=AF=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Notice/Index.vue | 88 ++++++++++++++++++--------------- src/store/modules/socket.js | 9 +++- 2 files changed, 55 insertions(+), 42 deletions(-) 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 } } })