docs: 完善注释

Former-commit-id: 7a03ecf0ed497da80924b8f6a5117c2e783b6d4d
This commit is contained in:
haoxr
2023-03-16 01:09:35 +08:00
parent cfd7c0277e
commit 6e1eccc9c0
3 changed files with 28 additions and 17 deletions

View File

@@ -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<LoginResult> {
}
/**
* 注销
* 注销API
*/
export function logoutApi() {
return request({

View File

@@ -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;
}

View File

@@ -19,9 +19,9 @@ export const useUserStore = defineStore('user', () => {
const perms = ref<Array<string>>([]); // 用户权限编码集合 → 判断按钮权限
/**
* 登录
* 登录调用
*
* @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 => {