feat: 新增消息通知模块
This commit is contained in:
33
Yi.Bbs.Vue3/src/stores/notice.js
Normal file
33
Yi.Bbs.Vue3/src/stores/notice.js
Normal file
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user