Appearance
参数参考
渲染参数
Corptcha.render(container, options) 的 options 支持以下参数:
| 参数 | 类型 | 说明 |
|---|---|---|
apiBaseUrl | string | 验证服务 API 地址,例如 https://cpt-api.25y.cn |
siteKey | string | 站点 Site ID(cpt_ 开头),在控制台获取 |
purpose | string | 场景标识,用于区分表单用途(login/register/comment 等) |
language | 'zh-CN' | 'en-US' | 界面语言,默认 zh-CN |
appearance | 'compact' | 'normal' | 外观形态,compact 更紧凑 |
theme | object | 主题: |
autoExecute | boolean | 为 true 时挂载后自动开始验证,默认 false |
onSuccess | (token: string) => void | 验证成功回调,token 为一次性验证令牌 |
onError | (error) => void | 验证失败回调,error 含 errorCode / message |
onStateChange | (state) => void | 状态变化回调(idle/analyzing/ready/submitting/success/error/expired) |
onExpired | () => void | 验证令牌过期回调 |
实例方法
| 方法 | 说明 |
|---|---|
execute() | 手动开始验证(表单提交前未验证时调用) |
reset() | 重置为初始状态,允许重新验证 |
destroy() | 销毁组件并释放资源(页面卸载时调用) |

