diff --git a/src/layouts/default/header/components/notify/NoticeReader.vue b/src/layouts/default/header/components/notify/NoticeReader.vue index 57478e71..1d6c5a45 100644 --- a/src/layouts/default/header/components/notify/NoticeReader.vue +++ b/src/layouts/default/header/components/notify/NoticeReader.vue @@ -24,6 +24,9 @@ import { $ref } from 'vue/macros' import { SiteMessage } from '/@/views/modules/notice/site/SiteMessage.api' import { findById, read } from './SiteMessage.api' + import { useSiteMessageStore } from '/@/layouts/default/header/components/notify/SiteMessage.store' + + const siteMessageStore = useSiteMessageStore() const modalWidth = $ref('60%') let visible = $ref(false) @@ -37,7 +40,7 @@ message = messageInfo findById(messageInfo.id).then(({ data }) => { message = data - read(messageInfo.id) + read(messageInfo.id).then(() => siteMessageStore.updateNotReadCount()) confirmLoading = false }) } diff --git a/src/layouts/default/header/components/notify/SiteMessage.store.ts b/src/layouts/default/header/components/notify/SiteMessage.store.ts new file mode 100644 index 00000000..56a2163d --- /dev/null +++ b/src/layouts/default/header/components/notify/SiteMessage.store.ts @@ -0,0 +1,22 @@ +import { defineStore } from 'pinia' +import { store } from '/@/store' +import { countByReceiveNotRead } from './SiteMessage.api' + +export const useSiteMessageStore = defineStore({ + id: 'SiteMessageStore', + state: () => ({ + notReadCount: 0, + }), + actions: { + // 更新未读消息数量 + updateNotReadCount() { + countByReceiveNotRead().then(({ data }) => { + this.notReadCount = data + }) + }, + }, +}) +// setup 之外之使用 +export function useSiteMessageStoreWithOut() { + return useSiteMessageStore(store) +} diff --git a/src/layouts/default/header/components/notify/index.vue b/src/layouts/default/header/components/notify/index.vue index 5083c65c..3cee7b9c 100644 --- a/src/layouts/default/header/components/notify/index.vue +++ b/src/layouts/default/header/components/notify/index.vue @@ -26,7 +26,7 @@
- 查看更多 + 查看{{ num }}更多
@@ -35,15 +35,18 @@ diff --git a/src/store/modules/multipleTab.ts b/src/store/modules/multipleTab.ts index 8afa34e8..5371e6ad 100644 --- a/src/store/modules/multipleTab.ts +++ b/src/store/modules/multipleTab.ts @@ -13,7 +13,6 @@ import { getRawRoute } from '/@/utils' import { MULTIPLE_TABS_KEY } from '/@/enums/cacheEnum' import projectSetting from '/@/settings/projectSetting' -import { useUserStore } from '/@/store/modules/user' export interface MultipleTabState { cacheTabList: Set