# topnet-captcha

> 行为验证器

Latest version **1.3.0** (published 2023-11-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install topnet-captcha
pnpm add topnet-captcha
yarn add topnet-captcha
bun add topnet-captcha
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2023-11-10 |
| First published | 2023-11-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | coderLi |
| Maintainers | lionlylovek |

## Links

- npm: https://www.npmjs.com/package/topnet-captcha
- npm.io page: https://npm.io/package/topnet-captcha

## Dependencies (1)

- [jquery](https://npm.io/package/jquery.md) ^3.6.0

## Recent versions

- 1.3.0 (latest) — 2023-11-10
- 1.2.0 — 2023-11-10
- 1.1.0 — 2023-11-10
- 1.0.0 — 2023-11-10

## README

# Captcha.js

## Captcha.js 是一个行为验证器插件，用于实现四种类型的验证码组件。使用该插件前需要先引入 jQuery、Captcha.js 和 Captcha.css。以下是关于如何使用 Captcha.js 的说明：

安装
首先，在你的项目中引入 jQuery、Captcha.js 和 Captcha.css 文件。

```javascript
$("#createCaptcha").click(function () {
  /**
   * @description: 四个类型的行为验证器插件,需要先引入 jquery, Captcha.js 和 Captcha.css
   * @param {String} selector - 用于指定验证码组件所要附加到的元素的选择器。class 为 .dom，id 为 #dom
   * @param {Object} options - 用于配置验证码组件的选项。
   * @param {String} options.type - 验证码组件的类型,不传默认为 slider 滑块验证码,
   *   - CONCAT(滑动还原验证码)
   *   - ROTATE(旋转验证码)
   *   - WORD*IMAGE_CLICK(点选验证码)
   * @param {String} options.placeholder - 在验证组件中显示的占位文本。
   * @param {String} options.baseUrl - 向验证码服务器发起请求时的基本 URL。
   * @param {Boolean} options.isPrintLog - 是否打印日志
   * @param {Object} options.headers - 在向验证码服务器发起请求时要包含的头部信息。
   * @param {String} options.headers.token - 用于验证向验证码服务器发起请求的令牌。
   * @param {Function} options.successed - 验证码验证成功时要执行的回调函数。
   * @param {Function} options.failed - 验证码验证失败时要执行的回调函数。
   * @returns {Object} - 新创建的验证码组件。
   */
  myComponent = new Captcha("#com", {
    type: "ROTATE",
    placeholder: "拖动滑块到正确位置",
    baseUrl: "xxxx",
    headers: {
      token: "this is token",
    },
    isPrintLog: true,
    successed: function (res) {
      alert("验证成功");
      // myComponent.close() 关闭验证弹窗事件
    },
    failed: function (err) {
      alert("验证失败");
    },
  });
});
```

参数说明
selector：用于指定验证码组件所要附加到的元素的选择器。

可以使用 class (".dom") 或 id ("#dom")。
options.type（可选）：

验证码组件的类型，

默认为 slider（滑块验证码）。

可选值有：
CONCAT（滑动还原验证码）
ROTATE（旋转验证码）
WORD\*IMAGE_CLICK（点选验证码）
options.placeholder（可选）：在验证组件中显示的占位文本。
options.baseUrl（可选）：向验证码服务器发起请求时的基本 URL。
options.isPrintLog（可选）：是否打印日志。
options.headers（可选）：在向验证码服务器发起请求时要包含的头部信息。
options.headers.token（可选）：用于验证向验证码服务器发起请求的令牌。
options.successed（可选）：验证码验证成功时要执行的回调函数。
options.failed（可选）：验证码验证失败时要执行的回调函数。
方法
myComponent.close()：关闭验证码弹窗事件。

---
_Source: https://npm.io/package/topnet-captcha · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
