feat: 实现登录登出的逻辑

This commit is contained in:
valarchie
2023-07-04 21:55:03 +08:00
parent 8f46526cc0
commit a021e7f9d5
10 changed files with 85 additions and 147 deletions

View File

@@ -10,6 +10,8 @@ export type CaptchaDTO = {
export type ConfigDTO = {
/** 验证码开关 */
isCaptchaOn: boolean;
/** 系统字典配置(下拉选项之类的) */
dictTypes: Map<String, Array<DictionaryData>>;
};
export type LoginByPasswordDTO = {
@@ -23,16 +25,26 @@ export type LoginByPasswordDTO = {
captchaCodeKey: string;
};
export type RefreshTokenResult = {
success: boolean;
data: {
/** `token` */
accessToken: string;
/** 用于调用刷新`accessToken`的接口时所需的`token` */
refreshToken: string;
/** `accessToken`的过期时间(格式'xxxx/xx/xx xx:xx:xx' */
expires: Date;
};
/**
* 后端token实现
*/
export type TokenDTO = {
/** token */
token: string;
/** 当前登录的用户 */
currentUser: CurrentLoginUserDTO;
};
export type CurrentLoginUserDTO = {
userInfo: any;
roleKey: string;
permissions: Set<string>;
};
export type DictionaryData = {
label: string;
value: Number;
cssTag: string;
};
/** 获取系统配置接口 */
@@ -47,10 +59,5 @@ export const getCaptchaCode = () => {
/** 登录接口 */
export const loginByPassword = (data: LoginByPasswordDTO) => {
return http.request<ResponseData<any>>("post", "/login", { data });
};
/** 刷新token */
export const refreshTokenApi = (data?: object) => {
return http.request<RefreshTokenResult>("post", "/refreshToken", { data });
return http.request<ResponseData<TokenDTO>>("post", "/login", { data });
};

View File

@@ -32,8 +32,3 @@ export type RefreshTokenResult = {
export const getLogin = (data?: object) => {
return http.request<UserResult>("post", "/login", { data });
};
/** 刷新token */
export const refreshTokenApi = (data?: object) => {
return http.request<RefreshTokenResult>("post", "/refreshToken", { data });
};