* chore: update deps * feat: use jsonc/x language * chore: update eslint 10.0 * fix: no-useless-assignment * feat: add CLAUDE.md * chore: ignore * feat: claude * fix: lint * chore: suppot eslint v10 * fix: lint * fix: lint * fix: type check * fix: unit test * fix: Suggested fix * fix: unit test * chore: update stylelint v17 * chore: update all major deps * fix: echarts console warn * chore: update vitest v4 * feat: add skills ignores * chore: update deps * chore: update deps * fix: cspell * chore: update deps * chore: update tailwindcss v4 * chore: remove postcss config * fix: no use catalog * chore: tailwind v4 config * fix: tailwindcss v4 sort * feat: use eslint-plugin-better-tailwindcss * fix: Interference between enforce-consistent-line-wrapping, jsx-curly-brace-presence and Prettier * fix: Interference between enforce-consistent-line-wrapping, jsx-curly-brace-presence and Prettier * fix(lint): resolve prettier and better-tailwindcss formatting conflicts * fix(tailwind): update theme references and lint sources * style(format): normalize apps docs and playground vue files * style(format): normalize core ui-kit components * style(format): normalize effects ui and layout components
118 lines
3.4 KiB
Vue
118 lines
3.4 KiB
Vue
<script lang="ts" setup>
|
|
import type {
|
|
CaptchaVerifyPassingData,
|
|
SliderCaptchaActionType,
|
|
} from '@vben/common-ui';
|
|
|
|
import { ref } from 'vue';
|
|
|
|
import { Page, SliderCaptcha } from '@vben/common-ui';
|
|
import { Bell, Sun } from '@vben/icons';
|
|
|
|
import { Button, Card, message } from 'ant-design-vue';
|
|
|
|
function handleSuccess(data: CaptchaVerifyPassingData) {
|
|
const { time } = data;
|
|
message.success(`校验成功,耗时${time}秒`);
|
|
}
|
|
function handleBtnClick(elRef?: SliderCaptchaActionType) {
|
|
if (!elRef) {
|
|
return;
|
|
}
|
|
elRef.resume();
|
|
}
|
|
|
|
const el1 = ref<SliderCaptchaActionType>();
|
|
const el2 = ref<SliderCaptchaActionType>();
|
|
const el3 = ref<SliderCaptchaActionType>();
|
|
const el4 = ref<SliderCaptchaActionType>();
|
|
const el5 = ref<SliderCaptchaActionType>();
|
|
const el6 = ref<SliderCaptchaActionType>();
|
|
</script>
|
|
|
|
<template>
|
|
<Page description="用于前端简单的拖动校验场景" title="滑块校验">
|
|
<Card class="mb-5" title="基础示例">
|
|
<div class="flex-center p-4 px-[30%]">
|
|
<SliderCaptcha ref="el1" @success="handleSuccess" />
|
|
<Button class="ml-2" type="primary" @click="handleBtnClick(el1)">
|
|
还原
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
<Card class="mb-5" title="自定义圆角">
|
|
<div class="flex-center p-4 px-[30%]">
|
|
<SliderCaptcha
|
|
ref="el2"
|
|
class="rounded-full"
|
|
@success="handleSuccess"
|
|
/>
|
|
<Button class="ml-2" type="primary" @click="handleBtnClick(el2)">
|
|
还原
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
<Card class="mb-5" title="自定义背景色">
|
|
<div class="flex-center p-4 px-[30%]">
|
|
<SliderCaptcha
|
|
ref="el3"
|
|
:bar-style="{
|
|
backgroundColor: '#018ffb',
|
|
}"
|
|
success-text="校验成功"
|
|
text="拖动以进行校验"
|
|
@success="handleSuccess"
|
|
/>
|
|
<Button class="ml-2" type="primary" @click="handleBtnClick(el3)">
|
|
还原
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
<Card class="mb-5" title="自定义拖拽图标">
|
|
<div class="flex-center p-4 px-[30%]">
|
|
<SliderCaptcha ref="el4" @success="handleSuccess">
|
|
<template #actionIcon="{ isPassing }">
|
|
<Bell v-if="isPassing" />
|
|
<Sun v-else />
|
|
</template>
|
|
</SliderCaptcha>
|
|
<Button class="ml-2" type="primary" @click="handleBtnClick(el4)">
|
|
还原
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
<Card class="mb-5" title="自定义文本">
|
|
<div class="flex-center p-4 px-[30%]">
|
|
<SliderCaptcha
|
|
ref="el5"
|
|
success-text="成功"
|
|
text="拖动"
|
|
@success="handleSuccess"
|
|
/>
|
|
<Button class="ml-2" type="primary" @click="handleBtnClick(el5)">
|
|
还原
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
<Card class="mb-5" title="自定义内容(slot)">
|
|
<div class="flex-center p-4 px-[30%]">
|
|
<SliderCaptcha ref="el6" @success="handleSuccess">
|
|
<template #text="{ isPassing }">
|
|
<template v-if="isPassing">
|
|
<Bell class="mr-2 size-4" />
|
|
成功
|
|
</template>
|
|
<template v-else>
|
|
拖动
|
|
<Sun class="ml-2 size-4" />
|
|
</template>
|
|
</template>
|
|
</SliderCaptcha>
|
|
<Button class="ml-2" type="primary" @click="handleBtnClick(el6)">
|
|
还原
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
</Page>
|
|
</template>
|