user.js 1018 Bytes
/*
 * @Description: 
 * @Autor: renchao
 * @LastEditTime: 2023-07-28 15:26:16
 */
import { getUserInfo } from '@/api/user'
const state = {
    name: '',
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
    isRefresh: false,
    // 业务流程刷新
    workFresh: false
}
const mutations = {
    SET_NAME: (state, data) => {
        state.name = data.loginName
    },
    REFRESH: (state, data) => {
        state.isRefresh = data
    },
    SETWORKFRESH: (state, data) => {
        state.workFresh = 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)
    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}