feat: captcha example (#4330)

* feat: captcha example

* fix: fix lint errors

* chore: event handling and methods

* chore: add accessibility features ARIA labels and roles

---------

Co-authored-by: vince <vince292007@gmail.com>
This commit is contained in:
Squall2017
2024-09-07 20:33:33 +08:00
committed by GitHub
parent ad89ea7a75
commit b1636405fc
10 changed files with 314 additions and 0 deletions

View File

@@ -71,6 +71,9 @@
},
"ellipsis": {
"title": "EllipsisText"
},
"captcha": {
"title": "Captcha"
}
}
}

View File

@@ -71,6 +71,9 @@
},
"ellipsis": {
"title": "文本省略"
},
"captcha": {
"title": "验证码"
}
}
}

View File

@@ -39,6 +39,14 @@ const routes: RouteRecordRaw[] = [
title: $t('page.examples.ellipsis.title'),
},
},
{
name: 'CaptchaExample',
path: '/examples/captcha',
component: () => import('#/views/examples/captcha/index.vue'),
meta: {
title: $t('page.examples.captcha.title'),
},
},
],
},
];

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,43 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { Page, type Point, PointSelectionCaptcha } from '@vben/common-ui';
import { Card } from 'ant-design-vue';
import { captchaImage, hintImage } from './base64';
const selectedPoints = ref<Point[]>([]);
const handleConfirm = (points: Point[], clear: () => void) => {
selectedPoints.value = points;
clear();
};
const handleRefresh = () => {
selectedPoints.value = [];
};
</script>
<template>
<Page
description="通过点击图片中的特定位置来验证用户身份。"
title="验证码组件示例"
>
<Card class="mb-4" title="基本使用">
<PointSelectionCaptcha
:captcha-image="captchaImage"
:hint-image="hintImage"
class="float-left"
@confirm="handleConfirm"
@refresh="handleRefresh"
/>
<div class="float-left p-5">
<div v-for="point in selectedPoints" :key="point.i" class="flex">
<span class="mr-3 w-16">索引{{ point.i }}</span>
<span class="mr-3 w-44">时间戳{{ point.t }}</span>
<span class="mr-3 w-16">x{{ point.x }}</span>
<span class="mr-3 w-16">y{{ point.y }}</span>
</div>
</div>
</Card>
</Page>
</template>