import { Session } from '@/utils/storage.js';
import SystemConfig from '@/utils/SystemConfig'

const userInfosModule = {
	namespaced: true,
	state: {
		userInfos: {},
	},
	mutations: {
		// 设置用户信息
		getUserInfos(state, data) {
			state.userInfos = data;
		},
	},
	actions: {
		// 设置用户信息
		async setUserInfos({ commit }, data) {
			if (data) {
				commit('getUserInfos', data);
			} else {
				const users = Session.get(SystemConfig.adminUser);
				if (users) commit('getUserInfos', users);
			}
		},
	},
};

export default userInfosModule;
