38 lines
955 B
TypeScript
38 lines
955 B
TypeScript
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,
|
||
});
|
||
}
|