first commit
This commit is contained in:
46
src/stores/modules/user/index.ts
Normal file
46
src/stores/modules/user/index.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* @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');
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user