feat: update
This commit is contained in:
@@ -1,44 +1,46 @@
|
||||
import type { TicketInfoType, TokenInfoType } from 'react-rotate-captcha'
|
||||
import { getCaptcha, VerfiyCaptcha } from '@/api/captcha/api.ts'
|
||||
import type { TicketInfoType, TokenInfoType } from "react-rotate-captcha";
|
||||
import { getCaptcha, VerfiyCaptcha } from "@/api/captcha/api.ts";
|
||||
|
||||
export type ActionType = {
|
||||
code: 0 | 1
|
||||
msg: string
|
||||
}
|
||||
let image: string = ''
|
||||
code: 0 | 1;
|
||||
msg: string;
|
||||
};
|
||||
let image: string = "";
|
||||
|
||||
export async function get(): Promise<TokenInfoType> {
|
||||
const res: any = await getCaptcha()
|
||||
image = res.data.str
|
||||
return res
|
||||
const res: any = await getCaptcha();
|
||||
image = res.data.str;
|
||||
return res;
|
||||
}
|
||||
|
||||
export function isSupportWebp() {
|
||||
try {
|
||||
return (
|
||||
document
|
||||
.createElement('canvas')
|
||||
.toDataURL('image/webp', 0.5)
|
||||
.indexOf('data:image/webp') === 0
|
||||
)
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
try {
|
||||
return (
|
||||
document
|
||||
.createElement("canvas")
|
||||
.toDataURL("image/webp", 0.5)
|
||||
.indexOf("data:image/webp") === 0
|
||||
);
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function load() {
|
||||
return image
|
||||
return image;
|
||||
}
|
||||
|
||||
export function sleep(time: number) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => resolve(true), time)
|
||||
})
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => resolve(true), time);
|
||||
});
|
||||
}
|
||||
|
||||
export async function verify(token: string, deg: number): Promise<TicketInfoType> {
|
||||
const data: any = {
|
||||
token: token,
|
||||
deg: deg,
|
||||
}
|
||||
const res: any = await VerfiyCaptcha(data)
|
||||
return res
|
||||
const data: any = {
|
||||
token: token,
|
||||
deg: deg,
|
||||
};
|
||||
const res: any = await VerfiyCaptcha(data);
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user