生成字母数字的验证码
Installation
yarn add --dev @dfeidao/fd-an000080
配置
使用本原子操作需要在feidao.json中routers下加入
{
"URL": "/`@pathname`",
"METHOD": "get",
"SERVICE": "dataservice.nodejs",
"DATA": {
"modelid": "`@path`"
}
}
@pathname为url访问地址,@path为服务路径
Example
<div id="box"></div>
// 服务中
import an80 from '@dfeidao/fd-an000080';
interface Message {
cookie: {
uk: string
}
}
const options = { width: 100, height: 40, fontSize: 30, color: true, inverse: false, size: 24, charPreset: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', noise: 1, background: '#fff' };
return an80(msg.cookie, options);
在组件中直接给验证码结点赋值.
// 客户端中
import aw2 from '@dfeidao/fd-aw000002';
const raw2 = await aw2(`@pathname`, {});
const box = fd.data.node.querySelector<HTMLDivElement>('[id="box"]');
box.innerHTML = raw2;