Files
Yi.Admin/Yi.Bbs.Vue3/src/stores/notice.js
2024-05-23 23:40:55 +08:00

34 lines
640 B
JavaScript

import { defineStore } from "pinia";
const chatStore = defineStore("notice", {
state: () => ({
noticeList: []
}),
getters: {
noticeForNoReadCount:(state)=>{
return state.noticeList.filter(x => x.isRead ==false).length;
}
},
actions:
{
addNotice(msg) {
this.noticeList.unshift(msg);
},
addNotices(msgs) {
msgs.forEach(item => {
this.addNotice(item);
});
},
setNotices(msgs) {
this.noticeList=msgs;
},
removeNotice(id)
{
this.noticeList = this.noticeList.filter(obj => obj.id != id);
}
},
});
export default chatStore;