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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
| import { isBoolean } from "/@/cool/utils";
|
| const state = {
| list: [],
| current: null,
| visible: true
| };
|
| const getters = {
| // 当前会话
| session: (state: any) => state.current,
| // 会话列表
| sessionList: (state: any) => state.list,
| // 是否显示会话列表
| sessionVisible: (state: any) => state.visible
| };
|
| const actions = {};
|
| const mutations = {
| // 设置会话信息
| SET_SESSION(state: any, data: any) {
| state.current = data;
| state.current.serviceUnreadCount = 0;
| },
|
| // 清空会话信息
| CLEAR_SESSION(state: any) {
| state.session = null;
| },
|
| // 更新会话信息
| UPDATE_SESSION(state: any, data: any) {
| Object.assign(state.current, data);
| },
|
| // 设置会话列表
| SET_SESSION_LIST(state: any, data: any[]) {
| state.list = data;
| },
|
| // 清空会话列表
| CLEAR_SESSION_LIST(state: any) {
| state.list = [];
| },
|
| // 打开会话列表
| OPEN_SESSION(state: any, val: any) {
| state.visible = isBoolean(val) ? val : !state.visible;
| },
|
| // 关闭会话列表
| CLOSE_SESSION(state: any) {
| state.visible = false;
| }
| };
|
| export default {
| state,
| getters,
| actions,
| mutations
| };
|
|