Files
lotteryAdmin/src/api/admin-auth.ts
2026-05-09 11:16:00 +08:00

38 lines
955 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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,
});
}