feat: 登录页面
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import type { AppState, RouteRecordNormalized, NotificationReturn } from './types';
|
||||
|
||||
import defaultSettings from '@/config/settings.json';
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* @Author: RenXiaoDong
|
||||
* @Date: 2025-06-19 01:45:53
|
||||
*/
|
||||
import { defineStore } from 'pinia';
|
||||
import type { TabBarState, TagProps, RouteLocationNormalized } from './types';
|
||||
|
||||
import { DEFAULT_ROUTE, DEFAULT_ROUTE_NAME, REDIRECT_ROUTE_NAME } from '@/router/constants';
|
||||
|
||||
@ -1,46 +1,29 @@
|
||||
/*
|
||||
* @Author: 田鑫
|
||||
* @Date: 2023-03-05 14:57:17
|
||||
* @LastEditors: 田鑫
|
||||
* @LastEditTime: 2023-03-05 15:29:15
|
||||
* @Description: 用户相关状态
|
||||
*/
|
||||
|
||||
type Role = 'ENTERPRISE' | 'PERSON';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
interface UserState {
|
||||
role: Role;
|
||||
isLogin: boolean;
|
||||
token: String;
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: (): UserState => ({
|
||||
role: 'PERSON',
|
||||
isLogin: false,
|
||||
token: localStorage.getItem('accessToken') || '',
|
||||
}),
|
||||
|
||||
getters: {
|
||||
userRole(state) {
|
||||
return state.role;
|
||||
},
|
||||
userIsLogin(state) {
|
||||
return state.isLogin;
|
||||
},
|
||||
},
|
||||
getters: {},
|
||||
|
||||
actions: {
|
||||
setUserRole(role: Role) {
|
||||
this.role = role;
|
||||
setToken(token: String) {
|
||||
const _token = `Bearer ${token}`;
|
||||
this.token = _token;
|
||||
localStorage.setItem('accessToken', _token);
|
||||
},
|
||||
|
||||
setUserLoginStatus(isLogin: boolean) {
|
||||
this.isLogin = isLogin;
|
||||
deleteToken() {
|
||||
this.token = '';
|
||||
localStorage.removeItem('accessToken');
|
||||
},
|
||||
|
||||
async getUserInfo() {
|
||||
// todo 调用获取用户信息接口,当前用mock数据表示
|
||||
AMessage.success(`当前用户角色为:ENTERPRISE`)
|
||||
this.setUserRole('ENTERPRISE');
|
||||
// AMessage.success(`当前用户角色为:ENTERPRISE`);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user