Blame view

src/store/modules/user.js 1.04 KB
1
/*
xiaomiao committed
2
 * @Description:
3
 * @Autor: renchao
1  
renchao@pashanhoo.com committed
4
 * @LastEditTime: 2023-07-28 15:45:21
5
 */
任超 committed
6
import { getUserInfo } from '@/api/user'
赵千 committed
7
const state = {
任超 committed
8
    name: '',
xiaomiao committed
9
    userInfo:{},
赵千 committed
10
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
11
    isRefresh: false,
1  
renchao@pashanhoo.com committed
12 13
    // 业务流程刷新
    workFresh: false
赵千 committed
14 15
}
const mutations = {
任超 committed
16 17
    SET_NAME: (state, data) => {
        state.name = data.loginName
xiaomiao committed
18
        state.userInfo = data
19 20
    },
    REFRESH: (state, data) => {
xiaomiao committed
21

22
        state.isRefresh = data
1  
renchao@pashanhoo.com committed
23 24 25
    },
    SETWORKFRESH: (state, data) => {
        state.workFresh = data
赵千 committed
26 27 28 29
    }
}

const actions = {
任超 committed
30 31 32
    getUserInfo ({ commit }) {
        return new Promise(async (resolve) => {
            let { result: res } = await getUserInfo()
任超 committed
33
            commit('SET_NAME', res)
任超 committed
34 35 36
            resolve(true)
        })
    },
37 38 39
    refreshPage ({ commit }, data) {
        commit('REFRESH', data)
    },
1  
renchao@pashanhoo.com committed
40 41 42
    reWorkFresh ({ commit }, data) {
        commit('SETWORKFRESH', data)
    }
赵千 committed
43 44 45 46 47 48 49
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}