@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,261 @@
|
|
|
1
|
+
<!-- WangEditor 富文本编辑器 插件地址:https://www.wangeditor.com/ -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="editor-wrapper">
|
|
4
|
+
<Toolbar
|
|
5
|
+
class="editor-toolbar"
|
|
6
|
+
:editor="editorRef"
|
|
7
|
+
:mode="mode"
|
|
8
|
+
:defaultConfig="toolbarConfig"
|
|
9
|
+
/>
|
|
10
|
+
<Editor
|
|
11
|
+
:style="{ height: height, overflowY: 'hidden' }"
|
|
12
|
+
v-model="modelValue"
|
|
13
|
+
:mode="mode"
|
|
14
|
+
:defaultConfig="editorConfig"
|
|
15
|
+
@onCreated="onCreateEditor"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import '@wangeditor/editor/dist/css/style.css'
|
|
22
|
+
import { onBeforeUnmount, onMounted, shallowRef, computed } from 'vue'
|
|
23
|
+
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
|
|
24
|
+
import { useUserStore } from '@/store/modules/user'
|
|
25
|
+
import EmojiText from '@/utils/ui/emojo'
|
|
26
|
+
import { IDomEditor, IToolbarConfig, IEditorConfig } from '@wangeditor/editor'
|
|
27
|
+
import request from '@/utils/http'
|
|
28
|
+
import { ElMessage } from 'element-plus'
|
|
29
|
+
|
|
30
|
+
defineOptions({ name: 'ArtWangEditor' })
|
|
31
|
+
|
|
32
|
+
type InsertFnType = (url: string, alt: string, href: string) => void
|
|
33
|
+
|
|
34
|
+
const { VITE_API_URL } = import.meta.env
|
|
35
|
+
|
|
36
|
+
// Props 定义
|
|
37
|
+
interface Props {
|
|
38
|
+
/** 编辑器高度 */
|
|
39
|
+
height?: string
|
|
40
|
+
/** 自定义工具栏配置 */
|
|
41
|
+
toolbarKeys?: string[]
|
|
42
|
+
/** 插入新工具到指定位置 */
|
|
43
|
+
insertKeys?: { index: number; keys: string[] }
|
|
44
|
+
/** 排除的工具栏项 */
|
|
45
|
+
excludeKeys?: string[]
|
|
46
|
+
/** 编辑器模式 */
|
|
47
|
+
mode?: 'default' | 'simple'
|
|
48
|
+
/** 占位符文本 */
|
|
49
|
+
placeholder?: string
|
|
50
|
+
/** 上传配置 */
|
|
51
|
+
uploadConfig?: {
|
|
52
|
+
maxFileSize?: number
|
|
53
|
+
maxNumberOfFiles?: number
|
|
54
|
+
server?: string
|
|
55
|
+
// 是否开启自定义上传
|
|
56
|
+
isCustomUpload?: boolean
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
61
|
+
height: '500px',
|
|
62
|
+
mode: 'default',
|
|
63
|
+
placeholder: '请输入内容...',
|
|
64
|
+
excludeKeys: () => ['fontFamily'],
|
|
65
|
+
isCustomUpload: false
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const modelValue = defineModel<string>({ required: true })
|
|
69
|
+
|
|
70
|
+
// 编辑器实例
|
|
71
|
+
const editorRef = shallowRef<IDomEditor>()
|
|
72
|
+
const userStore = useUserStore()
|
|
73
|
+
|
|
74
|
+
// 常量配置
|
|
75
|
+
const DEFAULT_UPLOAD_CONFIG = {
|
|
76
|
+
maxFileSize: 3 * 1024 * 1024, // 3MB
|
|
77
|
+
maxNumberOfFiles: 10,
|
|
78
|
+
fieldName: 'file',
|
|
79
|
+
allowedFileTypes: ['image/*']
|
|
80
|
+
} as const
|
|
81
|
+
|
|
82
|
+
// 计算属性:上传服务器地址
|
|
83
|
+
const uploadServer = computed(
|
|
84
|
+
() => props.uploadConfig?.server || `${VITE_API_URL}/api/common/upload/wangeditor`
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
// 合并上传配置
|
|
88
|
+
const mergedUploadConfig = computed(() => ({
|
|
89
|
+
...DEFAULT_UPLOAD_CONFIG,
|
|
90
|
+
...props.uploadConfig
|
|
91
|
+
}))
|
|
92
|
+
|
|
93
|
+
// 工具栏配置
|
|
94
|
+
const toolbarConfig = computed((): Partial<IToolbarConfig> => {
|
|
95
|
+
const config: Partial<IToolbarConfig> = {}
|
|
96
|
+
|
|
97
|
+
// 完全自定义工具栏
|
|
98
|
+
if (props.toolbarKeys && props.toolbarKeys.length > 0) {
|
|
99
|
+
config.toolbarKeys = props.toolbarKeys
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 插入新工具
|
|
103
|
+
if (props.insertKeys) {
|
|
104
|
+
config.insertKeys = props.insertKeys
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 排除工具
|
|
108
|
+
if (props.excludeKeys && props.excludeKeys.length > 0) {
|
|
109
|
+
config.excludeKeys = props.excludeKeys
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return config
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
// 编辑器配置
|
|
116
|
+
const editorConfig: Partial<IEditorConfig> = {
|
|
117
|
+
placeholder: props.placeholder,
|
|
118
|
+
MENU_CONF: {
|
|
119
|
+
uploadImage: {
|
|
120
|
+
fieldName: mergedUploadConfig.value.fieldName,
|
|
121
|
+
maxFileSize: mergedUploadConfig.value.maxFileSize,
|
|
122
|
+
maxNumberOfFiles: mergedUploadConfig.value.maxNumberOfFiles,
|
|
123
|
+
allowedFileTypes: mergedUploadConfig.value.allowedFileTypes,
|
|
124
|
+
server: uploadServer.value,
|
|
125
|
+
headers: {
|
|
126
|
+
Authorization: userStore.accessToken
|
|
127
|
+
},
|
|
128
|
+
onSuccess() {
|
|
129
|
+
ElMessage.success(`图片上传成功 ${EmojiText[200]}`)
|
|
130
|
+
},
|
|
131
|
+
onError(file: File, err: any, res: any) {
|
|
132
|
+
console.error('图片上传失败:', err, res)
|
|
133
|
+
ElMessage.error(`图片上传失败 ${EmojiText[500]}`)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 自定义上传
|
|
140
|
+
if (props.uploadConfig?.isCustomUpload && props.uploadConfig?.server && editorConfig.MENU_CONF) {
|
|
141
|
+
editorConfig.MENU_CONF.uploadImage.customUpload = async (
|
|
142
|
+
file: File,
|
|
143
|
+
insertFn: InsertFnType
|
|
144
|
+
) => {
|
|
145
|
+
try {
|
|
146
|
+
const formData = new FormData()
|
|
147
|
+
formData.append(mergedUploadConfig.value.fieldName, file)
|
|
148
|
+
|
|
149
|
+
const response = await request.post<{ url: string; alt: string; href: string }>({
|
|
150
|
+
url: props.uploadConfig?.server,
|
|
151
|
+
data: formData,
|
|
152
|
+
headers: {
|
|
153
|
+
'Content-Type': 'multipart/form-data',
|
|
154
|
+
Authorization: userStore.accessToken
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
const { url, alt, href } = response
|
|
159
|
+
|
|
160
|
+
if (!url) {
|
|
161
|
+
throw new Error('上传失败,请检查服务端配置')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
insertFn(url, alt, href)
|
|
165
|
+
ElMessage.success(`图片上传成功 ${EmojiText[200]}`)
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('图片上传失败:', error)
|
|
168
|
+
ElMessage.error(`图片上传失败 ${EmojiText[500]}`)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 编辑器创建回调
|
|
174
|
+
const onCreateEditor = (editor: IDomEditor) => {
|
|
175
|
+
editorRef.value = editor
|
|
176
|
+
|
|
177
|
+
// 监听全屏事件
|
|
178
|
+
editor.on('fullScreen', () => {
|
|
179
|
+
console.log('编辑器进入全屏模式')
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
// 确保在编辑器创建后应用自定义图标
|
|
183
|
+
applyCustomIcons()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// 应用自定义图标(带重试机制)
|
|
187
|
+
const applyCustomIcons = () => {
|
|
188
|
+
let retryCount = 0
|
|
189
|
+
const maxRetries = 10
|
|
190
|
+
const retryDelay = 100
|
|
191
|
+
|
|
192
|
+
const tryApplyIcons = () => {
|
|
193
|
+
const editor = editorRef.value
|
|
194
|
+
if (!editor) {
|
|
195
|
+
if (retryCount < maxRetries) {
|
|
196
|
+
retryCount++
|
|
197
|
+
setTimeout(tryApplyIcons, retryDelay)
|
|
198
|
+
}
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 获取当前编辑器的工具栏容器
|
|
203
|
+
const editorContainer = editor.getEditableContainer().closest('.editor-wrapper')
|
|
204
|
+
if (!editorContainer) {
|
|
205
|
+
if (retryCount < maxRetries) {
|
|
206
|
+
retryCount++
|
|
207
|
+
setTimeout(tryApplyIcons, retryDelay)
|
|
208
|
+
}
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const toolbar = editorContainer.querySelector('.w-e-toolbar')
|
|
213
|
+
const toolbarButtons = editorContainer.querySelectorAll('.w-e-bar-item button[data-menu-key]')
|
|
214
|
+
|
|
215
|
+
if (toolbar && toolbarButtons.length > 0) {
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 如果工具栏还没渲染完成,继续重试
|
|
220
|
+
if (retryCount < maxRetries) {
|
|
221
|
+
retryCount++
|
|
222
|
+
setTimeout(tryApplyIcons, retryDelay)
|
|
223
|
+
} else {
|
|
224
|
+
console.warn('工具栏渲染超时,无法应用自定义图标 - 编辑器实例:', editor.id)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 使用 requestAnimationFrame 确保在下一帧执行
|
|
229
|
+
requestAnimationFrame(tryApplyIcons)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// 暴露编辑器实例和方法
|
|
233
|
+
defineExpose({
|
|
234
|
+
/** 获取编辑器实例 */
|
|
235
|
+
getEditor: () => editorRef.value,
|
|
236
|
+
/** 设置编辑器内容 */
|
|
237
|
+
setHtml: (html: string) => editorRef.value?.setHtml(html),
|
|
238
|
+
/** 获取编辑器内容 */
|
|
239
|
+
getHtml: () => editorRef.value?.getHtml(),
|
|
240
|
+
/** 清空编辑器 */
|
|
241
|
+
clear: () => editorRef.value?.clear(),
|
|
242
|
+
/** 聚焦编辑器 */
|
|
243
|
+
focus: () => editorRef.value?.focus()
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
// 生命周期
|
|
247
|
+
onMounted(() => {
|
|
248
|
+
// 图标替换已在 onCreateEditor 中处理
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
onBeforeUnmount(() => {
|
|
252
|
+
const editor = editorRef.value
|
|
253
|
+
if (editor) {
|
|
254
|
+
editor.destroy()
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
</script>
|
|
258
|
+
|
|
259
|
+
<style lang="scss">
|
|
260
|
+
@use './style';
|
|
261
|
+
</style>
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
$box-radius: calc(var(--custom-radius) / 3 + 2px);
|
|
2
|
+
|
|
3
|
+
// 全屏容器 z-index 调整
|
|
4
|
+
.w-e-full-screen-container {
|
|
5
|
+
z-index: 100 !important;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* 编辑器容器 */
|
|
9
|
+
.editor-wrapper {
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
border: 1px solid var(--art-gray-300);
|
|
13
|
+
border-radius: $box-radius !important;
|
|
14
|
+
|
|
15
|
+
.w-e-bar {
|
|
16
|
+
border-radius: $box-radius $box-radius 0 0 !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.menu-item {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
align-items: center;
|
|
23
|
+
|
|
24
|
+
i {
|
|
25
|
+
margin-right: 5px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* 工具栏 */
|
|
30
|
+
.editor-toolbar {
|
|
31
|
+
border-bottom: 1px solid var(--default-border);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* 下拉选择框配置 */
|
|
35
|
+
.w-e-select-list {
|
|
36
|
+
min-width: 140px;
|
|
37
|
+
padding: 5px 10px 10px;
|
|
38
|
+
border: none;
|
|
39
|
+
border-radius: $box-radius;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* 下拉选择框元素配置 */
|
|
43
|
+
.w-e-select-list ul li {
|
|
44
|
+
margin-top: 5px;
|
|
45
|
+
font-size: 15px !important;
|
|
46
|
+
border-radius: $box-radius;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* 下拉选择框 正文文字大小调整 */
|
|
50
|
+
.w-e-select-list ul li:last-of-type {
|
|
51
|
+
font-size: 16px !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* 下拉选择框 hover 样式调整 */
|
|
55
|
+
.w-e-select-list ul li:hover {
|
|
56
|
+
background-color: var(--art-gray-200);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:root {
|
|
60
|
+
/* 激活颜色 */
|
|
61
|
+
--w-e-toolbar-active-bg-color: var(--art-gray-200);
|
|
62
|
+
|
|
63
|
+
/* toolbar 图标和文字颜色 */
|
|
64
|
+
--w-e-toolbar-color: #000;
|
|
65
|
+
|
|
66
|
+
/* 表格选中时候的边框颜色 */
|
|
67
|
+
--w-e-textarea-selected-border-color: #ddd;
|
|
68
|
+
|
|
69
|
+
/* 表格头背景颜色 */
|
|
70
|
+
--w-e-textarea-slight-bg-color: var(--art-gray-200);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* 工具栏按钮样式 */
|
|
74
|
+
.w-e-bar-item svg {
|
|
75
|
+
fill: var(--art-gray-800);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.w-e-bar-item button {
|
|
79
|
+
color: var(--art-gray-800);
|
|
80
|
+
border-radius: $box-radius;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* 工具栏 hover 按钮背景颜色 */
|
|
84
|
+
.w-e-bar-item button:hover {
|
|
85
|
+
background-color: var(--art-gray-200);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* 工具栏分割线 */
|
|
89
|
+
.w-e-bar-divider {
|
|
90
|
+
height: 20px;
|
|
91
|
+
margin-top: 10px;
|
|
92
|
+
background-color: #ccc;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* 工具栏菜单 */
|
|
96
|
+
.w-e-bar-item-group .w-e-bar-item-menus-container {
|
|
97
|
+
min-width: 120px;
|
|
98
|
+
padding: 10px 0;
|
|
99
|
+
border: none;
|
|
100
|
+
border-radius: $box-radius;
|
|
101
|
+
|
|
102
|
+
.w-e-bar-item {
|
|
103
|
+
button {
|
|
104
|
+
width: 100%;
|
|
105
|
+
margin: 0 5px;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* 代码块 */
|
|
111
|
+
.w-e-text-container [data-slate-editor] pre > code {
|
|
112
|
+
padding: 0.6rem 1rem;
|
|
113
|
+
background-color: var(--art-gray-50);
|
|
114
|
+
border-radius: $box-radius;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* 弹出框 */
|
|
118
|
+
.w-e-drop-panel {
|
|
119
|
+
border: 0;
|
|
120
|
+
border-radius: $box-radius;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
a {
|
|
124
|
+
color: #318ef4;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.w-e-text-container {
|
|
128
|
+
[data-slate-editor] {
|
|
129
|
+
h1,
|
|
130
|
+
h2,
|
|
131
|
+
h3,
|
|
132
|
+
h4,
|
|
133
|
+
h5,
|
|
134
|
+
h6 {
|
|
135
|
+
margin: 0.8em 0 0.4em;
|
|
136
|
+
font-weight: 700;
|
|
137
|
+
line-height: 1.35;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
h1 {
|
|
141
|
+
font-size: 2em;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
h2 {
|
|
145
|
+
font-size: 1.5em;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
h3 {
|
|
149
|
+
font-size: 1.25em;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
h4 {
|
|
153
|
+
font-size: 1.125em;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
h5 {
|
|
157
|
+
font-size: 1em;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
h6 {
|
|
161
|
+
font-size: 0.875em;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
ul,
|
|
165
|
+
ol {
|
|
166
|
+
padding-left: 1.5em;
|
|
167
|
+
margin: 0.8em 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
ul {
|
|
171
|
+
list-style: disc;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
ol {
|
|
175
|
+
list-style: decimal;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
li {
|
|
179
|
+
margin: 0.25em 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
ul ul {
|
|
183
|
+
list-style: circle;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
ul ul ul {
|
|
187
|
+
list-style: square;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
strong,
|
|
192
|
+
b {
|
|
193
|
+
font-weight: 700;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
i,
|
|
197
|
+
em {
|
|
198
|
+
font-style: italic;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* 表格样式优化 */
|
|
203
|
+
.w-e-text-container [data-slate-editor] .table-container th {
|
|
204
|
+
border-right: none;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.w-e-text-container [data-slate-editor] .table-container th:last-of-type {
|
|
208
|
+
border-right: 1px solid #ccc !important;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* 引用 */
|
|
212
|
+
.w-e-text-container [data-slate-editor] blockquote {
|
|
213
|
+
background-color: var(--art-gray-200);
|
|
214
|
+
border-left: 4px solid var(--art-gray-300);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* 输入区域弹出 bar */
|
|
218
|
+
.w-e-hover-bar {
|
|
219
|
+
border-radius: $box-radius;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* 超链接弹窗 */
|
|
223
|
+
.w-e-modal {
|
|
224
|
+
border: none;
|
|
225
|
+
border-radius: $box-radius;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* 图片样式调整 */
|
|
229
|
+
.w-e-text-container [data-slate-editor] .w-e-selected-image-container {
|
|
230
|
+
overflow: inherit;
|
|
231
|
+
|
|
232
|
+
&:hover {
|
|
233
|
+
border: 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
img {
|
|
237
|
+
border: 1px solid transparent;
|
|
238
|
+
transition: border 0.3s;
|
|
239
|
+
|
|
240
|
+
&:hover {
|
|
241
|
+
border: 1px solid #318ef4 !important;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.w-e-image-dragger {
|
|
246
|
+
width: 12px;
|
|
247
|
+
height: 12px;
|
|
248
|
+
background-color: #318ef4;
|
|
249
|
+
border: 2px solid #fff;
|
|
250
|
+
border-radius: $box-radius;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.left-top {
|
|
254
|
+
top: -6px;
|
|
255
|
+
left: -6px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.right-top {
|
|
259
|
+
top: -6px;
|
|
260
|
+
right: -6px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.left-bottom {
|
|
264
|
+
bottom: -6px;
|
|
265
|
+
left: -6px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.right-bottom {
|
|
269
|
+
right: -6px;
|
|
270
|
+
bottom: -6px;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<!-- 面包屑导航 -->
|
|
2
|
+
<template>
|
|
3
|
+
<nav class="ml-2.5 max-lg:!hidden" aria-label="breadcrumb">
|
|
4
|
+
<ul class="flex-c h-full">
|
|
5
|
+
<li
|
|
6
|
+
v-for="(item, index) in breadcrumbItems"
|
|
7
|
+
:key="item.path"
|
|
8
|
+
class="box-border flex-c h-7 text-sm leading-7"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
:class="
|
|
12
|
+
isClickable(item, index)
|
|
13
|
+
? 'c-p py-1 rounded tad-200 hover:bg-active-color hover:[&_span]:text-g-600'
|
|
14
|
+
: ''
|
|
15
|
+
"
|
|
16
|
+
@click="handleBreadcrumbClick(item, index)"
|
|
17
|
+
>
|
|
18
|
+
<span
|
|
19
|
+
class="block max-w-46 overflow-hidden text-ellipsis whitespace-nowrap px-1.5 text-sm text-g-600 dark:text-g-800"
|
|
20
|
+
>{{ formatMenuTitle(item.meta?.title as string) }}</span
|
|
21
|
+
>
|
|
22
|
+
</div>
|
|
23
|
+
<div
|
|
24
|
+
v-if="!isLastItem(index) && item.meta?.title"
|
|
25
|
+
class="mx-1 text-sm not-italic text-g-500"
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
>
|
|
28
|
+
/
|
|
29
|
+
</div>
|
|
30
|
+
</li>
|
|
31
|
+
</ul>
|
|
32
|
+
</nav>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { computed } from 'vue'
|
|
37
|
+
import { useRouter, useRoute } from 'vue-router'
|
|
38
|
+
import type { RouteLocationMatched, RouteRecordRaw } from 'vue-router'
|
|
39
|
+
import { formatMenuTitle } from '@/utils/router'
|
|
40
|
+
|
|
41
|
+
defineOptions({ name: 'ArtBreadcrumb' })
|
|
42
|
+
|
|
43
|
+
export interface BreadcrumbItem {
|
|
44
|
+
path: string
|
|
45
|
+
meta: RouteRecordRaw['meta']
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const route = useRoute()
|
|
49
|
+
const router = useRouter()
|
|
50
|
+
|
|
51
|
+
// 使用computed替代watch,提高性能
|
|
52
|
+
const breadcrumbItems = computed<BreadcrumbItem[]>(() => {
|
|
53
|
+
const { matched } = route
|
|
54
|
+
const matchedLength = matched.length
|
|
55
|
+
|
|
56
|
+
// 处理首页情况
|
|
57
|
+
if (!matchedLength || isHomeRoute(matched[0])) {
|
|
58
|
+
return []
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 处理一级菜单和普通路由
|
|
62
|
+
const firstRoute = matched[0]
|
|
63
|
+
const isFirstLevel = firstRoute.meta?.isFirstLevel
|
|
64
|
+
const lastIndex = matchedLength - 1
|
|
65
|
+
const currentRoute = matched[lastIndex]
|
|
66
|
+
const currentRouteMeta = currentRoute.meta
|
|
67
|
+
|
|
68
|
+
let items = isFirstLevel
|
|
69
|
+
? [createBreadcrumbItem(currentRoute)]
|
|
70
|
+
: matched.map(createBreadcrumbItem)
|
|
71
|
+
|
|
72
|
+
// 过滤包裹容器:如果有多个项目且第一个是容器路由(如 /outside),则移除它
|
|
73
|
+
if (items.length > 1 && isWrapperContainer(items[0])) {
|
|
74
|
+
items = items.slice(1)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// IFrame 页面特殊处理:如果过滤后只剩一个 iframe 页面,或者所有项都是包裹容器,则仅展示当前页
|
|
78
|
+
if (currentRouteMeta?.isIframe && (items.length === 1 || items.every(isWrapperContainer))) {
|
|
79
|
+
return [createBreadcrumbItem(currentRoute)]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return items
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// 辅助函数:判断是否为包裹容器路由
|
|
86
|
+
const isWrapperContainer = (item: BreadcrumbItem): boolean =>
|
|
87
|
+
item.path === '/outside' && !!item.meta?.isIframe
|
|
88
|
+
|
|
89
|
+
// 辅助函数:创建面包屑项目
|
|
90
|
+
const createBreadcrumbItem = (route: RouteLocationMatched): BreadcrumbItem => ({
|
|
91
|
+
path: route.path,
|
|
92
|
+
meta: route.meta
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// 辅助函数:判断是否为首页
|
|
96
|
+
const isHomeRoute = (route: RouteLocationMatched): boolean => route.name === '/'
|
|
97
|
+
|
|
98
|
+
// 辅助函数:判断是否为最后一项
|
|
99
|
+
const isLastItem = (index: number): boolean => {
|
|
100
|
+
const itemsLength = breadcrumbItems.value.length
|
|
101
|
+
return index === itemsLength - 1
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 辅助函数:判断是否可点击
|
|
105
|
+
const isClickable = (item: BreadcrumbItem, index: number): boolean =>
|
|
106
|
+
item.path !== '/outside' && !isLastItem(index)
|
|
107
|
+
|
|
108
|
+
// 辅助函数:查找路由的第一个有效子路由
|
|
109
|
+
const findFirstValidChild = (route: RouteRecordRaw) =>
|
|
110
|
+
route.children?.find((child) => !child.redirect && !child.meta?.isHide)
|
|
111
|
+
|
|
112
|
+
// 辅助函数:构建完整路径
|
|
113
|
+
const buildFullPath = (childPath: string): string => `/${childPath}`.replace('//', '/')
|
|
114
|
+
|
|
115
|
+
// 处理面包屑点击事件
|
|
116
|
+
async function handleBreadcrumbClick(item: BreadcrumbItem, index: number): Promise<void> {
|
|
117
|
+
// 如果是最后一项或外部链接,不处理
|
|
118
|
+
if (isLastItem(index) || item.path === '/outside') {
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
// 缓存路由表查找结果
|
|
124
|
+
const routes = router.getRoutes()
|
|
125
|
+
const targetRoute = routes.find((route) => route.path === item.path)
|
|
126
|
+
|
|
127
|
+
if (!targetRoute?.children?.length) {
|
|
128
|
+
await router.push(item.path)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const firstValidChild = findFirstValidChild(targetRoute)
|
|
133
|
+
if (firstValidChild) {
|
|
134
|
+
await router.push(buildFullPath(firstValidChild.path))
|
|
135
|
+
} else {
|
|
136
|
+
await router.push(item.path)
|
|
137
|
+
}
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error('导航失败:', error)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</script>
|