Files
wer-admin/src/store/modules/notice.ts
疯狂的狮子Li b9e5220069 update 优化 通知公告页面增加查看详情功能 支持预览已经编辑好的富文本内容
update 优化 消息盒子相关消息可直接跳转到详情页展示富文本内容
2026-03-26 18:06:00 +08:00

48 lines
911 B
TypeScript

import { defineStore } from 'pinia';
import { reactive } from 'vue';
export interface NoticeItem {
title?: string;
category?: string;
type?: string;
source?: string;
read: boolean;
message: string;
content?: string;
data?: Record<string, any> | null;
path?: string;
time: string;
}
export const useNoticeStore = defineStore('notice', () => {
const state = reactive({
notices: [] as NoticeItem[]
});
const addNotice = (notice: NoticeItem) => {
state.notices.push(notice);
};
const removeNotice = (notice: NoticeItem) => {
state.notices.splice(state.notices.indexOf(notice), 1);
};
//实现全部已读
const readAll = () => {
state.notices.forEach((item: any) => {
item.read = true;
});
};
const clearNotice = () => {
state.notices = [];
};
return {
state,
addNotice,
removeNotice,
readAll,
clearNotice
};
});