feat: update

This commit is contained in:
landaiqing
2024-05-20 14:34:52 +08:00
parent 3d60f1478a
commit 7e87781c85
53 changed files with 3726 additions and 2537 deletions

View File

@@ -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;
}