user.js
1.25 KB
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
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2024-02-01 16:27:16
*/
import { getUserInfo } from '@/api/user'
const state = {
name: '',
userInfo: {},
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
isRefresh: false,
// 业务流程刷新
workFresh: false,
// 左侧菜单刷新
menuRefresh: false
}
const mutations = {
SET_NAME: (state, data) => {
state.name = data.loginName
state.userInfo = data
},
REFRESH: (state, data) => {
state.isRefresh = data
},
SETWORKFRESH: (state, data) => {
state.workFresh = data
},
SETMENUREFRESH: (state, data) => {
state.menuRefresh = data
},
}
const actions = {
getUserInfo ({ commit }) {
return new Promise(async (resolve) => {
let { result: res } = await getUserInfo()
commit('SET_NAME', res)
resolve(true)
})
},
refreshPage ({ commit }, data) {
commit('REFRESH', data)
},
reWorkFresh ({ commit }, data) {
commit('SETWORKFRESH', data)
},
reMenuRefresh ({ commit }, data) {
commit('SETMENUREFRESH', data)
},
}
export default {
namespaced: true,
state,
mutations,
actions
}