Skip to content

pansyjs/smart-captcha

Repository files navigation

@pansy/smart-captcha

阿里巴巴集团提供的一种智能验证码解决方案。

coverage CI deploy CI NPM version NPM downloads codecov license issues Percentage of issues still open Average time to resolve an issue dumi

📝 阿里文档

文档

🏗 安装

# npm install
npm install @pansy/smart-captcha --save

# yarn install
yarn add @pansy/smart-captcha

# pnpm install
pnpm i @pansy/smart-captcha

🔨 使用

import { SmartCaptcha } from '@pansy/smart-captcha';

export default () => {
  <SmartCaptcha />
}

注意:

qiankun 项目中 使用时由于沙盒的原因导致组件加载不出来,可通过 excludeAssetFilter 配置排除 //g.alicdn.com/AWSC/AWSC/awsc.js;

如果使用 umi 只需要在基座项目里中的 src/app.ts 文件里添加如下代码即可

const cdnUrls =  [
  '//g.alicdn.com/AWSC/AWSC/awsc.js',
];

function isQuankuExclude(value: string) {
  let result = false;

  for (let i = 0; i < cdnUrls.length; i++) {
    if (value.includes(cdnUrls[i])) {
      result = true;
      break;
    }
  }

  return result;
}

export const qiankun = Promise.resolve().then(() => ({
  excludeAssetFilter: (assetUrl: string) => {
    return isQuankuExclude(assetUrl);
  }
}));