feat:添加管理员登录
This commit is contained in:
37
src/api/admin-auth.ts
Normal file
37
src/api/admin-auth.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
hasLotteryAdminApiBaseUrl,
|
||||
publicAdminRequest,
|
||||
} from "@/lib/admin-http";
|
||||
import type {
|
||||
AdminAuthCaptchaResponse,
|
||||
AdminAuthLoginRequest,
|
||||
AdminAuthLoginResponse,
|
||||
} from "@/types/api/admin-auth";
|
||||
|
||||
import { API_V1_PREFIX } from "@/api/paths";
|
||||
|
||||
/** `GET /api/v1/admin/auth/captcha`(无需 Token) */
|
||||
export async function getAdminCaptcha(): Promise<AdminAuthCaptchaResponse | null> {
|
||||
if (!hasLotteryAdminApiBaseUrl()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return await publicAdminRequest<AdminAuthCaptchaResponse>({
|
||||
url: `${API_V1_PREFIX}/admin/auth/captcha`,
|
||||
method: "GET",
|
||||
});
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** `POST /api/v1/admin/auth/login`(无需 Token) */
|
||||
export async function postAdminLogin(
|
||||
body: AdminAuthLoginRequest,
|
||||
): Promise<AdminAuthLoginResponse> {
|
||||
return publicAdminRequest<AdminAuthLoginResponse>({
|
||||
url: `${API_V1_PREFIX}/admin/auth/login`,
|
||||
method: "POST",
|
||||
data: body,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user