创建请求验证码和登录接口
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user