From c7d850b93a7c4110336f44daa1935d0357e67eed Mon Sep 17 00:00:00 2001 From: xlsea Date: Wed, 4 Jun 2025 19:27:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=B4=E9=83=A8=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/svg-icon/bell.svg | 1 + src/enum/index.ts | 3 +- .../components/message-button.vue | 152 ++++++++++++++++++ src/layouts/modules/global-header/index.vue | 2 + src/store/modules/notice/index.ts | 9 +- src/typings/components.d.ts | 2 + 6 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 src/assets/svg-icon/bell.svg create mode 100644 src/layouts/modules/global-header/components/message-button.vue diff --git a/src/assets/svg-icon/bell.svg b/src/assets/svg-icon/bell.svg new file mode 100644 index 00000000..bffd0ce6 --- /dev/null +++ b/src/assets/svg-icon/bell.svg @@ -0,0 +1 @@ + diff --git a/src/enum/index.ts b/src/enum/index.ts index 2739b3a4..a8031544 100644 --- a/src/enum/index.ts +++ b/src/enum/index.ts @@ -3,5 +3,6 @@ export enum SetupStoreId { Theme = 'theme-store', Auth = 'auth-store', Route = 'route-store', - Tab = 'tab-store' + Tab = 'tab-store', + Notice = 'notice-store' } diff --git a/src/layouts/modules/global-header/components/message-button.vue b/src/layouts/modules/global-header/components/message-button.vue new file mode 100644 index 00000000..3b732193 --- /dev/null +++ b/src/layouts/modules/global-header/components/message-button.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/layouts/modules/global-header/index.vue b/src/layouts/modules/global-header/index.vue index 93c15ee2..1428030a 100644 --- a/src/layouts/modules/global-header/index.vue +++ b/src/layouts/modules/global-header/index.vue @@ -10,6 +10,7 @@ import GlobalBreadcrumb from '../global-breadcrumb/index.vue'; import GlobalSearch from '../global-search/index.vue'; import ThemeButton from './components/theme-button.vue'; import UserAvatar from './components/user-avatar.vue'; +import MessageButton from './components/message-button.vue'; defineOptions({ name: 'GlobalHeader' @@ -45,6 +46,7 @@ const tenantId = ref(authStore.userInfo?.user?.tenantId || '0
+ { +export const useNoticeStore = defineStore(SetupStoreId.Notice, () => { const state = reactive({ notices: [] as NoticeItem[] }); @@ -21,6 +22,10 @@ export const useNoticeStore = defineStore('notice', () => { state.notices.splice(state.notices.indexOf(notice), 1); }; + const readNotice = (notice: NoticeItem) => { + state.notices[state.notices.indexOf(notice)].read = true; + }; + // 实现全部已读 const readAll = () => { state.notices.forEach((item: any) => { @@ -31,10 +36,12 @@ export const useNoticeStore = defineStore('notice', () => { const clearNotice = () => { state.notices = []; }; + return { state, addNotice, removeNotice, + readNotice, readAll, clearNotice }; diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 6ae162ed..f735fc70 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -62,6 +62,7 @@ declare module 'vue' { NA: typeof import('naive-ui')['NA'] NAlert: typeof import('naive-ui')['NAlert'] NAvatar: typeof import('naive-ui')['NAvatar'] + NBadge: typeof import('naive-ui')['NBadge'] NBreadcrumb: typeof import('naive-ui')['NBreadcrumb'] NBreadcrumbItem: typeof import('naive-ui')['NBreadcrumbItem'] NButton: typeof import('naive-ui')['NButton'] @@ -81,6 +82,7 @@ declare module 'vue' { NDrawerContent: typeof import('naive-ui')['NDrawerContent'] NDropdown: typeof import('naive-ui')['NDropdown'] NDynamicInput: typeof import('naive-ui')['NDynamicInput'] + NEllipsis: typeof import('naive-ui')['NEllipsis'] NEmpty: typeof import('naive-ui')['NEmpty'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem']