28 lines
849 B
Plaintext
28 lines
849 B
Plaintext
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
|
|
}
|
|
} |