Files
blog-admin-web/src/vendor/tianai-captcha/index.ts
T
2026-05-16 16:03:54 +08:00

44 lines
1.3 KiB
TypeScript

import { CaptchaConfig, TianAiCaptcha } from "./captcha/captcha.js"
export type TianAiCaptchaBindTarget = string | HTMLElement
export interface TianAiCaptchaResult {
id: string
data: Record<string, any>
}
export interface TianAiCaptchaStyle {
btnUrl?: string
moveTrackMaskBgColor?: string
moveTrackMaskBorderColor?: string
i18n?: Record<string, string>
}
export interface TianAiCaptchaConfig {
bindEl: TianAiCaptchaBindTarget
requestCaptchaDataUrl: string
types?: string[]
validCaptchaUrl?: string
timeToTimestamp?: boolean
validSuccess?: (res: any, captcha: any, tac: TianAiCaptchaInstance) => void
validFail?: (res: any, captcha: any, tac: TianAiCaptchaInstance) => void
onDataReady?: (result: TianAiCaptchaResult, captcha: any, tac: TianAiCaptchaInstance) => void | Promise<void>
btnRefreshFun?: (el: Event, tac: TianAiCaptchaInstance) => void
btnCloseFun?: (el: Event, tac: TianAiCaptchaInstance) => void
}
export interface TianAiCaptchaInstance {
init: () => TianAiCaptchaInstance
reloadCaptcha: () => void
destroyWindow: () => void
}
export function createTianAiCaptcha(
config: TianAiCaptchaConfig,
style?: TianAiCaptchaStyle,
): TianAiCaptchaInstance {
return new TianAiCaptcha(config, style) as TianAiCaptchaInstance
}
export { CaptchaConfig, TianAiCaptcha }