From 38fe6426a296b7b7ff396022aba1a5687f76b992 Mon Sep 17 00:00:00 2001 From: Squall2017 <252766926@qq.com> Date: Sat, 14 Sep 2024 21:21:16 +0800 Subject: [PATCH] fix: Improve the problem of inaccurate captcha accuracy (#4401) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: captcha example * fix: fix lint errors * chore: event handling and methods * chore: add accessibility features ARIA labels and roles * refactor: refactor code structure and improve captcha demo page * feat: add captcha internationalization * chore: 适配时间戳国际化展示 * fix: 1. 添加点击位置边界校验,防止点击外部导致x,y误差。2. 演示页面宽度过长添加滚动条。3. 添加hooks --------- --- .../captcha/hooks/useCaptchaPoints.ts | 18 ++++++ .../captcha/point-selection-captcha.vue | 60 ++++++++----------- .../src/views/examples/captcha/index.vue | 5 +- 3 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 packages/effects/common-ui/src/components/captcha/hooks/useCaptchaPoints.ts diff --git a/packages/effects/common-ui/src/components/captcha/hooks/useCaptchaPoints.ts b/packages/effects/common-ui/src/components/captcha/hooks/useCaptchaPoints.ts new file mode 100644 index 00000000000..6032d41a3af --- /dev/null +++ b/packages/effects/common-ui/src/components/captcha/hooks/useCaptchaPoints.ts @@ -0,0 +1,18 @@ +import type { CaptchaPoint } from '../types'; + +import { reactive } from 'vue'; + +export function useCaptchaPoints() { + const points = reactive([]); + function addPoint(point: CaptchaPoint) { + points.push(point); + } + function clearPoints() { + points.splice(0, points.length); + } + return { + addPoint, + clearPoints, + points, + }; +} diff --git a/packages/effects/common-ui/src/components/captcha/point-selection-captcha.vue b/packages/effects/common-ui/src/components/captcha/point-selection-captcha.vue index 3b1ac90729a..249cc110f9d 100644 --- a/packages/effects/common-ui/src/components/captcha/point-selection-captcha.vue +++ b/packages/effects/common-ui/src/components/captcha/point-selection-captcha.vue @@ -1,13 +1,12 @@