2024-04-04 19:28:18 +08:00
|
|
|
import { defineStore } from "pinia";
|
|
|
|
|
const chatStore = defineStore("chat", {
|
|
|
|
|
state: () => ({
|
|
|
|
|
userList: [],
|
2024-04-06 18:28:32 +08:00
|
|
|
msgList: []
|
2024-04-04 19:28:18 +08:00
|
|
|
}),
|
2024-04-06 18:28:32 +08:00
|
|
|
getters: {
|
|
|
|
|
allMsgContext: (state) => state.msgList.filter(x=>x.messageType=="All"),
|
|
|
|
|
personalMsgContext: (state) => state.msgList.filter(x=>x.messageType=="Personal"),
|
|
|
|
|
},
|
|
|
|
|
actions:
|
|
|
|
|
{
|
|
|
|
|
setMsgList(value) {
|
|
|
|
|
this.msgList = value;
|
|
|
|
|
},
|
|
|
|
|
addMsg(msg) {
|
|
|
|
|
this.msgList.push(msg);
|
|
|
|
|
},
|
2024-04-04 19:28:18 +08:00
|
|
|
setUserList(value) {
|
|
|
|
|
this.userList = value;
|
|
|
|
|
},
|
2024-04-06 18:28:32 +08:00
|
|
|
addUser(user) {
|
2024-04-04 19:28:18 +08:00
|
|
|
this.userList.push(user);
|
|
|
|
|
},
|
2024-04-06 18:28:32 +08:00
|
|
|
delUser(userId) {
|
2024-04-04 19:28:18 +08:00
|
|
|
this.userList = this.userList.filter(obj => obj.userId != userId);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default chatStore;
|