Files
lingji-work-fe/src/stores/modules/user/index.ts

47 lines
927 B
TypeScript
Raw Normal View History

2025-06-16 14:42:26 +08:00
/*
* @Author:
* @Date: 2023-03-05 14:57:17
* @LastEditors:
* @LastEditTime: 2023-03-05 15:29:15
* @Description:
*/
type Role = 'ENTERPRISE' | 'PERSON';
interface UserState {
role: Role;
isLogin: boolean;
}
export const useUserStore = defineStore('user', {
state: (): UserState => ({
role: 'PERSON',
isLogin: false,
}),
getters: {
userRole(state) {
return state.role;
},
userIsLogin(state) {
return state.isLogin;
},
},
actions: {
setUserRole(role: Role) {
this.role = role;
},
setUserLoginStatus(isLogin: boolean) {
this.isLogin = isLogin;
},
async getUserInfo() {
// todo 调用获取用户信息接口当前用mock数据表示
AMessage.success(`当前用户角色为ENTERPRISE`)
this.setUserRole('ENTERPRISE');
},
},
});