init:first commit of plus-ui
This commit is contained in:
42
src/store/modules/notice.ts
Normal file
42
src/store/modules/notice.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
interface NoticeItem {
|
||||
title?: string;
|
||||
read: boolean;
|
||||
message: any;
|
||||
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
|
||||
};
|
||||
});
|
||||
|
||||
export default useNoticeStore;
|
Reference in New Issue
Block a user