From ebc7760de2c714f23cf5b32b7f5ced77fbe18fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Fri, 27 Mar 2026 14:34:38 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=AE=8C=E6=88=90=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9B=92=E5=AD=90=E5=8A=9F=E8=83=BD=E5=89=8D=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E8=81=94=E5=8A=A8(=E5=B7=B2=E8=AF=BB=E6=9C=AA=E8=AF=BB?= =?UTF-8?q?=E5=9C=A8=E5=89=8D=E7=AB=AF=E6=B5=8F=E8=A7=88=E5=99=A8=E5=AD=98?= =?UTF-8?q?=E5=82=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.ts | 5 +- src/api/system/message/index.ts | 10 ++++ src/api/system/message/types.ts | 17 +++++++ src/layout/components/Navbar.vue | 11 +---- src/layout/components/notice/index.vue | 17 ++++++- src/layout/index.vue | 10 ++-- src/store/modules/notice.ts | 67 ++++++++++++++++++++++---- src/utils/message-read.ts | 45 +++++++++++++++++ src/utils/push-message.ts | 3 ++ src/utils/push.ts | 45 ++++++++++++++++- 10 files changed, 200 insertions(+), 30 deletions(-) create mode 100644 src/api/system/message/index.ts create mode 100644 src/api/system/message/types.ts create mode 100644 src/utils/message-read.ts diff --git a/src/api/login.ts b/src/api/login.ts index 134ecfa1..ac53f3c0 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -53,10 +53,7 @@ export function register(data: any) { */ export function logout() { closePush(); - if ( - import.meta.env.VITE_APP_MESSAGE_ENABLED === 'true' - && import.meta.env.VITE_APP_MESSAGE_TRANSPORT.toLowerCase() !== 'websocket' - ) { + if (import.meta.env.VITE_APP_MESSAGE_ENABLED === 'true' && import.meta.env.VITE_APP_MESSAGE_TRANSPORT.toLowerCase() === 'sse') { request({ url: import.meta.env.VITE_APP_MESSAGE_PATH + '/close', method: 'get' diff --git a/src/api/system/message/index.ts b/src/api/system/message/index.ts new file mode 100644 index 00000000..88663019 --- /dev/null +++ b/src/api/system/message/index.ts @@ -0,0 +1,10 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { MessageBoxVO } from './types'; + +export function getMessageBox(): AxiosPromise { + return request({ + url: '/system/message/box', + method: 'get' + }); +} diff --git a/src/api/system/message/types.ts b/src/api/system/message/types.ts new file mode 100644 index 00000000..18a6591f --- /dev/null +++ b/src/api/system/message/types.ts @@ -0,0 +1,17 @@ +export interface MessageVO extends BaseEntity { + messageId: number | string; + category: string; + type: string; + source: string; + title: string; + message: string; + content?: string; + data?: Record | null; + path?: string; +} + +export interface MessageBoxVO { + systemList: MessageVO[]; + noticeList: MessageVO[]; + workflowList: MessageVO[]; +} diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 726c285d..e614865c 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -30,7 +30,7 @@
@@ -107,7 +107,6 @@ const appStore = useAppStore(); const userStore = useUserStore(); const settingsStore = useSettingsStore(); const noticeStore = storeToRefs(useNoticeStore()); -const newNotice = ref(0); const { proxy } = getCurrentInstance() as ComponentInternalInstance; @@ -158,14 +157,6 @@ const handleCommand = (command: string) => { commandMap[command](); } }; -//用深度监听 消息 -watch( - () => noticeStore.state.value.notices, - (newVal) => { - newNotice.value = newVal.filter((item: any) => !item.read).length; - }, - { deep: true } -);