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 @@ @@ -1,6 +1,8 @@
/**
* @description: Login interface parameters
*/
import {string} from "vue-types";
export interface LoginParams {
username: string;
password: string;
@ -13,20 +15,34 @@ export interface RoleInfo { @@ -13,20 +15,34 @@ export interface RoleInfo {
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
*/
export interface LoginResultModel {
userId: string | number;
token: string;
role: RoleInfo;
accessToken: string;
avatar: string;
jti: string;
refreshToken: string;
roleId: string | number;
tenantId: string;
userName: string;
access_token: string;
clientId: string;
expires_in: number;
license: string;
refresh_token: string;
scope: string;
token_type: string;
user_info: UserInfo;
}
/**

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

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

Loading…
Cancel
Save