@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,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v-highlight 代码高亮指令
|
|
3
|
+
*
|
|
4
|
+
* 为代码块提供语法高亮、行号显示和一键复制功能。
|
|
5
|
+
* 基于 highlight.js 实现,支持多种编程语言的语法高亮。
|
|
6
|
+
*
|
|
7
|
+
* ## 主要功能
|
|
8
|
+
*
|
|
9
|
+
* - 语法高亮 - 使用 highlight.js 自动识别并高亮代码
|
|
10
|
+
* - 行号显示 - 自动为每行代码添加行号
|
|
11
|
+
* - 一键复制 - 提供复制按钮,点击即可复制代码(自动过滤行号)
|
|
12
|
+
* - 性能优化 - 批量处理代码块,避免阻塞渲染
|
|
13
|
+
* - 动态监听 - 使用 MutationObserver 监听新增代码块
|
|
14
|
+
* - 防重复处理 - 自动标记已处理的代码块,避免重复处理
|
|
15
|
+
*
|
|
16
|
+
* ## 使用示例
|
|
17
|
+
*
|
|
18
|
+
* ```vue
|
|
19
|
+
* <template>
|
|
20
|
+
* <!-- 基础用法 -->
|
|
21
|
+
* <div v-highlight v-html="codeContent"></div>
|
|
22
|
+
*
|
|
23
|
+
* <!-- 配合 Markdown 渲染 -->
|
|
24
|
+
* <div v-highlight>
|
|
25
|
+
* <pre><code class="language-javascript">
|
|
26
|
+
* const hello = 'world';
|
|
27
|
+
* console.log(hello);
|
|
28
|
+
* </code></pre>
|
|
29
|
+
* </div>
|
|
30
|
+
* </template>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ## 性能优化
|
|
34
|
+
*
|
|
35
|
+
* - 批量处理:每次处理 10 个代码块,避免长时间阻塞
|
|
36
|
+
* - 延迟处理:使用 requestAnimationFrame 分批处理
|
|
37
|
+
* - 重试机制:自动重试处理失败的代码块
|
|
38
|
+
* - 智能监听:只在有新代码块时才触发处理
|
|
39
|
+
*
|
|
40
|
+
* @module directives/core/highlight
|
|
41
|
+
* @author Art Design Pro Team
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
import type { App, Directive } from 'vue'
|
|
45
|
+
|
|
46
|
+
export type HighlightDirective = Directive<HTMLElement>
|
|
47
|
+
|
|
48
|
+
type HighlightJs = (typeof import('highlight.js/lib/core'))['default']
|
|
49
|
+
|
|
50
|
+
let highlighterPromise: Promise<HighlightJs> | undefined
|
|
51
|
+
const processingBlocks = new WeakSet<HTMLElement>()
|
|
52
|
+
|
|
53
|
+
const loadHighlighter = () => {
|
|
54
|
+
highlighterPromise ??= import('./highlight-loader').then(({ highlighter }) => highlighter)
|
|
55
|
+
|
|
56
|
+
return highlighterPromise
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 高亮代码
|
|
60
|
+
async function highlightCode(block: HTMLElement) {
|
|
61
|
+
const highlighter = await loadHighlighter()
|
|
62
|
+
highlighter.highlightElement(block)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 插入行号
|
|
66
|
+
function insertLineNumbers(block: HTMLElement) {
|
|
67
|
+
const lines = block.innerHTML.split('\n')
|
|
68
|
+
const numberedLines = lines
|
|
69
|
+
.map((line, index) => {
|
|
70
|
+
return `<span class="line-number">${index + 1}</span> ${line}`
|
|
71
|
+
})
|
|
72
|
+
.join('\n')
|
|
73
|
+
block.innerHTML = numberedLines
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 添加复制按钮:调整 DOM 结构,将代码部分包裹在 .code-wrapper 内
|
|
77
|
+
function addCopyButton(block: HTMLElement) {
|
|
78
|
+
const copyButton = document.createElement('i')
|
|
79
|
+
copyButton.className = 'copy-button'
|
|
80
|
+
copyButton.innerHTML =
|
|
81
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M7 6V3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-3v3c0 .552-.45 1-1.007 1H4.007A1 1 0 0 1 3 21l.003-14c0-.552.45-1 1.006-1zM5.002 8L5 20h10V8zM9 6h8v10h2V4H9z"/></svg>'
|
|
82
|
+
copyButton.onclick = () => {
|
|
83
|
+
// 过滤掉行号,只复制代码内容
|
|
84
|
+
const codeContent = block.innerText.replace(/^\d+\s+/gm, '')
|
|
85
|
+
navigator.clipboard.writeText(codeContent).then(() => {
|
|
86
|
+
ElMessage.success('复制成功')
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const preElement = block.parentElement
|
|
91
|
+
if (preElement) {
|
|
92
|
+
let codeWrapper: HTMLElement
|
|
93
|
+
// 如果代码块还没有被包裹,则创建包裹容器
|
|
94
|
+
if (!block.parentElement.classList.contains('code-wrapper')) {
|
|
95
|
+
codeWrapper = document.createElement('div')
|
|
96
|
+
codeWrapper.className = 'code-wrapper'
|
|
97
|
+
preElement.replaceChild(codeWrapper, block)
|
|
98
|
+
codeWrapper.appendChild(block)
|
|
99
|
+
} else {
|
|
100
|
+
codeWrapper = block.parentElement
|
|
101
|
+
}
|
|
102
|
+
// 将复制按钮添加到 pre 元素(而非 codeWrapper 内),这样它不会随滚动条滚动
|
|
103
|
+
preElement.appendChild(copyButton)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 检查代码块是否已经被处理过
|
|
108
|
+
function isBlockProcessed(block: HTMLElement): boolean {
|
|
109
|
+
return (
|
|
110
|
+
block.hasAttribute('data-highlighted') ||
|
|
111
|
+
!!block.querySelector('.line-number') ||
|
|
112
|
+
!!block.parentElement?.querySelector('.copy-button')
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 标记代码块为已处理
|
|
117
|
+
function markBlockAsProcessed(block: HTMLElement) {
|
|
118
|
+
block.setAttribute('data-highlighted', 'true')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 处理单个代码块
|
|
122
|
+
async function processBlock(block: HTMLElement) {
|
|
123
|
+
if (isBlockProcessed(block) || processingBlocks.has(block)) {
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
processingBlocks.add(block)
|
|
128
|
+
try {
|
|
129
|
+
await highlightCode(block)
|
|
130
|
+
insertLineNumbers(block)
|
|
131
|
+
addCopyButton(block)
|
|
132
|
+
markBlockAsProcessed(block)
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.warn('处理代码块时出错:', error)
|
|
135
|
+
} finally {
|
|
136
|
+
processingBlocks.delete(block)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 查找并处理所有代码块
|
|
141
|
+
export async function processAllCodeBlocks(el: HTMLElement) {
|
|
142
|
+
const blocks = Array.from(el.querySelectorAll<HTMLElement>('pre code'))
|
|
143
|
+
const unprocessedBlocks = blocks.filter((block) => !isBlockProcessed(block))
|
|
144
|
+
|
|
145
|
+
if (unprocessedBlocks.length === 0) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (unprocessedBlocks.length <= 10) {
|
|
150
|
+
// 如果代码块数量少于等于10,直接处理所有代码块
|
|
151
|
+
await Promise.all(unprocessedBlocks.map((block) => processBlock(block)))
|
|
152
|
+
} else {
|
|
153
|
+
// 定义每次处理的代码块数
|
|
154
|
+
const batchSize = 10
|
|
155
|
+
for (let currentIndex = 0; currentIndex < unprocessedBlocks.length; currentIndex += batchSize) {
|
|
156
|
+
const batch = unprocessedBlocks.slice(currentIndex, currentIndex + batchSize)
|
|
157
|
+
await Promise.all(batch.map((block) => processBlock(block)))
|
|
158
|
+
|
|
159
|
+
if (currentIndex + batchSize < unprocessedBlocks.length) {
|
|
160
|
+
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 重试处理函数
|
|
167
|
+
function retryProcessing(el: HTMLElement, maxRetries: number = 3, delay: number = 200) {
|
|
168
|
+
let retryCount = 0
|
|
169
|
+
|
|
170
|
+
const tryProcess = async () => {
|
|
171
|
+
await processAllCodeBlocks(el)
|
|
172
|
+
|
|
173
|
+
// 检查是否还有未处理的代码块
|
|
174
|
+
const remainingBlocks = Array.from(el.querySelectorAll<HTMLElement>('pre code')).filter(
|
|
175
|
+
(block) => !isBlockProcessed(block)
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
if (remainingBlocks.length > 0 && retryCount < maxRetries) {
|
|
179
|
+
retryCount++
|
|
180
|
+
setTimeout(() => void tryProcess(), delay * retryCount) // 递增延迟
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
void tryProcess()
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// 代码高亮、插入行号、复制按钮
|
|
188
|
+
const highlightDirective: HighlightDirective = {
|
|
189
|
+
mounted(el: HTMLElement) {
|
|
190
|
+
// 立即尝试处理一次
|
|
191
|
+
void processAllCodeBlocks(el)
|
|
192
|
+
|
|
193
|
+
// 延迟处理,确保 v-html 内容已经渲染
|
|
194
|
+
setTimeout(() => {
|
|
195
|
+
retryProcessing(el)
|
|
196
|
+
}, 100)
|
|
197
|
+
|
|
198
|
+
// 使用 MutationObserver 监听 DOM 变化
|
|
199
|
+
const observer = new MutationObserver((mutations) => {
|
|
200
|
+
let hasNewCodeBlocks = false
|
|
201
|
+
|
|
202
|
+
mutations.forEach((mutation) => {
|
|
203
|
+
if (mutation.type === 'childList') {
|
|
204
|
+
mutation.addedNodes.forEach((node) => {
|
|
205
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
206
|
+
const element = node as HTMLElement
|
|
207
|
+
// 检查新添加的节点是否包含代码块
|
|
208
|
+
if (element.tagName === 'PRE' || element.querySelector('pre code')) {
|
|
209
|
+
hasNewCodeBlocks = true
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
if (hasNewCodeBlocks) {
|
|
217
|
+
// 延迟处理新添加的代码块
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
void processAllCodeBlocks(el)
|
|
220
|
+
}, 50)
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
// 开始观察
|
|
225
|
+
observer.observe(el, {
|
|
226
|
+
childList: true,
|
|
227
|
+
subtree: true
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
// 将 observer 存储到元素上,以便在 unmounted 时清理
|
|
231
|
+
;(el as any)._highlightObserver = observer
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
updated(el: HTMLElement) {
|
|
235
|
+
// 当组件更新时,重新处理代码块
|
|
236
|
+
setTimeout(() => {
|
|
237
|
+
void processAllCodeBlocks(el)
|
|
238
|
+
}, 50)
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
unmounted(el: HTMLElement) {
|
|
242
|
+
// 清理 MutationObserver
|
|
243
|
+
const observer = (el as any)._highlightObserver
|
|
244
|
+
if (observer) {
|
|
245
|
+
observer.disconnect()
|
|
246
|
+
delete (el as any)._highlightObserver
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function setupHighlightDirective(app: App) {
|
|
252
|
+
app.directive('highlight', highlightDirective)
|
|
253
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v-ripple 水波纹效果指令
|
|
3
|
+
*
|
|
4
|
+
* 为元素添加 Material Design 风格的水波纹点击效果。
|
|
5
|
+
* 点击时从点击位置扩散出圆形水波纹动画,提升交互体验。
|
|
6
|
+
*
|
|
7
|
+
* ## 主要功能
|
|
8
|
+
*
|
|
9
|
+
* - 水波纹动画 - 点击时从点击位置扩散圆形波纹
|
|
10
|
+
* - 自适应大小 - 根据元素尺寸自动调整波纹大小和动画时长
|
|
11
|
+
* - 智能配色 - 自动识别按钮类型,使用合适的波纹颜色
|
|
12
|
+
* - 自定义颜色 - 支持通过参数自定义波纹颜色
|
|
13
|
+
* - 性能优化 - 使用 requestAnimationFrame 和自动清理机制
|
|
14
|
+
*
|
|
15
|
+
* ## 使用示例
|
|
16
|
+
*
|
|
17
|
+
* ```vue
|
|
18
|
+
* <template>
|
|
19
|
+
* <!-- 基础用法 - 使用默认颜色 -->
|
|
20
|
+
* <el-button v-ripple>点击我</el-button>
|
|
21
|
+
*
|
|
22
|
+
* <!-- 自定义颜色 -->
|
|
23
|
+
* <el-button v-ripple="{ color: 'rgba(255, 0, 0, 0.3)' }">自定义颜色</el-button>
|
|
24
|
+
*
|
|
25
|
+
* <!-- 应用到任意元素 -->
|
|
26
|
+
* <div v-ripple class="custom-card">卡片内容</div>
|
|
27
|
+
* </template>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ## 颜色规则
|
|
31
|
+
*
|
|
32
|
+
* - 有色按钮(primary、success、warning 等):使用白色半透明波纹
|
|
33
|
+
* - 默认按钮:使用主题色半透明波纹
|
|
34
|
+
* - 自定义:通过 color 参数指定任意颜色
|
|
35
|
+
*
|
|
36
|
+
* @module directives/core/ripple
|
|
37
|
+
* @author Art Design Pro Team
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import type { App, Directive, DirectiveBinding } from 'vue'
|
|
41
|
+
|
|
42
|
+
export interface RippleOptions {
|
|
43
|
+
/** 水波纹颜色 */
|
|
44
|
+
color?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type RippleDirective = Directive<HTMLElement, RippleOptions>
|
|
48
|
+
|
|
49
|
+
export const vRipple: RippleDirective = {
|
|
50
|
+
mounted(el: HTMLElement, binding: DirectiveBinding) {
|
|
51
|
+
// 获取指令的配置参数
|
|
52
|
+
const options: RippleOptions = binding.value || {}
|
|
53
|
+
|
|
54
|
+
// 设置元素为相对定位,并隐藏溢出部分
|
|
55
|
+
el.style.position = 'relative'
|
|
56
|
+
el.style.overflow = 'hidden'
|
|
57
|
+
|
|
58
|
+
// 点击事件处理
|
|
59
|
+
el.addEventListener('mousedown', (e: MouseEvent) => {
|
|
60
|
+
const rect = el.getBoundingClientRect()
|
|
61
|
+
const left = e.clientX - rect.left
|
|
62
|
+
const top = e.clientY - rect.top
|
|
63
|
+
|
|
64
|
+
// 创建水波纹元素
|
|
65
|
+
const ripple = document.createElement('div')
|
|
66
|
+
const diameter = Math.max(el.clientWidth, el.clientHeight)
|
|
67
|
+
const radius = diameter / 2
|
|
68
|
+
|
|
69
|
+
// 根据直径计算动画时间(直径越大,动画时间越长)
|
|
70
|
+
const baseTime = 600 // 基础动画时间(毫秒)
|
|
71
|
+
const scaleFactor = 0.5 // 缩放因子
|
|
72
|
+
const animationDuration = baseTime + diameter * scaleFactor
|
|
73
|
+
|
|
74
|
+
// 设置水波纹的尺寸和位置
|
|
75
|
+
ripple.style.width = ripple.style.height = `${diameter}px`
|
|
76
|
+
ripple.style.left = `${left - radius}px`
|
|
77
|
+
ripple.style.top = `${top - radius}px`
|
|
78
|
+
ripple.style.position = 'absolute'
|
|
79
|
+
ripple.style.borderRadius = '50%'
|
|
80
|
+
ripple.style.pointerEvents = 'none'
|
|
81
|
+
|
|
82
|
+
// 判断是否为有色按钮(Element Plus 按钮类型)
|
|
83
|
+
const buttonTypes = ['primary', 'info', 'warning', 'danger', 'success'].map(
|
|
84
|
+
(type) => `el-button--${type}`
|
|
85
|
+
)
|
|
86
|
+
const isColoredButton = buttonTypes.some((type) => el.classList.contains(type))
|
|
87
|
+
const defaultColor = isColoredButton
|
|
88
|
+
? 'rgba(255, 255, 255, 0.25)' // 有色按钮使用白色水波纹
|
|
89
|
+
: 'var(--el-color-primary-light-7)' // 默认按钮使用主题色水波纹
|
|
90
|
+
|
|
91
|
+
// 设置水波纹颜色、初始状态和过渡效果
|
|
92
|
+
ripple.style.backgroundColor = options.color || defaultColor
|
|
93
|
+
ripple.style.transform = 'scale(0)'
|
|
94
|
+
ripple.style.transition = `transform ${animationDuration}ms cubic-bezier(0.3, 0, 0.2, 1), opacity ${animationDuration}ms cubic-bezier(0.3, 0, 0.5, 1)`
|
|
95
|
+
ripple.style.zIndex = '1'
|
|
96
|
+
|
|
97
|
+
// 添加水波纹元素到DOM中
|
|
98
|
+
el.appendChild(ripple)
|
|
99
|
+
|
|
100
|
+
// 触发动画
|
|
101
|
+
requestAnimationFrame(() => {
|
|
102
|
+
ripple.style.transform = 'scale(2)'
|
|
103
|
+
ripple.style.opacity = '0'
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
// 动画结束后移除水波纹元素
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
ripple.remove()
|
|
109
|
+
}, animationDuration + 500) // 增加500ms缓冲时间
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function setupRippleDirective(app: App) {
|
|
115
|
+
app.directive('ripple', vRipple)
|
|
116
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v-roles 角色权限指令
|
|
3
|
+
*
|
|
4
|
+
* 基于用户角色控制 DOM 元素的显示和隐藏。
|
|
5
|
+
* 只要用户拥有指定角色中的任意一个,元素就会显示,否则从 DOM 中移除。
|
|
6
|
+
*
|
|
7
|
+
* ## 主要功能
|
|
8
|
+
*
|
|
9
|
+
* - 角色验证 - 检查用户是否拥有指定角色
|
|
10
|
+
* - 多角色支持 - 支持单个角色或多个角色(满足其一即可)
|
|
11
|
+
* - DOM 控制 - 无权限时自动移除元素,而非隐藏
|
|
12
|
+
* - 响应式更新 - 角色变化时自动更新元素状态
|
|
13
|
+
*
|
|
14
|
+
* ## 使用示例
|
|
15
|
+
*
|
|
16
|
+
* ```vue
|
|
17
|
+
* <template>
|
|
18
|
+
* <!-- 单个角色 - 只有超级管理员可见 -->
|
|
19
|
+
* <el-button v-roles="'R_SUPER'">超级管理员功能</el-button>
|
|
20
|
+
*
|
|
21
|
+
* <!-- 多个角色 - 超级管理员或普通管理员可见 -->
|
|
22
|
+
* <el-button v-roles="['R_SUPER', 'R_ADMIN']">管理员功能</el-button>
|
|
23
|
+
*
|
|
24
|
+
* <!-- 应用到任意元素 -->
|
|
25
|
+
* <div v-roles="['R_SUPER', 'R_ADMIN', 'R_USER']">
|
|
26
|
+
* 所有登录用户可见的内容
|
|
27
|
+
* </div>
|
|
28
|
+
* </template>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ## 权限逻辑
|
|
32
|
+
*
|
|
33
|
+
* - 用户角色从 userStore.getUserInfo.roles 获取
|
|
34
|
+
* - 只要用户拥有指定角色中的任意一个,元素就会显示
|
|
35
|
+
* - 如果用户没有任何角色或不满足条件,元素将被移除
|
|
36
|
+
*
|
|
37
|
+
* ## 注意事项
|
|
38
|
+
*
|
|
39
|
+
* - 该指令会直接移除 DOM 元素,而不是使用 v-if 隐藏
|
|
40
|
+
* - 适用于基于角色的粗粒度权限控制
|
|
41
|
+
* - 如需基于具体操作的细粒度权限控制,请使用 v-auth 指令
|
|
42
|
+
*
|
|
43
|
+
* @module directives/roles
|
|
44
|
+
* @author Art Design Pro Team
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
import { useUserStore } from '@/store/modules/user'
|
|
48
|
+
import { App, Directive, DirectiveBinding } from 'vue'
|
|
49
|
+
|
|
50
|
+
export type RolesDirective = Directive<HTMLElement, string | string[]>
|
|
51
|
+
|
|
52
|
+
function checkRolePermission(el: HTMLElement, binding: DirectiveBinding<string | string[]>): void {
|
|
53
|
+
const userStore = useUserStore()
|
|
54
|
+
const userRoles = userStore.getUserInfo.roles
|
|
55
|
+
|
|
56
|
+
// 如果用户角色为空或未定义,移除元素
|
|
57
|
+
if (!userRoles?.length) {
|
|
58
|
+
removeElement(el)
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 确保指令值为数组格式
|
|
63
|
+
const requiredRoles = Array.isArray(binding.value) ? binding.value : [binding.value]
|
|
64
|
+
|
|
65
|
+
// 检查用户是否具有所需角色之一
|
|
66
|
+
const hasPermission = requiredRoles.some((role: string) => userRoles.includes(role))
|
|
67
|
+
|
|
68
|
+
// 如果没有权限,安全地移除元素
|
|
69
|
+
if (!hasPermission) {
|
|
70
|
+
removeElement(el)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function removeElement(el: HTMLElement): void {
|
|
75
|
+
if (el.parentNode) {
|
|
76
|
+
el.parentNode.removeChild(el)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const rolesDirective: RolesDirective = {
|
|
81
|
+
mounted: checkRolePermission,
|
|
82
|
+
updated: checkRolePermission
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function setupRolesDirective(app: App): void {
|
|
86
|
+
app.directive('roles', rolesDirective)
|
|
87
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import { setupAuthDirective, type AuthDirective } from './core/auth'
|
|
3
|
+
import { setupHighlightDirective, type HighlightDirective } from './core/highlight'
|
|
4
|
+
import { setupRippleDirective, type RippleDirective } from './core/ripple'
|
|
5
|
+
import { setupRolesDirective, type RolesDirective } from './core/roles'
|
|
6
|
+
|
|
7
|
+
export function setupGlobDirectives(app: App) {
|
|
8
|
+
setupAuthDirective(app) // 权限指令
|
|
9
|
+
setupRolesDirective(app) // 角色权限指令
|
|
10
|
+
setupHighlightDirective(app) // 高亮指令
|
|
11
|
+
setupRippleDirective(app) // 水波纹指令
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type { AuthDirective, HighlightDirective, RippleDirective, RolesDirective }
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 系统级别枚举定义模块
|
|
3
|
+
*
|
|
4
|
+
* ## 主要功能
|
|
5
|
+
*
|
|
6
|
+
* - 菜单类型枚举(左侧、顶部、混合、双栏)
|
|
7
|
+
* - 主题类型枚举(亮色、暗色、自动)
|
|
8
|
+
* - 菜单主题枚举(设计、亮色、暗色)
|
|
9
|
+
* - 语言类型枚举(中文、英文)
|
|
10
|
+
* - 容器宽度枚举(全屏、固定)
|
|
11
|
+
* - 菜单宽度枚举(收起宽度)
|
|
12
|
+
*
|
|
13
|
+
* @module enums/appEnum
|
|
14
|
+
* @author Art Design Pro Team
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 菜单类型
|
|
19
|
+
*/
|
|
20
|
+
export enum MenuTypeEnum {
|
|
21
|
+
/** 左侧菜单 */
|
|
22
|
+
LEFT = 'left',
|
|
23
|
+
/** 顶部菜单 */
|
|
24
|
+
TOP = 'top',
|
|
25
|
+
/** 顶部+左侧菜单 */
|
|
26
|
+
TOP_LEFT = 'top-left',
|
|
27
|
+
/** 双栏菜单 */
|
|
28
|
+
DUAL_MENU = 'dual-menu'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 系统主题
|
|
33
|
+
*/
|
|
34
|
+
export enum SystemThemeEnum {
|
|
35
|
+
/** 暗色主题 */
|
|
36
|
+
DARK = 'dark',
|
|
37
|
+
/** 亮色主题 */
|
|
38
|
+
LIGHT = 'light',
|
|
39
|
+
/** 自动主题(跟随系统) */
|
|
40
|
+
AUTO = 'auto'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 菜单主题
|
|
45
|
+
*/
|
|
46
|
+
export enum MenuThemeEnum {
|
|
47
|
+
/** 暗色主题 */
|
|
48
|
+
DARK = 'dark',
|
|
49
|
+
/** 亮色主题 */
|
|
50
|
+
LIGHT = 'light',
|
|
51
|
+
/** 设计主题 */
|
|
52
|
+
DESIGN = 'design'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 菜单宽度
|
|
57
|
+
*/
|
|
58
|
+
export enum MenuWidth {
|
|
59
|
+
/** 收起宽度 */
|
|
60
|
+
CLOSE = '64px'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 语言类型
|
|
65
|
+
*/
|
|
66
|
+
export enum LanguageEnum {
|
|
67
|
+
/** 中文 */
|
|
68
|
+
ZH = 'zh',
|
|
69
|
+
/** 英文 */
|
|
70
|
+
EN = 'en'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 容器宽度
|
|
75
|
+
*/
|
|
76
|
+
export enum ContainerWidthEnum {
|
|
77
|
+
/** 全屏宽度 */
|
|
78
|
+
FULL = '100%',
|
|
79
|
+
/** 固定宽度 */
|
|
80
|
+
BOXED = '1200px'
|
|
81
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module 'nprogress'
|
|
4
|
+
|
|
5
|
+
declare module 'vue-img-cutter'
|
|
6
|
+
|
|
7
|
+
declare module 'file-saver'
|
|
8
|
+
|
|
9
|
+
declare module 'qrcode.vue' {
|
|
10
|
+
export type Level = 'L' | 'M' | 'Q' | 'H'
|
|
11
|
+
export type RenderAs = 'canvas' | 'svg'
|
|
12
|
+
export type GradientType = 'linear' | 'radial'
|
|
13
|
+
export interface ImageSettings {
|
|
14
|
+
src: string
|
|
15
|
+
height: number
|
|
16
|
+
width: number
|
|
17
|
+
excavate: boolean
|
|
18
|
+
}
|
|
19
|
+
export interface QRCodeProps {
|
|
20
|
+
value: string
|
|
21
|
+
size?: number
|
|
22
|
+
level?: Level
|
|
23
|
+
background?: string
|
|
24
|
+
foreground?: string
|
|
25
|
+
renderAs?: RenderAs
|
|
26
|
+
}
|
|
27
|
+
const QrcodeVue: any
|
|
28
|
+
export default QrcodeVue
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 全局变量声明
|
|
32
|
+
declare const __APP_VERSION__: string // 版本号
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAppMode - 应用模式管理
|
|
3
|
+
*
|
|
4
|
+
* 提供应用访问模式的判断和管理功能,支持前端和后端两种权限控制模式。
|
|
5
|
+
* 根据环境变量 VITE_ACCESS_MODE 自动识别当前运行模式。
|
|
6
|
+
*
|
|
7
|
+
* ## 主要功能
|
|
8
|
+
*
|
|
9
|
+
* 1. 模式识别 - 自动识别前端模式或后端模式
|
|
10
|
+
* 2. 前端模式 - 权限由前端路由配置控制,适合小型项目或演示环境
|
|
11
|
+
* 3. 后端模式 - 权限由后端接口返回的菜单数据控制,适合企业级应用
|
|
12
|
+
* 4. 响应式状态 - 提供响应式的模式判断,方便在组件中使用
|
|
13
|
+
*
|
|
14
|
+
* @module useAppMode
|
|
15
|
+
* @author Art Design Pro Team
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { computed } from 'vue'
|
|
19
|
+
|
|
20
|
+
export function useAppMode() {
|
|
21
|
+
// 获取访问模式配置
|
|
22
|
+
const accessMode = import.meta.env.VITE_ACCESS_MODE
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 是否为前端控制模式
|
|
26
|
+
* 前端模式:权限由前端路由配置控制
|
|
27
|
+
*/
|
|
28
|
+
const isFrontendMode = computed(() => accessMode === 'frontend')
|
|
29
|
+
/**
|
|
30
|
+
* 是否为后端控制模式
|
|
31
|
+
* 后端模式:权限由后端接口返回的菜单数据控制
|
|
32
|
+
*/
|
|
33
|
+
const isBackendMode = computed(() => accessMode === 'backend')
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 当前应用模式
|
|
37
|
+
*/
|
|
38
|
+
const currentMode = computed(() => accessMode)
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
isFrontendMode,
|
|
42
|
+
isBackendMode,
|
|
43
|
+
currentMode
|
|
44
|
+
}
|
|
45
|
+
}
|