mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat: 头部新增消息按钮
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { reactive } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { SetupStoreId } from '@/enum';
|
||||
|
||||
interface NoticeItem {
|
||||
title?: string;
|
||||
@ -8,7 +9,7 @@ interface NoticeItem {
|
||||
time: string;
|
||||
}
|
||||
|
||||
export const useNoticeStore = defineStore('notice', () => {
|
||||
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
|
||||
};
|
||||
|
Reference in New Issue
Block a user