import * as vue from "vue"; import { TemplateRef } from "vue"; //#region src/use-image-verify.d.ts /** * 算术运算验证码配置 */ type OperationConfig = { /** 运算数字范围(0到figure-1),默认值为 10 */figure?: number; /** 运算符类型,不指定则随机选择,可选值为 '+' | '-' | '*' */ arith?: '+' | '-' | '*'; }; /** * 字符验证码配置 */ type CharacterConfig = { /** 验证码长度,默认值为 4 */length?: number; /** 字符池,从中随机选择字符,默认值为 '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' */ characterPool?: string; }; /** * 图片验证码基础配置选项 */ type ImageVerifyOptions = { /** 画布宽度(像素),默认值为 120 */width?: number; /** 画布高度(像素),默认值为 40 */ height?: number; /** 点击画布时是否刷新验证码,默认值为 true */ refreshOnClick?: boolean; /** 干扰线数量,默认值为 10 */ disturbLine?: number; /** 干扰点数量,默认值为 40 */ disturbPoint?: number; type: 'operation' | 'character'; operationOptions?: OperationConfig; characterOptions?: CharacterConfig; }; /** * 图片验证码 Composable * * 用于创建和管理图片验证码,支持字符验证码和算术运算验证码两种类型 * * @param templateRef Canvas 元素的模板引用 * @param options 验证码配置选项 * @returns 验证码相关的响应式数据和方法 * * @example * ```ts * // 字符验证码 * const canvasRef = ref() * const { value, code, passed, validate, reset, refresh } = useImageVerify(canvasRef, { * type: 'character', * width: 120, * height: 40, * characterOptions: { * length: 4, * characterPool: '0123456789' * } * }) * * // 算术运算验证码 * const { value, code, passed, validate } = useImageVerify(canvasRef, { * type: 'operation', * operationOptions: { * figure: 10, * arith: '+' * } * }) * * // 验证 * value.value = '1234' * await validate() // 验证通过 * * // 重置 * reset() * * // 刷新 * refresh() * ``` */ declare function useImageVerify(templateRef: TemplateRef, options?: ImageVerifyOptions): { templateRef: Readonly>; value: vue.Ref; code: Readonly>; passed: vue.ComputedRef; validate: () => Promise; reset: () => void; refresh: () => void; }; /** * useImageVerify 返回类型 */ type UseImageVerifyReturns = ReturnType; //#endregion export { ImageVerifyOptions, UseImageVerifyReturns, useImageVerify };