Makeit Captcha
关于
Makeit Captcha 2.x 滑块验证码组件,基于 Vue3.x + Vite2.x + Canvas 开发,动态生成验证滑块,结合后端进行二次校验,能有效避免被恶意抓取后的模拟验证,进一步提升验证码的可靠性。
安装
npm i ilab-makeit-captcha
使用
import { createApp } from 'vue'
import MakeitCaptcha from 'ilab-makeit-captcha'
import 'ilab-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