makeit-captcha
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

Makeit Captcha

基于 Vue3.x + Vite4.x 开发,动态生成验证滑块的验证码组件

npm package npm_downloads MIT webpack vue vite axios ant design vue

关于

Makeit Captcha 2.x 滑块验证码组件,基于 Vue3.x + Vite4.x + Canvas 开发,动态生成验证滑块,结合后端进行二次校验,能有效避免被恶意抓取后的模拟验证,进一步提升验证码的可靠性。

✅ 自定义主题配色 🌲

✅ 自定义初始化验证码 💖

✅ 自定义远程校验结果 💥

✅ 动态配置验证码弹窗背景图 🌺

安装

npm i makeit-captcha

使用

import { createApp } from 'vue'
import MakeitCaptcha from 'makeit-captcha'
import 'makeit-captcha/dist/captcha.min.css'
import App from './app.vue'

const app = createApp(App)
app.use(MakeitCaptcha)
app.mount('#app')

示例

<!-- 自定义初始化 / 校验等 -->
<template>
    <div class="mi-captchas">

        <!-- 基础效果 -->
        <mi-captcha ref="captcha" />

        <!-- 手动触发重置 -->
        <a @click="reset">重置</a>

        <!-- 自定义主题色 -->
        <mi-captcha theme-color="#2F9688"
            border-color="#2F9688"
            box-shadow-color="#2F9688" />
        
        <!-- 自定义初始化 / 校验等 -->
        <mi-captcha theme-color="#be6be0"
            init-action="v1/captcha/init"
            @init="initAfter"
            verify-action="v1/captcha/verification"
            :verify-params="params.verify" />
    </div>
</template>

<script setup>
    import { ref, reactive } from 'vue'

    const captcha = ref(null)

    const params = reactive({
        verify: { key: null }
    })
    
    const initAfter = (res) => {
        if (res?.ret?.code === 200) {
            localStorage.setItem('mi-captcha-key', res?.data?.key)
            params.verify.key = res?.data?.key
        }
    }

    const reset = () => {
        console.log('reinitialize')
        captcha.value?.reset(false)
    }
</script>

更多

更多定制化内容及使用请查看在线示例:https://admin.makeit.vip/components/captcha

Package Sidebar

Install

npm i makeit-captcha

Weekly Downloads

39

Version

2.0.7

License

MIT

Unpacked Size

2 MB

Total Files

95

Last publish

Collaborators

  • makeit.vip