广丰卷烟厂数采质量分析系统
zhuguifei
2026-03-02 80ff784bf60637cd348ae665fc907f7b1e527dd8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { reactive } from 'vue';
import { defineStore } from 'pinia';
import { SetupStoreId } from '@/enum';
 
interface NoticeItem {
  title?: string;
  read: boolean;
  message: any;
  time: string;
}
 
export const useNoticeStore = defineStore(SetupStoreId.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 readNotice = (notice: NoticeItem) => {
    state.notices[state.notices.indexOf(notice)].read = true;
  };
 
  // 实现全部已读
  const readAll = () => {
    state.notices.forEach((item: any) => {
      item.read = true;
    });
  };
 
  const clearNotice = () => {
    state.notices = [];
  };
 
  return {
    state,
    addNotice,
    removeNotice,
    readNotice,
    readAll,
    clearNotice
  };
});
 
export default useNoticeStore;