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
| // import webSockHepler from "@/plugins/webSockHelper";
| // import useUserStore from "@/store/modules/user";
| // const userStore = useUserStore();
|
| const useWebSockStore = defineStore("websock", {
| state: () => ({
| webSock: undefined as any,
| unread: 0, //未读消息数
| msgList: [] as any[], //消息列表
| sessionList: [] as any[], //会话列表
| sessionObj: {} as any, //当前会话对象
| isopen: false, //是否处于打开状态
| }),
| actions: {
| // 设置
| changeSetting(data: Exclude<string, any>) {
| const { key, value } = data;
| if (this.hasOwnProperty(key)) {
| this[key] = value;
| }
| },
| //更新未读数量
| updateUnread() {
| let usread = this.sessionList.reduce((pre: number, cur: any) => {
| //更新未读消息数量
| return pre + cur.unReadCount;
| }, 0);
| this.unread = usread;
| },
| },
| });
| export default useWebSockStore;
|
|