创建请求验证码和登录接口

This commit is contained in:
2026-06-07 11:26:28 +08:00
parent caf9038dfa
commit 78192a2f61
4 changed files with 166 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { RequestConfig } from "@/types/HttpClientType.uts"
import { HttpMethod } from "@/enum/HttpMethod.uts"
import { VerifyCodeResult } from "@/api/types.uts"
import { HttpClient } from "@/utils/HttpClient"
export class CodeApi {
private static http = HttpClient.getInstance()
static async getImgCode() : Promise<VerifyCodeResult> {
const config = new RequestConfig()
config.url = "/auth/code"
config.method = HttpMethod.GET
const res = await this.http.request<UTSJSONObject>(config)
const data = res.data
if (data == null) {
throw new Error("验证码数据异常")
}
// 手动转换 UTSJSONObject 到 VerifyCodeResult
const result: VerifyCodeResult = {
captchaEnabled: data["captchaEnabled"] as boolean ?? false,
uuid: data["uuid"] as string ?? "",
img: data["img"] as string ?? ""
}
return result
}
}