@blazes/captcha
v1.0.27
Published
滑动验证块
Keywords
Readme
背景
点击发送验证码按钮时候,用户需要将图片滑动至指定位置,才会真正发送。 防止玩家或者脚本等频繁调用验证码接口。
安装
npm
npm install @blazes/captchayarn
yarn add @blazes/captchaCDN
<head>
...
<link
rel="stylesheet"
href="https://captcha.resource.pandadagames.com/statics/style.css"
/>
</head>
<body></body>
<script src="https://captcha.resource.pandadagames.com/statics/index.js"></script>API
实例化参数
| 属性 | 说明 | 必填 | 类型 | | --- | ---- | --- | --- | | appId | 接入的应用 id | 是 | string | | version | 版本信息,不同版本产生背景图不一样,目前只有 v1 | 是 | string | | baseUrl | 后端地址,需要配置 cors | 是 | string | | success | 验证成功后的回调函数 | 是 | (token: string) => string | | lang | 语言 | 是 | 枚举,hans | hant | ja | en | ko |
方法
| 名称 | 说明 | 入参 | 回参 | | --- | --- | --- | --- | | show | 显示验证码。验证成功会返回 token 的 promise | 无 | Promise | | resetConfig | 重置配置 | 和实例化传入参数一致,但都是选填。 | 无 |
使用
CDN 引入
const myCaptcha = new yh_captcha.Captcha({
appId: "giftcode",
version: "v1",
baseUrl: "http://52.74.243.209:18081"
success: function (token) {},
lang: "ja",
});
myCaptcha.show().then(() => {});npm引入
import { Captcha, Language } from "@blazes/captcha";
import "@blazes/captcha/dist/style.css";
const myCaptcha = new Captcha({
appId: "giftcode",
version: "v1",
baseUrl: "http://52.74.243.209:18081",
success: function (token) {},
lang: Language.JA,
});
myCaptcha.show().then(() => {});