diff --git a/src/api/auth/index.ts b/src/api/auth/index.ts index 8c85cef9..61de631a 100644 --- a/src/api/auth/index.ts +++ b/src/api/auth/index.ts @@ -3,6 +3,7 @@ import { AxiosPromise } from 'axios'; import { LoginData, LoginResult } from './types'; /** + * 登录API * * @param data {LoginData} * @returns @@ -16,7 +17,7 @@ export function loginApi(data: LoginData): AxiosPromise { } /** - * 注销 + * 注销API */ export function logoutApi() { return request({ diff --git a/src/api/auth/types.ts b/src/api/auth/types.ts index 641530b9..cd8bd3a3 100644 --- a/src/api/auth/types.ts +++ b/src/api/auth/types.ts @@ -1,8 +1,14 @@ /** - * 登录请求 + * 登录请求参数 */ export interface LoginData { + /** + * 用户名 + */ username: string; + /** + * 密码 + */ password: string; } @@ -10,16 +16,20 @@ export interface LoginData { * 登录响应 */ export interface LoginResult { - accessToken: string; - tokenType: string; - refreshToken: string; - expires: number; -} - -/** - * 验证码类型 - */ -export interface VerifyCode { - verifyCodeImg: string; - verifyCodeKey: string; + /** + * 访问token + */ + accessToken?: string; + /** + * 过期时间(单位:毫秒) + */ + expires?: number; + /** + * 刷新token + */ + refreshToken?: string; + /** + * token 类型 + */ + tokenType?: string; } diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index b61af479..9e39254a 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -19,9 +19,9 @@ export const useUserStore = defineStore('user', () => { const perms = ref>([]); // 用户权限编码集合 → 判断按钮权限 /** - * 登录 + * 登录调用 * - * @param loginData + * @param {LoginData} * @returns */ function login(loginData: LoginData) { @@ -29,7 +29,7 @@ export const useUserStore = defineStore('user', () => { loginApi(loginData) .then(response => { const { tokenType, accessToken } = response.data; - token.value = tokenType + ' ' + accessToken; + token.value = tokenType + ' ' + accessToken; // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx resolve(); }) .catch(error => {