1. 切换账号功能
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
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
CI / CI OK (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled

This commit is contained in:
李琦
2026-05-30 16:58:05 +08:00
parent 75d1b4db42
commit d254f99a23
7 changed files with 533 additions and 57 deletions

View File

@@ -6,6 +6,7 @@ export namespace AuthApi {
account: string;
password?: string;
code?: string;
admin_id?: number;
/** @deprecated 兼容旧客户端 */
login_method?: 'phone' | 'login_account' | 'job_number';
username?: string;
@@ -15,8 +16,23 @@ export namespace AuthApi {
}
/** 登录接口返回值 */
export interface AccountOption {
account_type?: string;
id: number;
nick_name: string;
role_name: string;
store_name: string;
login_account?: string;
is_current?: boolean;
password_matched?: boolean;
}
export interface LoginResult {
token: string;
token?: string;
need_select?: boolean;
accounts?: AccountOption[];
default_account_id?: number;
default_account_type?: string;
}
export interface RefreshTokenResult {
@@ -28,6 +44,9 @@ export namespace AuthApi {
export interface SendCodeResult {
code?: string;
need_select?: boolean;
accounts?: AccountOption[];
default_account_id?: number;
default_account_type?: string;
}
}
@@ -40,6 +59,7 @@ export async function loginApi(data: AuthApi.LoginParams) {
account: data.account,
password: data.password,
code: data.code,
admin_id: data.admin_id,
});
}
@@ -66,6 +86,7 @@ export async function loginApi(data: AuthApi.LoginParams) {
export async function sendVerificationCode(params: {
account?: string;
password?: string;
admin_id?: number;
login_method?: 'phone' | 'login_account' | 'job_number';
username?: string;
phone?: string;
@@ -75,6 +96,7 @@ export async function sendVerificationCode(params: {
if (params.account) {
return requestClient.post<AuthApi.SendCodeResult>('send-verification-code', {
account: params.account,
admin_id: params.admin_id,
});
}
@@ -120,3 +142,19 @@ export async function logoutApi() {
export async function getAccessCodesApi() {
return requestClient.get<string[]>('auth/codes');
}
/**
* 同手机号可切换的管理员账号
*/
export async function getSiblingAccountsApi() {
return requestClient.get<AuthApi.AccountOption[]>('auth/sibling-accounts');
}
/**
* 切换管理员账号
*/
export async function switchAccountApi(data: {
admin_id: number;
}) {
return requestClient.post<AuthApi.LoginResult>('auth/switch-account', data);
}