Browse Source

⚗ 实现对象

master
wangxiang 3 years ago
parent
commit
58111bb1e7
  1. 36
      kicc-ui/src/api/sys/model/userModel.ts
  2. 5
      kicc-ui/src/store/modules/user.ts

36
kicc-ui/src/api/sys/model/userModel.ts

@ -1,6 +1,8 @@
/** /**
* @description: Login interface parameters * @description: Login interface parameters
*/ */
import {string} from "vue-types";
export interface LoginParams { export interface LoginParams {
username: string; username: string;
password: string; password: string;
@ -13,20 +15,34 @@ export interface RoleInfo {
value: string; value: string;
} }
export interface UserInfo {
accountNonExpired: boolean;
accountNonLocked: boolean;
authorities: Recordable;
credentialsNonExpired: boolean;
deptId: string;
enabled: boolean;
id: string;
password?: string;
phone: string;
tenantId: string;
username: string;
[key: string]: any;
}
/** /**
* @description: Login interface return value * @description: Login interface return value
*/ */
export interface LoginResultModel { export interface LoginResultModel {
userId: string | number; access_token: string;
token: string; clientId: string;
role: RoleInfo; expires_in: number;
accessToken: string; license: string;
avatar: string; refresh_token: string;
jti: string; scope: string;
refreshToken: string; token_type: string;
roleId: string | number; user_info: UserInfo;
tenantId: string;
userName: string;
} }
/** /**

5
kicc-ui/src/store/modules/user.ts

@ -76,12 +76,13 @@ export const useUserStore = defineStore({
*/ */
async login(params: LoginParams & { goHome?: boolean; }): Promise<GetUserInfoModel | null> { async login(params: LoginParams & { goHome?: boolean; }): Promise<GetUserInfoModel | null> {
try { try {
debugger;
const { goHome = true, ...loginParams } = params; const { goHome = true, ...loginParams } = params;
const data = await loginApi(loginParams); const data = await loginApi(loginParams);
const { accessToken } = data; const { access_token } = data;
// 保存令牌 // 保存令牌
this.setToken(accessToken); this.setToken(access_token);
// 获取用户信息 // 获取用户信息
const userInfo = await this.getUserInfoAction(); const userInfo = await this.getUserInfoAction();

Loading…
Cancel
Save