1.0.8 • Published 2 years ago

graph-validate-lib v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

graph-validate-lib

图形验证库 提供随机字符、滑块、文字点选、数字计算、滑动图片等验证功能的图形化 UI 库

randomBlock

随机字符验证

new randomBlock(
  {
    container: document.getElementById("block"),
    line: true,
    point: true,
    fill: true,
    fontSize: 50,
    charNum: 5,
    factor: "1234567890",
  },
  function (randomStr) {
    console.log(randomStr);
  }
);
参数说明默认值
containerDOM 节点-
line干扰线false
point噪点false
fill字体填充false
fontSize字体大小50
charNum随机字符数量4
factor随机因子ABCDEFGHIJKL...
callback回调函数,返回当前随机字符-

Slider

滑块验证

new lib.slider(
  { container, title: "sliding unlock", success: "unlock" },
  (res) => {
    console.log("[debug]res:", res);
  }
);
参数说明默认值
containerDOM 节点-
title默认展示文案滑动解锁
success成功文案解锁成功

TextClick

文字点选验证

new lib.TextClick(
  {
    container: document.getElementById("app"),
    width: 400,
    height: 200,
    images: [
      "https://th.bing.com/th/id/OIP.2gS4UgpMqzgMv_WcelDaZwAAAA?pid=ImgDet&rs=1",
      "https://th.bing.com/th/id/OIP.W3ZzYPC0KT8ijxyc-1wpGAAAAA?pid=ImgDet&rs=1",
      "https://th.bing.com/th/id/R.0233d6fa7a283ac2cc9adbbce09b2150?rik=mAI8iultzrL3OQ&pid=ImgRaw&r=0&sres=1&sresct=1",
    ],
    fontStr: "冒菜火锅麻辣烫全部都好吃",
  },
  function (res) {
    console.log("[debug]res:", res);
  }
);
参数说明默认值
containerDOM 节点-
width宽度320
height高度160
fontStr字符串预选池1234567890
fontNum字符数量5
checkNum校验数量3
accuracy精度15
images图片 URL 列表[]

RandomCalc

计算验证

new lib.RandomCalc(
  {
    container: document.getElementById("app"),
    width: 320,
    height: 60,
  },
  function (res) {
    console.log("[debug]res:", res);
  }
);
参数说明默认值
containerDOM 节点-
width宽度320
height高度60
range数值区间100
operator运算符列表"+", "-"

SliderImg

滑动图片验证

new lib.SliderImg(
  {
    container: document.getElementById("app"),
    width: 320,
    height: 160,
    images: [
      "https://th.bing.com/th/id/OIP.2gS4UgpMqzgMv_WcelDaZwAAAA?pid=ImgDet&rs=1",
      "https://th.bing.com/th/id/OIP.W3ZzYPC0KT8ijxyc-1wpGAAAAA?pid=ImgDet&rs=1",
      "https://th.bing.com/th/id/R.0233d6fa7a283ac2cc9adbbce09b2150?rik=mAI8iultzrL3OQ&pid=ImgRaw&r=0&sres=1&sresct=1",
    ],
  },
  function (res) {
    console.log("[debug]res:", res);
  }
);
参数说明默认值
containerDOM 节点-
width宽度320
height高度160
cuttingWH裁剪图片的宽高40
accuracy精度5
images图片 URL 列表[]
1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago