Blame view

src/store/modules/user.js 816 Bytes
1 2 3 4 5
/*
 * @Description: 
 * @Autor: renchao
 * @LastEditTime: 2023-04-12 10:47:33
 */
任超 committed
6
import { getUserInfo } from '@/api/user'
赵千 committed
7
const state = {
任超 committed
8
    name: '',
赵千 committed
9
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
10
    isRefresh: false,
赵千 committed
11 12
}
const mutations = {
任超 committed
13 14
    SET_NAME: (state, data) => {
        state.name = data.loginName
15 16 17
    },
    REFRESH: (state, data) => {
        state.isRefresh = data
赵千 committed
18 19 20 21
    }
}

const actions = {
任超 committed
22 23 24
    getUserInfo ({ commit }) {
        return new Promise(async (resolve) => {
            let { result: res } = await getUserInfo()
任超 committed
25
            commit('SET_NAME', res)
任超 committed
26 27 28
            resolve(true)
        })
    },
29 30 31
    refreshPage ({ commit }, data) {
        commit('REFRESH', data)
    },
赵千 committed
32 33 34 35 36 37 38
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}