优化功能
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
This commit is contained in:
@@ -3,9 +3,13 @@ import { baseRequestClient, requestClient } from '#/api/request';
|
||||
export namespace AuthApi {
|
||||
/** 登录接口参数 */
|
||||
export interface LoginParams {
|
||||
login_method?: 'phone' | 'login_account' | 'job_number'; // 登录方式类型
|
||||
password?: string;
|
||||
username?: string;
|
||||
phone?: string; // 手机号(当login_method为phone时)
|
||||
code?: string;
|
||||
login_account?: string; // 登录账号(当login_method为login_account时)
|
||||
job_number?: string; // 工号(当login_method为job_number时)
|
||||
}
|
||||
|
||||
/** 登录接口返回值 */
|
||||
@@ -17,25 +21,62 @@ export namespace AuthApi {
|
||||
data: string;
|
||||
status: number;
|
||||
}
|
||||
|
||||
/** 发送验证码返回结果 */
|
||||
export interface SendCodeResult {
|
||||
code?: string; // 开发环境返回验证码
|
||||
accounts?: Array<{
|
||||
id: number;
|
||||
login_account: string;
|
||||
job_number: string;
|
||||
}>; // 如果手机号绑定多个账号,返回账号列表
|
||||
need_select?: boolean; // 是否需要选择账号/工号
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
export async function loginApi(data: AuthApi.LoginParams) {
|
||||
return requestClient.post<AuthApi.LoginResult>('login', {
|
||||
phone: data.username,
|
||||
const params: any = {
|
||||
login_method: data.login_method || 'phone', // 添加默认值
|
||||
password: data.password,
|
||||
code: data.code,
|
||||
});
|
||||
};
|
||||
|
||||
if (data.login_method === 'phone') {
|
||||
params.phone = data.phone || data.username;
|
||||
} else if (data.login_method === 'login_account') {
|
||||
params.login_account = data.login_account;
|
||||
} else if (data.login_method === 'job_number') {
|
||||
params.job_number = data.job_number;
|
||||
}
|
||||
|
||||
return requestClient.post<AuthApi.LoginResult>('login', params);
|
||||
}
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
export async function sendVerificationCode(username: string) {
|
||||
return requestClient.post('send-verification-code', {
|
||||
username,
|
||||
});
|
||||
export async function sendVerificationCode(params: {
|
||||
login_method?: 'phone' | 'login_account' | 'job_number';
|
||||
username?: string;
|
||||
phone?: string;
|
||||
login_account?: string;
|
||||
job_number?: string;
|
||||
}) {
|
||||
const requestParams: any = {
|
||||
login_method: params.login_method || 'phone',
|
||||
};
|
||||
|
||||
if (params.login_method === 'phone') {
|
||||
requestParams.phone = params.phone || params.username;
|
||||
} else if (params.login_method === 'login_account') {
|
||||
requestParams.login_account = params.login_account;
|
||||
} else if (params.login_method === 'job_number') {
|
||||
requestParams.job_number = params.job_number;
|
||||
}
|
||||
|
||||
return requestClient.post<AuthApi.SendCodeResult>('send-verification-code', requestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user