@kevairy/template 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +14 -0
- package/package.json +37 -0
- package/template/.env +22 -0
- package/template/.env.development +13 -0
- package/template/.env.production +10 -0
- package/template/.prettierignore +3 -0
- package/template/.prettierrc +20 -0
- package/template/.stylelintignore +9 -0
- package/template/.stylelintrc.cjs +84 -0
- package/template/LICENSE +21 -0
- package/template/README.md +22 -0
- package/template/_gitignore +19 -0
- package/template/eslint-auto-import.json +324 -0
- package/template/eslint.config.mjs +83 -0
- package/template/index.html +25 -0
- package/template/package.json +79 -0
- package/template/playwright.config.ts +25 -0
- package/template/public/favicon.ico +0 -0
- package/template/src/App.vue +39 -0
- package/template/src/adapters/auth/index.ts +9 -0
- package/template/src/adapters/auth/mock.ts +10 -0
- package/template/src/adapters/auth/types.ts +11 -0
- package/template/src/adapters/navigation/index.ts +13 -0
- package/template/src/adapters/navigation/types.ts +6 -0
- package/template/src/api/auth.ts +23 -0
- package/template/src/assets/images/avatar/avatar.webp +0 -0
- package/template/src/assets/images/avatar/avatar1.webp +0 -0
- package/template/src/assets/images/avatar/avatar10.webp +0 -0
- package/template/src/assets/images/avatar/avatar2.webp +0 -0
- package/template/src/assets/images/avatar/avatar3.webp +0 -0
- package/template/src/assets/images/avatar/avatar4.webp +0 -0
- package/template/src/assets/images/avatar/avatar5.webp +0 -0
- package/template/src/assets/images/avatar/avatar6.webp +0 -0
- package/template/src/assets/images/avatar/avatar7.webp +0 -0
- package/template/src/assets/images/avatar/avatar8.webp +0 -0
- package/template/src/assets/images/avatar/avatar9.webp +0 -0
- package/template/src/assets/images/ceremony/hb.png +0 -0
- package/template/src/assets/images/ceremony/sd.png +0 -0
- package/template/src/assets/images/ceremony/xc.png +0 -0
- package/template/src/assets/images/ceremony/yd.png +0 -0
- package/template/src/assets/images/common/logo.webp +0 -0
- package/template/src/assets/images/draw/draw1.png +0 -0
- package/template/src/assets/images/favicon.ico +0 -0
- package/template/src/assets/images/lock/bg_dark.webp +0 -0
- package/template/src/assets/images/lock/bg_light.webp +0 -0
- package/template/src/assets/images/login/kylin-hero-source.png +0 -0
- package/template/src/assets/images/login/lf_icon2.webp +0 -0
- package/template/src/assets/images/settings/menu_layouts/dual_column.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/horizontal.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/mixed.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/vertical.png +0 -0
- package/template/src/assets/images/settings/menu_styles/dark.png +0 -0
- package/template/src/assets/images/settings/menu_styles/design.png +0 -0
- package/template/src/assets/images/settings/menu_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/dark.png +0 -0
- package/template/src/assets/images/settings/theme_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/system.png +0 -0
- package/template/src/assets/images/svg/403.svg +1 -0
- package/template/src/assets/images/svg/404.svg +1 -0
- package/template/src/assets/images/svg/500.svg +5 -0
- package/template/src/assets/images/svg/login_icon.svg +1 -0
- package/template/src/assets/images/user/avatar.webp +0 -0
- package/template/src/assets/images/user/bg.webp +0 -0
- package/template/src/assets/styles/core/app.scss +227 -0
- package/template/src/assets/styles/core/dark.scss +93 -0
- package/template/src/assets/styles/core/el-dark.scss +2 -0
- package/template/src/assets/styles/core/el-light.scss +34 -0
- package/template/src/assets/styles/core/el-ui.scss +519 -0
- package/template/src/assets/styles/core/md.scss +1036 -0
- package/template/src/assets/styles/core/mixin.scss +157 -0
- package/template/src/assets/styles/core/reset.scss +41 -0
- package/template/src/assets/styles/core/router-transition.scss +104 -0
- package/template/src/assets/styles/core/tailwind.css +219 -0
- package/template/src/assets/styles/core/theme-animation.scss +63 -0
- package/template/src/assets/styles/core/theme-change.scss +11 -0
- package/template/src/assets/styles/custom/one-dark-pro.scss +98 -0
- package/template/src/assets/styles/index.scss +23 -0
- package/template/src/assets/svg/loading.ts +32 -0
- package/template/src/bootstrap/initializeApp.ts +30 -0
- package/template/src/components/core/banners/art-basic-banner/index.vue +343 -0
- package/template/src/components/core/banners/art-card-banner/index.vue +114 -0
- package/template/src/components/core/base/art-back-to-top/index.vue +40 -0
- package/template/src/components/core/base/art-logo/index.vue +34 -0
- package/template/src/components/core/base/art-svg-icon/index.vue +24 -0
- package/template/src/components/core/cards/art-bar-chart-card/index.vue +103 -0
- package/template/src/components/core/cards/art-data-list-card/index.vue +74 -0
- package/template/src/components/core/cards/art-donut-chart-card/index.vue +124 -0
- package/template/src/components/core/cards/art-image-card/index.vue +89 -0
- package/template/src/components/core/cards/art-line-chart-card/index.vue +126 -0
- package/template/src/components/core/cards/art-progress-card/index.vue +86 -0
- package/template/src/components/core/cards/art-stats-card/index.vue +67 -0
- package/template/src/components/core/cards/art-timeline-list-card/index.vue +69 -0
- package/template/src/components/core/charts/art-bar-chart/index.vue +203 -0
- package/template/src/components/core/charts/art-dual-bar-compare-chart/index.vue +195 -0
- package/template/src/components/core/charts/art-h-bar-chart/index.vue +208 -0
- package/template/src/components/core/charts/art-k-line-chart/index.vue +152 -0
- package/template/src/components/core/charts/art-line-chart/index.vue +371 -0
- package/template/src/components/core/charts/art-radar-chart/index.vue +105 -0
- package/template/src/components/core/charts/art-ring-chart/index.vue +133 -0
- package/template/src/components/core/charts/art-scatter-chart/index.vue +115 -0
- package/template/src/components/core/feedback/art-page-loading/index.vue +281 -0
- package/template/src/components/core/forms/art-button-more/index.vue +71 -0
- package/template/src/components/core/forms/art-button-table/index.vue +59 -0
- package/template/src/components/core/forms/art-drag-verify/index.vue +430 -0
- package/template/src/components/core/forms/art-excel-export/index.vue +390 -0
- package/template/src/components/core/forms/art-excel-import/index.vue +62 -0
- package/template/src/components/core/forms/art-form/index.vue +507 -0
- package/template/src/components/core/forms/art-wang-editor/index.vue +261 -0
- package/template/src/components/core/forms/art-wang-editor/style.scss +273 -0
- package/template/src/components/core/layouts/art-breadcrumb/index.vue +142 -0
- package/template/src/components/core/layouts/art-chat-window/index.vue +262 -0
- package/template/src/components/core/layouts/art-fast-enter/index.vue +113 -0
- package/template/src/components/core/layouts/art-fireworks-effect/index.vue +633 -0
- package/template/src/components/core/layouts/art-global-component/index.vue +14 -0
- package/template/src/components/core/layouts/art-global-search/index.vue +431 -0
- package/template/src/components/core/layouts/art-header-bar/index.vue +485 -0
- package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +118 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/index.vue +110 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/widget/HorizontalSubmenu.vue +106 -0
- package/template/src/components/core/layouts/art-menus/art-mixed-menu/index.vue +279 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/index.vue +354 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/style.scss +251 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/theme.scss +258 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/widget/SidebarSubmenu.vue +190 -0
- package/template/src/components/core/layouts/art-notification/index.vue +456 -0
- package/template/src/components/core/layouts/art-page-content/index.vue +137 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts +248 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsHandlers.ts +167 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts +233 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsState.ts +37 -0
- package/template/src/components/core/layouts/art-settings-panel/index.vue +72 -0
- package/template/src/components/core/layouts/art-settings-panel/style.scss +92 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BasicSettings.vue +77 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BoxStyleSettings.vue +38 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ColorSettings.vue +35 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ContainerSettings.vue +33 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuLayoutSettings.vue +31 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuStyleSettings.vue +44 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SectionTitle.vue +17 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +236 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingDrawer.vue +51 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingHeader.vue +18 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingItem.vue +101 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ThemeSettings.vue +28 -0
- package/template/src/components/core/layouts/art-work-tab/index.vue +584 -0
- package/template/src/components/core/media/art-cutter-img/index.vue +350 -0
- package/template/src/components/core/media/art-video-player/index.vue +111 -0
- package/template/src/components/core/others/art-menu-right/index.vue +415 -0
- package/template/src/components/core/others/art-watermark/index.vue +64 -0
- package/template/src/components/core/text-effect/art-count-to/index.vue +310 -0
- package/template/src/components/core/text-effect/art-festival-text-scroll/index.vue +32 -0
- package/template/src/components/core/text-effect/art-text-scroll/index.vue +285 -0
- package/template/src/components/core/theme/theme-svg/index.vue +100 -0
- package/template/src/components/core/views/exception/ArtException.vue +55 -0
- package/template/src/components/core/views/login/AuthTopBar.vue +149 -0
- package/template/src/components/core/views/login/LoginLeftView.vue +602 -0
- package/template/src/components/core/views/result/ArtResultPage.vue +43 -0
- package/template/src/components/core/widget/art-icon-button/index.vue +23 -0
- package/template/src/config/assets/images.ts +61 -0
- package/template/src/config/index.ts +170 -0
- package/template/src/config/modules/component.ts +98 -0
- package/template/src/config/modules/fastEnter.ts +16 -0
- package/template/src/config/modules/festival.ts +51 -0
- package/template/src/config/modules/headerBar.ts +64 -0
- package/template/src/config/setting.ts +109 -0
- package/template/src/directives/core/auth.ts +66 -0
- package/template/src/directives/core/highlight-loader.ts +37 -0
- package/template/src/directives/core/highlight.ts +253 -0
- package/template/src/directives/core/ripple.ts +116 -0
- package/template/src/directives/core/roles.ts +87 -0
- package/template/src/directives/index.ts +14 -0
- package/template/src/enums/appEnum.ts +81 -0
- package/template/src/enums/formEnum.ts +17 -0
- package/template/src/env.d.ts +32 -0
- package/template/src/hooks/core/useAppMode.ts +45 -0
- package/template/src/hooks/core/useAuth.ts +74 -0
- package/template/src/hooks/core/useCeremony.ts +184 -0
- package/template/src/hooks/core/useChart.ts +745 -0
- package/template/src/hooks/core/useCommon.ts +87 -0
- package/template/src/hooks/core/useFastEnter.ts +55 -0
- package/template/src/hooks/core/useHeaderBar.ts +201 -0
- package/template/src/hooks/core/useLayoutHeight.ts +148 -0
- package/template/src/hooks/core/useTableColumns.ts +313 -0
- package/template/src/hooks/core/useTheme.ts +174 -0
- package/template/src/hooks/index.ts +29 -0
- package/template/src/locales/index.ts +123 -0
- package/template/src/locales/langs/en.json +283 -0
- package/template/src/locales/langs/zh.json +283 -0
- package/template/src/main.ts +29 -0
- package/template/src/mock/auth.ts +46 -0
- package/template/src/plugins/echarts.ts +76 -0
- package/template/src/plugins/index.ts +6 -0
- package/template/src/router/core/ComponentLoader.ts +82 -0
- package/template/src/router/core/IframeRouteManager.ts +78 -0
- package/template/src/router/core/MenuProcessor.ts +280 -0
- package/template/src/router/core/RoutePermissionValidator.ts +161 -0
- package/template/src/router/core/RouteRegistry.ts +90 -0
- package/template/src/router/core/RouteTransformer.ts +132 -0
- package/template/src/router/core/RouteValidator.ts +187 -0
- package/template/src/router/core/index.ts +14 -0
- package/template/src/router/guards/afterEach.ts +34 -0
- package/template/src/router/guards/beforeEach.ts +442 -0
- package/template/src/router/index.ts +24 -0
- package/template/src/router/modules/dashboard.ts +23 -0
- package/template/src/router/modules/examples.ts +109 -0
- package/template/src/router/modules/exception.ts +46 -0
- package/template/src/router/modules/index.ts +12 -0
- package/template/src/router/modules/result.ts +32 -0
- package/template/src/router/routes/asyncRoutes.ts +9 -0
- package/template/src/router/routes/staticRoutes.ts +60 -0
- package/template/src/router/routesAlias.ts +8 -0
- package/template/src/services/auth.ts +15 -0
- package/template/src/store/index.ts +52 -0
- package/template/src/store/modules/menu.ts +109 -0
- package/template/src/store/modules/setting.ts +450 -0
- package/template/src/store/modules/user.ts +218 -0
- package/template/src/store/modules/worktab.ts +568 -0
- package/template/src/types/api/api.d.ts +86 -0
- package/template/src/types/common/index.ts +95 -0
- package/template/src/types/common/response.ts +32 -0
- package/template/src/types/component/chart.ts +324 -0
- package/template/src/types/component/index.ts +86 -0
- package/template/src/types/config/index.ts +253 -0
- package/template/src/types/directive/directive.d.ts +15 -0
- package/template/src/types/import/auto-imports.d.ts +319 -0
- package/template/src/types/import/components.d.ts +126 -0
- package/template/src/types/index.ts +22 -0
- package/template/src/types/router/index.ts +80 -0
- package/template/src/types/store/index.ts +157 -0
- package/template/src/utils/form/index.ts +9 -0
- package/template/src/utils/form/validator.ts +316 -0
- package/template/src/utils/http/contract.ts +39 -0
- package/template/src/utils/http/error.ts +182 -0
- package/template/src/utils/http/index.ts +226 -0
- package/template/src/utils/http/status.ts +18 -0
- package/template/src/utils/index.ts +31 -0
- package/template/src/utils/navigation/index.ts +10 -0
- package/template/src/utils/navigation/jump.ts +68 -0
- package/template/src/utils/navigation/route.ts +85 -0
- package/template/src/utils/navigation/worktab.ts +67 -0
- package/template/src/utils/router.ts +63 -0
- package/template/src/utils/socket/index.ts +423 -0
- package/template/src/utils/storage/index.ts +7 -0
- package/template/src/utils/storage/storage-config.ts +127 -0
- package/template/src/utils/storage/storage-key-manager.ts +97 -0
- package/template/src/utils/storage/storage.ts +250 -0
- package/template/src/utils/sys/console.ts +9 -0
- package/template/src/utils/sys/error-handle.ts +143 -0
- package/template/src/utils/sys/index.ts +2 -0
- package/template/src/utils/sys/mittBus.ts +61 -0
- package/template/src/utils/ui/animation.ts +80 -0
- package/template/src/utils/ui/colors.ts +273 -0
- package/template/src/utils/ui/emojo.ts +24 -0
- package/template/src/utils/ui/iconify-loader.ts +31 -0
- package/template/src/utils/ui/index.ts +11 -0
- package/template/src/utils/ui/loading.ts +158 -0
- package/template/src/utils/ui/tabs.ts +60 -0
- package/template/src/views/auth/forget-password/index.vue +62 -0
- package/template/src/views/auth/login/index.vue +166 -0
- package/template/src/views/auth/login/style.css +38 -0
- package/template/src/views/auth/register/index.vue +240 -0
- package/template/src/views/dashboard/console/index.vue +173 -0
- package/template/src/views/examples/analytics/index.vue +389 -0
- package/template/src/views/examples/complex-form/index.vue +395 -0
- package/template/src/views/examples/crud-workspace/index.vue +412 -0
- package/template/src/views/examples/navigation/detail/index.vue +151 -0
- package/template/src/views/examples/navigation/state/index.vue +226 -0
- package/template/src/views/examples/overview/index.vue +309 -0
- package/template/src/views/examples/permissions/index.vue +303 -0
- package/template/src/views/examples/search-table/index.vue +182 -0
- package/template/src/views/examples/search-table/search.config.ts +81 -0
- package/template/src/views/examples/search-table/service.ts +116 -0
- package/template/src/views/examples/search-table/table.config.ts +37 -0
- package/template/src/views/exception/403/index.vue +16 -0
- package/template/src/views/exception/404/index.vue +16 -0
- package/template/src/views/exception/500/index.vue +16 -0
- package/template/src/views/index/index.vue +29 -0
- package/template/src/views/index/style.scss +93 -0
- package/template/src/views/outside/Iframe.vue +42 -0
- package/template/src/views/result/fail/index.vue +28 -0
- package/template/src/views/result/success/index.vue +21 -0
- package/template/tests/e2e/auth.spec.ts +14 -0
- package/template/tests/e2e/search-table.spec.ts +154 -0
- package/template/tests/unit/adapters/auth.spec.ts +38 -0
- package/template/tests/unit/config/app-config.spec.ts +17 -0
- package/template/tests/unit/directives/highlight.spec.ts +20 -0
- package/template/tests/unit/http/contract.spec.ts +47 -0
- package/template/tests/unit/mock/search-table.spec.ts +62 -0
- package/template/tests/unit/router/examples.spec.ts +52 -0
- package/template/tsconfig.json +28 -0
- package/template/vite.config.ts +181 -0
- package/template/vitest.config.ts +27 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
<!-- 拖拽验证组件 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div
|
|
4
|
+
ref="dragVerify"
|
|
5
|
+
class="drag_verify"
|
|
6
|
+
:style="dragVerifyStyle"
|
|
7
|
+
@mousemove="dragMoving"
|
|
8
|
+
@mouseup="dragFinish"
|
|
9
|
+
@mouseleave="dragFinish"
|
|
10
|
+
@touchmove="dragMoving"
|
|
11
|
+
@touchend="dragFinish"
|
|
12
|
+
>
|
|
13
|
+
<!-- 进度条 -->
|
|
14
|
+
<div
|
|
15
|
+
class="dv_progress_bar"
|
|
16
|
+
:class="{ goFirst2: isOk }"
|
|
17
|
+
ref="progressBar"
|
|
18
|
+
:style="progressBarStyle"
|
|
19
|
+
>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<!-- 提示文本 -->
|
|
23
|
+
<div class="dv_text" :style="textStyle" ref="messageRef">
|
|
24
|
+
<slot name="textBefore" v-if="$slots.textBefore"></slot>
|
|
25
|
+
{{ message }}
|
|
26
|
+
<slot name="textAfter" v-if="$slots.textAfter"></slot>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- 滑块处理器 -->
|
|
30
|
+
<div
|
|
31
|
+
class="dv_handler dv_handler_bg"
|
|
32
|
+
:class="{ goFirst: isOk }"
|
|
33
|
+
@mousedown="dragStart"
|
|
34
|
+
@touchstart="dragStart"
|
|
35
|
+
ref="handler"
|
|
36
|
+
:style="handlerStyle"
|
|
37
|
+
>
|
|
38
|
+
<ArtSvgIcon :icon="value ? successIcon : handlerIcon" class="text-g-600"></ArtSvgIcon>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
defineOptions({ name: 'ArtDragVerify' })
|
|
45
|
+
|
|
46
|
+
// 事件定义
|
|
47
|
+
const emit = defineEmits(['handlerMove', 'update:value', 'passCallback'])
|
|
48
|
+
|
|
49
|
+
// 组件属性接口定义
|
|
50
|
+
interface PropsType {
|
|
51
|
+
/** 是否通过验证 */
|
|
52
|
+
value: boolean
|
|
53
|
+
/** 组件宽度 */
|
|
54
|
+
width?: number | string
|
|
55
|
+
/** 组件高度 */
|
|
56
|
+
height?: number
|
|
57
|
+
/** 默认提示文本 */
|
|
58
|
+
text?: string
|
|
59
|
+
/** 成功提示文本 */
|
|
60
|
+
successText?: string
|
|
61
|
+
/** 背景色 */
|
|
62
|
+
background?: string
|
|
63
|
+
/** 进度条背景色 */
|
|
64
|
+
progressBarBg?: string
|
|
65
|
+
/** 完成状态背景色 */
|
|
66
|
+
completedBg?: string
|
|
67
|
+
/** 是否圆角 */
|
|
68
|
+
circle?: boolean
|
|
69
|
+
/** 圆角大小 */
|
|
70
|
+
radius?: string
|
|
71
|
+
/** 滑块图标 */
|
|
72
|
+
handlerIcon?: string
|
|
73
|
+
/** 成功图标 */
|
|
74
|
+
successIcon?: string
|
|
75
|
+
/** 滑块背景色 */
|
|
76
|
+
handlerBg?: string
|
|
77
|
+
/** 文本大小 */
|
|
78
|
+
textSize?: string
|
|
79
|
+
/** 文本颜色 */
|
|
80
|
+
textColor?: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 属性默认值设置
|
|
84
|
+
const props = withDefaults(defineProps<PropsType>(), {
|
|
85
|
+
value: false,
|
|
86
|
+
width: '100%',
|
|
87
|
+
height: 40,
|
|
88
|
+
text: '按住滑块拖动',
|
|
89
|
+
successText: 'success',
|
|
90
|
+
background: '#eee',
|
|
91
|
+
progressBarBg: '#1385FF',
|
|
92
|
+
completedBg: '#57D187',
|
|
93
|
+
circle: false,
|
|
94
|
+
radius: 'calc(var(--custom-radius) / 3 + 2px)',
|
|
95
|
+
handlerIcon: 'solar:double-alt-arrow-right-linear',
|
|
96
|
+
successIcon: 'ri:check-fill',
|
|
97
|
+
handlerBg: '#fff',
|
|
98
|
+
textSize: '13px',
|
|
99
|
+
textColor: '#333'
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// 组件状态接口定义
|
|
103
|
+
interface StateType {
|
|
104
|
+
isMoving: boolean // 是否正在拖拽
|
|
105
|
+
x: number // 拖拽起始位置
|
|
106
|
+
isOk: boolean // 是否验证成功
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 响应式状态定义
|
|
110
|
+
const state = reactive(<StateType>{
|
|
111
|
+
isMoving: false,
|
|
112
|
+
x: 0,
|
|
113
|
+
isOk: false
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// 解构响应式状态
|
|
117
|
+
const { isOk } = toRefs(state)
|
|
118
|
+
|
|
119
|
+
// DOM 元素引用
|
|
120
|
+
const dragVerify = ref()
|
|
121
|
+
const messageRef = ref()
|
|
122
|
+
const handler = ref()
|
|
123
|
+
const progressBar = ref()
|
|
124
|
+
|
|
125
|
+
// 触摸事件变量 - 用于禁止页面滑动
|
|
126
|
+
let startX: number, startY: number, moveX: number, moveY: number
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 触摸开始事件处理
|
|
130
|
+
* @param e 触摸事件对象
|
|
131
|
+
*/
|
|
132
|
+
const onTouchStart = (e: any) => {
|
|
133
|
+
startX = e.targetTouches[0].pageX
|
|
134
|
+
startY = e.targetTouches[0].pageY
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 触摸移动事件处理 - 判断是否为横向滑动,如果是则阻止默认行为
|
|
139
|
+
* @param e 触摸事件对象
|
|
140
|
+
*/
|
|
141
|
+
const onTouchMove = (e: any) => {
|
|
142
|
+
moveX = e.targetTouches[0].pageX
|
|
143
|
+
moveY = e.targetTouches[0].pageY
|
|
144
|
+
|
|
145
|
+
// 如果横向移动距离大于纵向移动距离,阻止默认行为(防止页面滑动)
|
|
146
|
+
if (Math.abs(moveX - startX) > Math.abs(moveY - startY)) {
|
|
147
|
+
e.preventDefault()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 全局事件监听器添加
|
|
152
|
+
document.addEventListener('touchstart', onTouchStart)
|
|
153
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false })
|
|
154
|
+
|
|
155
|
+
// 获取数值形式的宽度
|
|
156
|
+
const getNumericWidth = (): number => {
|
|
157
|
+
if (typeof props.width === 'string') {
|
|
158
|
+
// 如果是字符串,尝试从DOM元素获取实际宽度
|
|
159
|
+
return dragVerify.value?.offsetWidth || 260
|
|
160
|
+
}
|
|
161
|
+
return props.width
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 获取样式字符串形式的宽度
|
|
165
|
+
const getStyleWidth = (): string => {
|
|
166
|
+
if (typeof props.width === 'string') {
|
|
167
|
+
return props.width
|
|
168
|
+
}
|
|
169
|
+
return props.width + 'px'
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 组件挂载后的初始化
|
|
173
|
+
onMounted(() => {
|
|
174
|
+
// 设置 CSS 自定义属性
|
|
175
|
+
dragVerify.value?.style.setProperty('--textColor', props.textColor)
|
|
176
|
+
|
|
177
|
+
// 等待DOM更新后设置宽度相关属性
|
|
178
|
+
nextTick(() => {
|
|
179
|
+
const numericWidth = getNumericWidth()
|
|
180
|
+
dragVerify.value?.style.setProperty('--width', Math.floor(numericWidth / 2) + 'px')
|
|
181
|
+
dragVerify.value?.style.setProperty('--pwidth', -Math.floor(numericWidth / 2) + 'px')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
// 重复添加事件监听器(确保事件绑定)
|
|
185
|
+
document.addEventListener('touchstart', onTouchStart)
|
|
186
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false })
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
// 组件卸载前清理事件监听器
|
|
190
|
+
onBeforeUnmount(() => {
|
|
191
|
+
document.removeEventListener('touchstart', onTouchStart)
|
|
192
|
+
document.removeEventListener('touchmove', onTouchMove)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
// 滑块样式计算
|
|
196
|
+
const handlerStyle = {
|
|
197
|
+
left: '0',
|
|
198
|
+
width: props.height + 'px',
|
|
199
|
+
height: props.height + 'px',
|
|
200
|
+
background: props.handlerBg
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// 主容器样式计算
|
|
204
|
+
const dragVerifyStyle = computed(() => ({
|
|
205
|
+
width: getStyleWidth(),
|
|
206
|
+
height: props.height + 'px',
|
|
207
|
+
lineHeight: props.height + 'px',
|
|
208
|
+
background: props.background,
|
|
209
|
+
borderRadius: props.circle ? props.height / 2 + 'px' : props.radius
|
|
210
|
+
}))
|
|
211
|
+
|
|
212
|
+
// 进度条样式计算
|
|
213
|
+
const progressBarStyle = {
|
|
214
|
+
background: props.progressBarBg,
|
|
215
|
+
height: props.height + 'px',
|
|
216
|
+
borderRadius: props.circle
|
|
217
|
+
? props.height / 2 + 'px 0 0 ' + props.height / 2 + 'px'
|
|
218
|
+
: props.radius
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 文本样式计算
|
|
222
|
+
const textStyle = computed(() => ({
|
|
223
|
+
fontSize: props.textSize
|
|
224
|
+
}))
|
|
225
|
+
|
|
226
|
+
// 显示消息计算属性
|
|
227
|
+
const message = computed(() => {
|
|
228
|
+
return props.value ? props.successText : props.text
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 拖拽开始处理函数
|
|
233
|
+
* @param e 鼠标或触摸事件对象
|
|
234
|
+
*/
|
|
235
|
+
const dragStart = (e: any) => {
|
|
236
|
+
if (!props.value) {
|
|
237
|
+
state.isMoving = true
|
|
238
|
+
handler.value.style.transition = 'none'
|
|
239
|
+
// 计算拖拽起始位置
|
|
240
|
+
state.x =
|
|
241
|
+
(e.pageX || e.touches[0].pageX) - parseInt(handler.value.style.left.replace('px', ''), 10)
|
|
242
|
+
}
|
|
243
|
+
emit('handlerMove')
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 拖拽移动处理函数
|
|
248
|
+
* @param e 鼠标或触摸事件对象
|
|
249
|
+
*/
|
|
250
|
+
const dragMoving = (e: any) => {
|
|
251
|
+
if (state.isMoving && !props.value) {
|
|
252
|
+
const numericWidth = getNumericWidth()
|
|
253
|
+
// 计算当前位置
|
|
254
|
+
let _x = (e.pageX || e.touches[0].pageX) - state.x
|
|
255
|
+
|
|
256
|
+
// 在有效范围内移动
|
|
257
|
+
if (_x > 0 && _x <= numericWidth - props.height) {
|
|
258
|
+
handler.value.style.left = _x + 'px'
|
|
259
|
+
progressBar.value.style.width = _x + props.height / 2 + 'px'
|
|
260
|
+
} else if (_x > numericWidth - props.height) {
|
|
261
|
+
// 拖拽到末端,触发验证成功
|
|
262
|
+
handler.value.style.left = numericWidth - props.height + 'px'
|
|
263
|
+
progressBar.value.style.width = numericWidth - props.height / 2 + 'px'
|
|
264
|
+
passVerify()
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 拖拽结束处理函数
|
|
271
|
+
* @param e 鼠标或触摸事件对象
|
|
272
|
+
*/
|
|
273
|
+
const dragFinish = (e: any) => {
|
|
274
|
+
if (state.isMoving && !props.value) {
|
|
275
|
+
const numericWidth = getNumericWidth()
|
|
276
|
+
// 计算最终位置
|
|
277
|
+
let _x = (e.pageX || e.changedTouches[0].pageX) - state.x
|
|
278
|
+
|
|
279
|
+
if (_x < numericWidth - props.height) {
|
|
280
|
+
// 未拖拽到末端,重置位置
|
|
281
|
+
state.isOk = true
|
|
282
|
+
handler.value.style.left = '0'
|
|
283
|
+
handler.value.style.transition = 'all 0.2s'
|
|
284
|
+
progressBar.value.style.width = '0'
|
|
285
|
+
state.isOk = false
|
|
286
|
+
} else {
|
|
287
|
+
// 拖拽到末端,保持验证成功状态
|
|
288
|
+
handler.value.style.transition = 'none'
|
|
289
|
+
handler.value.style.left = numericWidth - props.height + 'px'
|
|
290
|
+
progressBar.value.style.width = numericWidth - props.height / 2 + 'px'
|
|
291
|
+
passVerify()
|
|
292
|
+
}
|
|
293
|
+
state.isMoving = false
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 验证通过处理函数
|
|
299
|
+
*/
|
|
300
|
+
const passVerify = () => {
|
|
301
|
+
emit('update:value', true)
|
|
302
|
+
state.isMoving = false
|
|
303
|
+
// 更新样式为成功状态
|
|
304
|
+
progressBar.value.style.background = props.completedBg
|
|
305
|
+
messageRef.value.style['-webkit-text-fill-color'] = 'unset'
|
|
306
|
+
messageRef.value.style.animation = 'slidetounlock2 2s cubic-bezier(0, 0.2, 1, 1) infinite'
|
|
307
|
+
messageRef.value.style.color = '#fff'
|
|
308
|
+
emit('passCallback')
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* 重置验证状态函数
|
|
313
|
+
*/
|
|
314
|
+
const reset = () => {
|
|
315
|
+
// 重置滑块位置
|
|
316
|
+
handler.value.style.left = '0'
|
|
317
|
+
progressBar.value.style.width = '0'
|
|
318
|
+
progressBar.value.style.background = props.progressBarBg
|
|
319
|
+
// 重置文本样式
|
|
320
|
+
messageRef.value.style['-webkit-text-fill-color'] = 'transparent'
|
|
321
|
+
messageRef.value.style.animation = 'slidetounlock 2s cubic-bezier(0, 0.2, 1, 1) infinite'
|
|
322
|
+
messageRef.value.style.color = props.background
|
|
323
|
+
// 重置状态
|
|
324
|
+
emit('update:value', false)
|
|
325
|
+
state.isOk = false
|
|
326
|
+
state.isMoving = false
|
|
327
|
+
state.x = 0
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// 暴露重置方法给父组件
|
|
331
|
+
defineExpose({
|
|
332
|
+
reset
|
|
333
|
+
})
|
|
334
|
+
</script>
|
|
335
|
+
|
|
336
|
+
<style lang="scss" scoped>
|
|
337
|
+
.drag_verify {
|
|
338
|
+
position: relative;
|
|
339
|
+
box-sizing: border-box;
|
|
340
|
+
overflow: hidden;
|
|
341
|
+
text-align: center;
|
|
342
|
+
border: 1px solid var(--default-border-dashed);
|
|
343
|
+
|
|
344
|
+
.dv_handler {
|
|
345
|
+
position: absolute;
|
|
346
|
+
top: 0;
|
|
347
|
+
left: 0;
|
|
348
|
+
display: flex;
|
|
349
|
+
align-items: center;
|
|
350
|
+
justify-content: center;
|
|
351
|
+
cursor: move;
|
|
352
|
+
|
|
353
|
+
i {
|
|
354
|
+
padding-left: 0;
|
|
355
|
+
font-size: 14px;
|
|
356
|
+
color: #999;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.el-icon-circle-check {
|
|
360
|
+
margin-top: 9px;
|
|
361
|
+
color: #6c6;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.dv_progress_bar {
|
|
366
|
+
position: absolute;
|
|
367
|
+
width: 0;
|
|
368
|
+
height: 34px;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.dv_text {
|
|
372
|
+
position: absolute;
|
|
373
|
+
inset: 0;
|
|
374
|
+
display: flex;
|
|
375
|
+
align-items: center;
|
|
376
|
+
justify-content: center;
|
|
377
|
+
color: transparent;
|
|
378
|
+
user-select: none;
|
|
379
|
+
background: linear-gradient(
|
|
380
|
+
to right,
|
|
381
|
+
var(--textColor) 0%,
|
|
382
|
+
var(--textColor) 40%,
|
|
383
|
+
#fff 50%,
|
|
384
|
+
var(--textColor) 60%,
|
|
385
|
+
var(--textColor) 100%
|
|
386
|
+
);
|
|
387
|
+
-webkit-background-clip: text;
|
|
388
|
+
background-clip: text;
|
|
389
|
+
animation: slidetounlock 2s cubic-bezier(0, 0.2, 1, 1) infinite;
|
|
390
|
+
-webkit-text-fill-color: transparent;
|
|
391
|
+
text-size-adjust: none;
|
|
392
|
+
|
|
393
|
+
* {
|
|
394
|
+
-webkit-text-fill-color: var(--textColor);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.goFirst {
|
|
400
|
+
left: 0 !important;
|
|
401
|
+
transition: left 0.5s;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.goFirst2 {
|
|
405
|
+
width: 0 !important;
|
|
406
|
+
transition: width 0.5s;
|
|
407
|
+
}
|
|
408
|
+
</style>
|
|
409
|
+
|
|
410
|
+
<style lang="scss">
|
|
411
|
+
@keyframes slidetounlock {
|
|
412
|
+
0% {
|
|
413
|
+
background-position: var(--pwidth) 0;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
100% {
|
|
417
|
+
background-position: var(--width) 0;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
@keyframes slidetounlock2 {
|
|
422
|
+
0% {
|
|
423
|
+
background-position: var(--pwidth) 0;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
100% {
|
|
427
|
+
background-position: var(--pwidth) 0;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
</style>
|