@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,415 @@
|
|
|
1
|
+
<!-- 右键菜单 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="menu-right">
|
|
4
|
+
<Transition name="context-menu" @before-enter="onBeforeEnter" @after-leave="onAfterLeave">
|
|
5
|
+
<div
|
|
6
|
+
v-show="visible"
|
|
7
|
+
:style="menuStyle"
|
|
8
|
+
class="context-menu art-card-xs !shadow-xl min-w-[var(--menu-width)] w-[var(--menu-width)]"
|
|
9
|
+
>
|
|
10
|
+
<ul class="menu-list m-0 list-none" :style="menuListStyle">
|
|
11
|
+
<template v-for="item in menuItems" :key="item.key">
|
|
12
|
+
<!-- 普通菜单项 -->
|
|
13
|
+
<li
|
|
14
|
+
v-if="!item.children"
|
|
15
|
+
class="menu-item relative flex-c c-p select-none rounded text-xs transition-colors duration-150 hover:bg-g-200"
|
|
16
|
+
:class="{ 'is-disabled': item.disabled, 'has-line': item.showLine }"
|
|
17
|
+
:style="menuItemStyle"
|
|
18
|
+
@click="handleMenuClick(item)"
|
|
19
|
+
>
|
|
20
|
+
<ArtSvgIcon
|
|
21
|
+
v-if="item.icon"
|
|
22
|
+
class="mr-2 shrink-0 text-base text-g-800"
|
|
23
|
+
:icon="item.icon"
|
|
24
|
+
/>
|
|
25
|
+
<span
|
|
26
|
+
class="menu-label flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-g-800"
|
|
27
|
+
>{{ item.label }}</span
|
|
28
|
+
>
|
|
29
|
+
</li>
|
|
30
|
+
|
|
31
|
+
<!-- 子菜单 -->
|
|
32
|
+
<li
|
|
33
|
+
v-else
|
|
34
|
+
class="menu-item submenu relative flex-c c-p select-none rounded text-xs transition-colors duration-150 hover:bg-g-200"
|
|
35
|
+
:style="menuItemStyle"
|
|
36
|
+
>
|
|
37
|
+
<div class="submenu-title flex-c w-full">
|
|
38
|
+
<ArtSvgIcon
|
|
39
|
+
v-if="item.icon"
|
|
40
|
+
class="mr-2 shrink-0 text-base text-g-800"
|
|
41
|
+
:icon="item.icon"
|
|
42
|
+
/>
|
|
43
|
+
<span
|
|
44
|
+
class="menu-label flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-g-800"
|
|
45
|
+
>{{ item.label }}</span
|
|
46
|
+
>
|
|
47
|
+
<ArtSvgIcon
|
|
48
|
+
icon="ri:arrow-right-s-line"
|
|
49
|
+
class="ubmenu-arrow ml-auto mr-0 text-base text-g-500 transition-transform duration-150"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
<ul
|
|
53
|
+
class="submenu-list art-card-xs absolute left-full top-0 z-[2001] hidden w-max min-w-max list-none !shadow-xl"
|
|
54
|
+
:style="submenuListStyle"
|
|
55
|
+
>
|
|
56
|
+
<li
|
|
57
|
+
v-for="child in item.children"
|
|
58
|
+
:key="child.key"
|
|
59
|
+
class="menu-item relative mx-1.5 flex-c c-p select-none rounded text-xs transition-colors duration-150 hover:bg-g-200"
|
|
60
|
+
:class="{ 'is-disabled': child.disabled, 'has-line': child.showLine }"
|
|
61
|
+
:style="menuItemStyle"
|
|
62
|
+
@click="handleMenuClick(child)"
|
|
63
|
+
>
|
|
64
|
+
<ArtSvgIcon
|
|
65
|
+
v-if="child.icon"
|
|
66
|
+
class="r-2 shrink-0 text-base text-g-800 mr-1"
|
|
67
|
+
:icon="child.icon"
|
|
68
|
+
/>
|
|
69
|
+
<span
|
|
70
|
+
class="menu-label flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-g-800"
|
|
71
|
+
>{{ child.label }}</span
|
|
72
|
+
>
|
|
73
|
+
</li>
|
|
74
|
+
</ul>
|
|
75
|
+
</li>
|
|
76
|
+
</template>
|
|
77
|
+
</ul>
|
|
78
|
+
</div>
|
|
79
|
+
</Transition>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<script setup lang="ts">
|
|
84
|
+
import type { CSSProperties } from 'vue'
|
|
85
|
+
|
|
86
|
+
defineOptions({ name: 'ArtMenuRight' })
|
|
87
|
+
|
|
88
|
+
export interface MenuItemType {
|
|
89
|
+
/** 菜单项唯一标识 */
|
|
90
|
+
key: string
|
|
91
|
+
/** 菜单项标签 */
|
|
92
|
+
label: string
|
|
93
|
+
/** 菜单项图标 */
|
|
94
|
+
icon?: string
|
|
95
|
+
/** 菜单项是否禁用 */
|
|
96
|
+
disabled?: boolean
|
|
97
|
+
/** 菜单项是否显示分割线 */
|
|
98
|
+
showLine?: boolean
|
|
99
|
+
/** 子菜单 */
|
|
100
|
+
children?: MenuItemType[]
|
|
101
|
+
[key: string]: any
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface Props {
|
|
105
|
+
menuItems: MenuItemType[]
|
|
106
|
+
/** 菜单宽度 */
|
|
107
|
+
menuWidth?: number
|
|
108
|
+
/** 子菜单宽度 */
|
|
109
|
+
submenuWidth?: number
|
|
110
|
+
/** 菜单项高度 */
|
|
111
|
+
itemHeight?: number
|
|
112
|
+
/** 边界距离 */
|
|
113
|
+
boundaryDistance?: number
|
|
114
|
+
/** 菜单内边距 */
|
|
115
|
+
menuPadding?: number
|
|
116
|
+
/** 菜单项水平内边距 */
|
|
117
|
+
itemPaddingX?: number
|
|
118
|
+
/** 菜单圆角 */
|
|
119
|
+
borderRadius?: number
|
|
120
|
+
/** 动画持续时间 */
|
|
121
|
+
animationDuration?: number
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
125
|
+
menuWidth: 120,
|
|
126
|
+
submenuWidth: 150,
|
|
127
|
+
itemHeight: 32,
|
|
128
|
+
boundaryDistance: 10,
|
|
129
|
+
menuPadding: 5,
|
|
130
|
+
itemPaddingX: 6,
|
|
131
|
+
borderRadius: 6,
|
|
132
|
+
animationDuration: 100
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const emit = defineEmits<{
|
|
136
|
+
(e: 'select', item: MenuItemType): void
|
|
137
|
+
(e: 'show'): void
|
|
138
|
+
(e: 'hide'): void
|
|
139
|
+
}>()
|
|
140
|
+
|
|
141
|
+
const visible = ref(false)
|
|
142
|
+
const position = ref({ x: 0, y: 0 })
|
|
143
|
+
|
|
144
|
+
// 用于清理定时器和事件监听器
|
|
145
|
+
let showTimer: number | null = null
|
|
146
|
+
let eventListenersAdded = false
|
|
147
|
+
|
|
148
|
+
// 计算菜单样式
|
|
149
|
+
const menuStyle = computed(
|
|
150
|
+
(): CSSProperties => ({
|
|
151
|
+
position: 'fixed' as const,
|
|
152
|
+
left: `${position.value.x}px`,
|
|
153
|
+
top: `${position.value.y}px`,
|
|
154
|
+
zIndex: 2000,
|
|
155
|
+
width: `${props.menuWidth}px`
|
|
156
|
+
})
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
// 计算菜单列表样式
|
|
160
|
+
const menuListStyle = computed(
|
|
161
|
+
(): CSSProperties => ({
|
|
162
|
+
padding: `${props.menuPadding}px`
|
|
163
|
+
})
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
// 计算菜单项样式
|
|
167
|
+
const menuItemStyle = computed(
|
|
168
|
+
(): CSSProperties => ({
|
|
169
|
+
height: `${props.itemHeight}px`,
|
|
170
|
+
padding: `0 ${props.itemPaddingX}px`,
|
|
171
|
+
borderRadius: '4px'
|
|
172
|
+
})
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
// 计算子菜单列表样式
|
|
176
|
+
const submenuListStyle = computed(
|
|
177
|
+
(): CSSProperties => ({
|
|
178
|
+
minWidth: `${props.submenuWidth}px`,
|
|
179
|
+
padding: `${props.menuPadding}px 0`,
|
|
180
|
+
borderRadius: `${props.borderRadius}px`
|
|
181
|
+
})
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
// 计算菜单高度(用于边界检测)
|
|
185
|
+
const calculateMenuHeight = (): number => {
|
|
186
|
+
let totalHeight = props.menuPadding * 2 // 上下内边距
|
|
187
|
+
|
|
188
|
+
props.menuItems.forEach((item) => {
|
|
189
|
+
totalHeight += props.itemHeight
|
|
190
|
+
if (item.showLine) {
|
|
191
|
+
totalHeight += 10 // 分割线额外高度
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
return totalHeight
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// 优化的位置计算函数
|
|
199
|
+
const calculatePosition = (e: MouseEvent) => {
|
|
200
|
+
const screenWidth = window.innerWidth
|
|
201
|
+
const screenHeight = window.innerHeight
|
|
202
|
+
const menuHeight = calculateMenuHeight()
|
|
203
|
+
|
|
204
|
+
let x = e.clientX
|
|
205
|
+
let y = e.clientY
|
|
206
|
+
|
|
207
|
+
// 检查右边界 - 优先显示在鼠标右侧,如果空间不足则显示在左侧
|
|
208
|
+
if (x + props.menuWidth > screenWidth - props.boundaryDistance) {
|
|
209
|
+
x = Math.max(props.boundaryDistance, x - props.menuWidth)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 检查下边界 - 优先显示在鼠标下方,如果空间不足则向上调整
|
|
213
|
+
if (y + menuHeight > screenHeight - props.boundaryDistance) {
|
|
214
|
+
y = Math.max(props.boundaryDistance, screenHeight - menuHeight - props.boundaryDistance)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 确保不会超出边界
|
|
218
|
+
x = Math.max(
|
|
219
|
+
props.boundaryDistance,
|
|
220
|
+
Math.min(x, screenWidth - props.menuWidth - props.boundaryDistance)
|
|
221
|
+
)
|
|
222
|
+
y = Math.max(
|
|
223
|
+
props.boundaryDistance,
|
|
224
|
+
Math.min(y, screenHeight - menuHeight - props.boundaryDistance)
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
return { x, y }
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 添加事件监听器
|
|
231
|
+
const addEventListeners = () => {
|
|
232
|
+
if (eventListenersAdded) return
|
|
233
|
+
|
|
234
|
+
document.addEventListener('click', handleDocumentClick)
|
|
235
|
+
document.addEventListener('contextmenu', handleDocumentContextmenu)
|
|
236
|
+
document.addEventListener('keydown', handleKeydown)
|
|
237
|
+
eventListenersAdded = true
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 移除事件监听器
|
|
241
|
+
const removeEventListeners = () => {
|
|
242
|
+
if (!eventListenersAdded) return
|
|
243
|
+
|
|
244
|
+
document.removeEventListener('click', handleDocumentClick)
|
|
245
|
+
document.removeEventListener('contextmenu', handleDocumentContextmenu)
|
|
246
|
+
document.removeEventListener('keydown', handleKeydown)
|
|
247
|
+
eventListenersAdded = false
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// 处理文档点击事件
|
|
251
|
+
const handleDocumentClick = (e: Event) => {
|
|
252
|
+
// 检查点击是否在菜单内部
|
|
253
|
+
const target = e.target as Element
|
|
254
|
+
const menuElement = document.querySelector('.context-menu')
|
|
255
|
+
if (menuElement && menuElement.contains(target)) {
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
hide()
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 处理文档右键事件
|
|
262
|
+
const handleDocumentContextmenu = () => {
|
|
263
|
+
hide()
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// 处理键盘事件
|
|
267
|
+
const handleKeydown = (e: KeyboardEvent) => {
|
|
268
|
+
if (e.key === 'Escape') {
|
|
269
|
+
hide()
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const show = (e: MouseEvent) => {
|
|
274
|
+
e.preventDefault()
|
|
275
|
+
e.stopPropagation()
|
|
276
|
+
|
|
277
|
+
// 清理之前的定时器
|
|
278
|
+
if (showTimer) {
|
|
279
|
+
window.clearTimeout(showTimer)
|
|
280
|
+
showTimer = null
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// 计算位置
|
|
284
|
+
position.value = calculatePosition(e)
|
|
285
|
+
visible.value = true
|
|
286
|
+
|
|
287
|
+
emit('show')
|
|
288
|
+
|
|
289
|
+
// 延迟添加事件监听器,避免立即触发关闭
|
|
290
|
+
showTimer = window.setTimeout(() => {
|
|
291
|
+
if (visible.value) {
|
|
292
|
+
addEventListeners()
|
|
293
|
+
}
|
|
294
|
+
showTimer = null
|
|
295
|
+
}, 50) // 减少延迟时间,提升响应性
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const hide = () => {
|
|
299
|
+
if (!visible.value) return
|
|
300
|
+
|
|
301
|
+
visible.value = false
|
|
302
|
+
emit('hide')
|
|
303
|
+
|
|
304
|
+
// 清理定时器
|
|
305
|
+
if (showTimer) {
|
|
306
|
+
window.clearTimeout(showTimer)
|
|
307
|
+
showTimer = null
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// 移除事件监听器
|
|
311
|
+
removeEventListeners()
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const handleMenuClick = (item: MenuItemType) => {
|
|
315
|
+
if (item.disabled) return
|
|
316
|
+
emit('select', item)
|
|
317
|
+
hide()
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// 动画钩子函数
|
|
321
|
+
const onBeforeEnter = (el: Element) => {
|
|
322
|
+
const element = el as HTMLElement
|
|
323
|
+
element.style.transformOrigin = 'top left'
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const onAfterLeave = () => {
|
|
327
|
+
// 确保清理所有资源
|
|
328
|
+
removeEventListeners()
|
|
329
|
+
if (showTimer) {
|
|
330
|
+
window.clearTimeout(showTimer)
|
|
331
|
+
showTimer = null
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// 组件卸载时清理资源
|
|
336
|
+
onUnmounted(() => {
|
|
337
|
+
removeEventListeners()
|
|
338
|
+
if (showTimer) {
|
|
339
|
+
window.clearTimeout(showTimer)
|
|
340
|
+
showTimer = null
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
// 导出方法供父组件调用
|
|
345
|
+
defineExpose({
|
|
346
|
+
show,
|
|
347
|
+
hide,
|
|
348
|
+
visible: computed(() => visible.value)
|
|
349
|
+
})
|
|
350
|
+
</script>
|
|
351
|
+
|
|
352
|
+
<style scoped>
|
|
353
|
+
.menu-right {
|
|
354
|
+
--menu-width: v-bind('props.menuWidth + "px"');
|
|
355
|
+
--border-radius: v-bind('props.borderRadius + "px"');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.menu-item.has-line {
|
|
359
|
+
margin-bottom: 10px;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.menu-item.has-line::after {
|
|
363
|
+
position: absolute;
|
|
364
|
+
right: 0;
|
|
365
|
+
bottom: -5px;
|
|
366
|
+
left: 0;
|
|
367
|
+
height: 1px;
|
|
368
|
+
content: '';
|
|
369
|
+
background-color: var(--art-gray-300);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.menu-item.is-disabled {
|
|
373
|
+
color: var(--el-text-color-disabled);
|
|
374
|
+
cursor: not-allowed;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.menu-item.is-disabled:hover {
|
|
378
|
+
background-color: transparent !important;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.menu-item.is-disabled i:not(.submenu-arrow),
|
|
382
|
+
.menu-item.is-disabled :deep(.art-svg-icon) {
|
|
383
|
+
color: var(--el-text-color-disabled) !important;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.menu-item.is-disabled .menu-label {
|
|
387
|
+
color: var(--el-text-color-disabled) !important;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.menu-item.submenu:hover .submenu-list {
|
|
391
|
+
display: block;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.menu-item.submenu:hover .submenu-title .submenu-arrow {
|
|
395
|
+
transform: rotate(90deg);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* 动画样式 */
|
|
399
|
+
.context-menu-enter-active,
|
|
400
|
+
.context-menu-leave-active {
|
|
401
|
+
transition: all v-bind('props.animationDuration + "ms"') ease-out;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.context-menu-enter-from,
|
|
405
|
+
.context-menu-leave-to {
|
|
406
|
+
opacity: 0;
|
|
407
|
+
transform: scale(0.9);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.context-menu-enter-to,
|
|
411
|
+
.context-menu-leave-from {
|
|
412
|
+
opacity: 1;
|
|
413
|
+
transform: scale(1);
|
|
414
|
+
}
|
|
415
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<!-- 水印组件 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div
|
|
4
|
+
v-if="watermarkVisible"
|
|
5
|
+
class="fixed left-0 top-0 h-screen w-screen pointer-events-none"
|
|
6
|
+
:style="{ zIndex: zIndex }"
|
|
7
|
+
>
|
|
8
|
+
<ElWatermark
|
|
9
|
+
:content="content"
|
|
10
|
+
:font="{ fontSize: fontSize, color: fontColor }"
|
|
11
|
+
:rotate="rotate"
|
|
12
|
+
:gap="[gapX, gapY]"
|
|
13
|
+
:offset="[offsetX, offsetY]"
|
|
14
|
+
>
|
|
15
|
+
<div style="height: 100vh"></div>
|
|
16
|
+
</ElWatermark>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import AppConfig from '@/config'
|
|
22
|
+
import { useSettingStore } from '@/store/modules/setting'
|
|
23
|
+
|
|
24
|
+
defineOptions({ name: 'ArtWatermark' })
|
|
25
|
+
|
|
26
|
+
const settingStore = useSettingStore()
|
|
27
|
+
const { watermarkVisible } = storeToRefs(settingStore)
|
|
28
|
+
|
|
29
|
+
interface WatermarkProps {
|
|
30
|
+
/** 水印内容 */
|
|
31
|
+
content?: string
|
|
32
|
+
/** 水印是否可见 */
|
|
33
|
+
visible?: boolean
|
|
34
|
+
/** 水印字体大小 */
|
|
35
|
+
fontSize?: number
|
|
36
|
+
/** 水印字体颜色 */
|
|
37
|
+
fontColor?: string
|
|
38
|
+
/** 水印旋转角度 */
|
|
39
|
+
rotate?: number
|
|
40
|
+
/** 水印间距X */
|
|
41
|
+
gapX?: number
|
|
42
|
+
/** 水印间距Y */
|
|
43
|
+
gapY?: number
|
|
44
|
+
/** 水印偏移X */
|
|
45
|
+
offsetX?: number
|
|
46
|
+
/** 水印偏移Y */
|
|
47
|
+
offsetY?: number
|
|
48
|
+
/** 水印层级 */
|
|
49
|
+
zIndex?: number
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
withDefaults(defineProps<WatermarkProps>(), {
|
|
53
|
+
content: AppConfig.systemInfo.name,
|
|
54
|
+
visible: false,
|
|
55
|
+
fontSize: 16,
|
|
56
|
+
fontColor: 'rgba(128, 128, 128, 0.2)',
|
|
57
|
+
rotate: -22,
|
|
58
|
+
gapX: 100,
|
|
59
|
+
gapY: 100,
|
|
60
|
+
offsetX: 50,
|
|
61
|
+
offsetY: 50,
|
|
62
|
+
zIndex: 3100
|
|
63
|
+
})
|
|
64
|
+
</script>
|