PixelAI-admin/src/stores/userInfo.ts

28 lines
573 B
TypeScript
Raw Normal View History

import { defineStore } from 'pinia';
import { UserInfosStates, UserInfosState } from './interface';
import { Session } from '/@/utils/storage';
// 用户信息
export const useUserInfo = defineStore('userInfo', {
state: (): UserInfosStates => ({
userInfos: {
authBtnList: [],
photo: '',
roles: [],
time: 0,
userName: '',
},
}),
actions: {
async setUserInfos(data?: UserInfosState) {
if (data) {
this.userInfos = <any>data;
} else {
if (Session.get('userInfo')) {
this.userInfos = Session.get('userInfo');
}
}
},
},
});