🌱 完成相关请求,待测试 #47

This commit is contained in:
BTMuli
2023-09-30 16:13:05 +08:00
parent 137180028e
commit bd67ee7a25
6 changed files with 306 additions and 91 deletions

View File

@@ -47,4 +47,65 @@ declare namespace TGApp.BBS.Geetest {
challenge: string;
validate: string;
}
/**
* @description 极验验证的请求方法-请求参数
* @since Beta v0.3.3
* @interface InitGeetestParams
* @property {string} gt - 极验验证 gt
* @property {string} challenge - 极验验证 challenge
* @property {boolean} offline - 极验验证 offline
* @property {boolean} new_captcha - 极验验证 new_captcha
* @property {string} product - 极验验证 product
* @property {string} width - 极验验证 width
* @property {boolean} https - 极验验证 https
* @return InitGeetestParams
*/
export interface InitGeetestParams {
gt: string;
challenge: string;
offline: boolean;
new_captcha: boolean;
product: string;
width: string;
https: boolean;
}
/**
* @description Geetest 插件 captchaObj
* @since Beta v0.3.3
* @todo 完善
* @interface GeetestCaptcha
* @property {string} getValidate
* @property {Function} onReady
* @property {Function} onRefresh
* @property {Function} onSuccess
* @property {Function} onError
* @property {Function} onClose
* @return GeetestCaptcha
*/
export interface GeetestCaptcha {
appendTo: (selector: string) => void;
getValidate: () => GeetestValidate;
onReady: (callback: () => void) => GeetestCaptcha;
onRefresh: (callback: () => void) => GeetestCaptcha;
onSuccess: (callback: () => void) => GeetestCaptcha;
onError: (callback: () => void) => GeetestCaptcha;
onClose: (callback: () => void) => GeetestCaptcha;
}
/**
* @description Geetest 插件 validate
* @since Beta v0.3.3
* @interface GeetestValidate
* @property {string} geetest_challenge
* @property {string} geetest_validate
* @property {string} geetest_seccode
* @return GeetestValidate
*/
export interface GeetestValidate {
geetest_challenge: string;
geetest_validate: string;
geetest_seccode: string;
}
}

View File

@@ -1,89 +0,0 @@
/**
* @file src types Plugins Geetest.d.ts
* @description Geetest 插件类型声明文件
* @author BTMuli <bt-muli@outlook.com>
* @since 3.0.0
*/
/**
* @description 因为引入 gt.js其 initGeetest 挂载到 window 上,所以需要声明 window
* @since 3.0.0
* @interface window
* @return window
*/
type window = Window & typeof globalThis;
globalThis.window = globalThis.window || globalThis;
declare global {
interface Window {
initGeetest: InitGeetest;
}
}
/**
* @description Geetest 插件初始化函数
* @since 3.0.0
* @interface InitGeetest
* @return InitGeetest
*/
export type InitGeetest = (
initGeetestOptions: InitGeetestOptions,
initGeetestCallback: InitGeetestCallback,
) => void;
/**
* @description Geetest 插件初始化函数参数
* @since 3.0.0
* @todo 完善
* @interface InitGeetestOptions
* @property {string} gt Geetest ID
* @property {string} challenge Geetest challenge
* @property {boolean} offline Geetest offline
* @property {boolean} new_captcha Geetest new_captcha
* @property {string} product Geetest product
* @property {string} width Geetest width
* @property {boolean} https Geetest https
* @return InitGeetestOptions
*/
export interface InitGeetestOptions {
gt: string;
challenge: string;
offline: boolean;
new_captcha: boolean;
product: string;
width: string;
https: boolean;
}
/**
* @description Geetest 插件初始化函数回调
* @since 3.0.0
* @todo 完善
* @interface InitGeetestCallback
* @return InitGeetestCallback
*/
export type InitGeetestCallback = (captchaObj: GeetestCaptcha) => void;
/**
* @description Geetest 插件 captchaObj
* @since 3.0.0
* @todo 完善
* @interface GeetestCaptcha
* @property {string} getValidate
* @property {Function} onReady
* @property {Function} onRefresh
* @property {Function} onSuccess
* @property {Function} onError
* @property {Function} onClose
* @return GeetestCaptcha
*/
export interface GeetestCaptcha {
appendTo: (selector: string) => void;
getValidate: () => string;
onReady: (callback: () => void) => void;
onRefresh: (callback: () => void) => void;
onSuccess: (callback: () => void) => void;
onError: (callback: () => void) => void;
onClose: (callback: () => void) => void;
}