user.js 1.49 KB
/*
 * @Description:
 * @Autor: renchao
 * @LastEditTime: 2024-03-21 13:34:48
 */
import { getUserInfo } from '@/api/user'
const state = {
    name: '',
    userInfo: {},
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
    isRefresh: false,
    // 弹窗返回需要回传的值
    pouopData: {},
    // 业务流程刷新
    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
    },
    SETPOUOPDATA: (state, data) => {
        state.pouopData = 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)
    },
    // 存储弹窗data的值
    getPouopData ({ commit }, data) {
        commit('SETPOUOPDATA', data)
    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}