@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.
Files changed (293) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -0
  3. package/package.json +37 -0
  4. package/template/.env +22 -0
  5. package/template/.env.development +13 -0
  6. package/template/.env.production +10 -0
  7. package/template/.prettierignore +3 -0
  8. package/template/.prettierrc +20 -0
  9. package/template/.stylelintignore +9 -0
  10. package/template/.stylelintrc.cjs +84 -0
  11. package/template/LICENSE +21 -0
  12. package/template/README.md +22 -0
  13. package/template/_gitignore +19 -0
  14. package/template/eslint-auto-import.json +324 -0
  15. package/template/eslint.config.mjs +83 -0
  16. package/template/index.html +25 -0
  17. package/template/package.json +79 -0
  18. package/template/playwright.config.ts +25 -0
  19. package/template/public/favicon.ico +0 -0
  20. package/template/src/App.vue +39 -0
  21. package/template/src/adapters/auth/index.ts +9 -0
  22. package/template/src/adapters/auth/mock.ts +10 -0
  23. package/template/src/adapters/auth/types.ts +11 -0
  24. package/template/src/adapters/navigation/index.ts +13 -0
  25. package/template/src/adapters/navigation/types.ts +6 -0
  26. package/template/src/api/auth.ts +23 -0
  27. package/template/src/assets/images/avatar/avatar.webp +0 -0
  28. package/template/src/assets/images/avatar/avatar1.webp +0 -0
  29. package/template/src/assets/images/avatar/avatar10.webp +0 -0
  30. package/template/src/assets/images/avatar/avatar2.webp +0 -0
  31. package/template/src/assets/images/avatar/avatar3.webp +0 -0
  32. package/template/src/assets/images/avatar/avatar4.webp +0 -0
  33. package/template/src/assets/images/avatar/avatar5.webp +0 -0
  34. package/template/src/assets/images/avatar/avatar6.webp +0 -0
  35. package/template/src/assets/images/avatar/avatar7.webp +0 -0
  36. package/template/src/assets/images/avatar/avatar8.webp +0 -0
  37. package/template/src/assets/images/avatar/avatar9.webp +0 -0
  38. package/template/src/assets/images/ceremony/hb.png +0 -0
  39. package/template/src/assets/images/ceremony/sd.png +0 -0
  40. package/template/src/assets/images/ceremony/xc.png +0 -0
  41. package/template/src/assets/images/ceremony/yd.png +0 -0
  42. package/template/src/assets/images/common/logo.webp +0 -0
  43. package/template/src/assets/images/draw/draw1.png +0 -0
  44. package/template/src/assets/images/favicon.ico +0 -0
  45. package/template/src/assets/images/lock/bg_dark.webp +0 -0
  46. package/template/src/assets/images/lock/bg_light.webp +0 -0
  47. package/template/src/assets/images/login/kylin-hero-source.png +0 -0
  48. package/template/src/assets/images/login/lf_icon2.webp +0 -0
  49. package/template/src/assets/images/settings/menu_layouts/dual_column.png +0 -0
  50. package/template/src/assets/images/settings/menu_layouts/horizontal.png +0 -0
  51. package/template/src/assets/images/settings/menu_layouts/mixed.png +0 -0
  52. package/template/src/assets/images/settings/menu_layouts/vertical.png +0 -0
  53. package/template/src/assets/images/settings/menu_styles/dark.png +0 -0
  54. package/template/src/assets/images/settings/menu_styles/design.png +0 -0
  55. package/template/src/assets/images/settings/menu_styles/light.png +0 -0
  56. package/template/src/assets/images/settings/theme_styles/dark.png +0 -0
  57. package/template/src/assets/images/settings/theme_styles/light.png +0 -0
  58. package/template/src/assets/images/settings/theme_styles/system.png +0 -0
  59. package/template/src/assets/images/svg/403.svg +1 -0
  60. package/template/src/assets/images/svg/404.svg +1 -0
  61. package/template/src/assets/images/svg/500.svg +5 -0
  62. package/template/src/assets/images/svg/login_icon.svg +1 -0
  63. package/template/src/assets/images/user/avatar.webp +0 -0
  64. package/template/src/assets/images/user/bg.webp +0 -0
  65. package/template/src/assets/styles/core/app.scss +227 -0
  66. package/template/src/assets/styles/core/dark.scss +93 -0
  67. package/template/src/assets/styles/core/el-dark.scss +2 -0
  68. package/template/src/assets/styles/core/el-light.scss +34 -0
  69. package/template/src/assets/styles/core/el-ui.scss +519 -0
  70. package/template/src/assets/styles/core/md.scss +1036 -0
  71. package/template/src/assets/styles/core/mixin.scss +157 -0
  72. package/template/src/assets/styles/core/reset.scss +41 -0
  73. package/template/src/assets/styles/core/router-transition.scss +104 -0
  74. package/template/src/assets/styles/core/tailwind.css +219 -0
  75. package/template/src/assets/styles/core/theme-animation.scss +63 -0
  76. package/template/src/assets/styles/core/theme-change.scss +11 -0
  77. package/template/src/assets/styles/custom/one-dark-pro.scss +98 -0
  78. package/template/src/assets/styles/index.scss +23 -0
  79. package/template/src/assets/svg/loading.ts +32 -0
  80. package/template/src/bootstrap/initializeApp.ts +30 -0
  81. package/template/src/components/core/banners/art-basic-banner/index.vue +343 -0
  82. package/template/src/components/core/banners/art-card-banner/index.vue +114 -0
  83. package/template/src/components/core/base/art-back-to-top/index.vue +40 -0
  84. package/template/src/components/core/base/art-logo/index.vue +34 -0
  85. package/template/src/components/core/base/art-svg-icon/index.vue +24 -0
  86. package/template/src/components/core/cards/art-bar-chart-card/index.vue +103 -0
  87. package/template/src/components/core/cards/art-data-list-card/index.vue +74 -0
  88. package/template/src/components/core/cards/art-donut-chart-card/index.vue +124 -0
  89. package/template/src/components/core/cards/art-image-card/index.vue +89 -0
  90. package/template/src/components/core/cards/art-line-chart-card/index.vue +126 -0
  91. package/template/src/components/core/cards/art-progress-card/index.vue +86 -0
  92. package/template/src/components/core/cards/art-stats-card/index.vue +67 -0
  93. package/template/src/components/core/cards/art-timeline-list-card/index.vue +69 -0
  94. package/template/src/components/core/charts/art-bar-chart/index.vue +203 -0
  95. package/template/src/components/core/charts/art-dual-bar-compare-chart/index.vue +195 -0
  96. package/template/src/components/core/charts/art-h-bar-chart/index.vue +208 -0
  97. package/template/src/components/core/charts/art-k-line-chart/index.vue +152 -0
  98. package/template/src/components/core/charts/art-line-chart/index.vue +371 -0
  99. package/template/src/components/core/charts/art-radar-chart/index.vue +105 -0
  100. package/template/src/components/core/charts/art-ring-chart/index.vue +133 -0
  101. package/template/src/components/core/charts/art-scatter-chart/index.vue +115 -0
  102. package/template/src/components/core/feedback/art-page-loading/index.vue +281 -0
  103. package/template/src/components/core/forms/art-button-more/index.vue +71 -0
  104. package/template/src/components/core/forms/art-button-table/index.vue +59 -0
  105. package/template/src/components/core/forms/art-drag-verify/index.vue +430 -0
  106. package/template/src/components/core/forms/art-excel-export/index.vue +390 -0
  107. package/template/src/components/core/forms/art-excel-import/index.vue +62 -0
  108. package/template/src/components/core/forms/art-form/index.vue +507 -0
  109. package/template/src/components/core/forms/art-wang-editor/index.vue +261 -0
  110. package/template/src/components/core/forms/art-wang-editor/style.scss +273 -0
  111. package/template/src/components/core/layouts/art-breadcrumb/index.vue +142 -0
  112. package/template/src/components/core/layouts/art-chat-window/index.vue +262 -0
  113. package/template/src/components/core/layouts/art-fast-enter/index.vue +113 -0
  114. package/template/src/components/core/layouts/art-fireworks-effect/index.vue +633 -0
  115. package/template/src/components/core/layouts/art-global-component/index.vue +14 -0
  116. package/template/src/components/core/layouts/art-global-search/index.vue +431 -0
  117. package/template/src/components/core/layouts/art-header-bar/index.vue +485 -0
  118. package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +118 -0
  119. package/template/src/components/core/layouts/art-menus/art-horizontal-menu/index.vue +110 -0
  120. package/template/src/components/core/layouts/art-menus/art-horizontal-menu/widget/HorizontalSubmenu.vue +106 -0
  121. package/template/src/components/core/layouts/art-menus/art-mixed-menu/index.vue +279 -0
  122. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/index.vue +354 -0
  123. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/style.scss +251 -0
  124. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/theme.scss +258 -0
  125. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/widget/SidebarSubmenu.vue +190 -0
  126. package/template/src/components/core/layouts/art-notification/index.vue +456 -0
  127. package/template/src/components/core/layouts/art-page-content/index.vue +137 -0
  128. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts +248 -0
  129. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsHandlers.ts +167 -0
  130. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts +233 -0
  131. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsState.ts +37 -0
  132. package/template/src/components/core/layouts/art-settings-panel/index.vue +72 -0
  133. package/template/src/components/core/layouts/art-settings-panel/style.scss +92 -0
  134. package/template/src/components/core/layouts/art-settings-panel/widget/BasicSettings.vue +77 -0
  135. package/template/src/components/core/layouts/art-settings-panel/widget/BoxStyleSettings.vue +38 -0
  136. package/template/src/components/core/layouts/art-settings-panel/widget/ColorSettings.vue +35 -0
  137. package/template/src/components/core/layouts/art-settings-panel/widget/ContainerSettings.vue +33 -0
  138. package/template/src/components/core/layouts/art-settings-panel/widget/MenuLayoutSettings.vue +31 -0
  139. package/template/src/components/core/layouts/art-settings-panel/widget/MenuStyleSettings.vue +44 -0
  140. package/template/src/components/core/layouts/art-settings-panel/widget/SectionTitle.vue +17 -0
  141. package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +236 -0
  142. package/template/src/components/core/layouts/art-settings-panel/widget/SettingDrawer.vue +51 -0
  143. package/template/src/components/core/layouts/art-settings-panel/widget/SettingHeader.vue +18 -0
  144. package/template/src/components/core/layouts/art-settings-panel/widget/SettingItem.vue +101 -0
  145. package/template/src/components/core/layouts/art-settings-panel/widget/ThemeSettings.vue +28 -0
  146. package/template/src/components/core/layouts/art-work-tab/index.vue +584 -0
  147. package/template/src/components/core/media/art-cutter-img/index.vue +350 -0
  148. package/template/src/components/core/media/art-video-player/index.vue +111 -0
  149. package/template/src/components/core/others/art-menu-right/index.vue +415 -0
  150. package/template/src/components/core/others/art-watermark/index.vue +64 -0
  151. package/template/src/components/core/text-effect/art-count-to/index.vue +310 -0
  152. package/template/src/components/core/text-effect/art-festival-text-scroll/index.vue +32 -0
  153. package/template/src/components/core/text-effect/art-text-scroll/index.vue +285 -0
  154. package/template/src/components/core/theme/theme-svg/index.vue +100 -0
  155. package/template/src/components/core/views/exception/ArtException.vue +55 -0
  156. package/template/src/components/core/views/login/AuthTopBar.vue +149 -0
  157. package/template/src/components/core/views/login/LoginLeftView.vue +602 -0
  158. package/template/src/components/core/views/result/ArtResultPage.vue +43 -0
  159. package/template/src/components/core/widget/art-icon-button/index.vue +23 -0
  160. package/template/src/config/assets/images.ts +61 -0
  161. package/template/src/config/index.ts +170 -0
  162. package/template/src/config/modules/component.ts +98 -0
  163. package/template/src/config/modules/fastEnter.ts +16 -0
  164. package/template/src/config/modules/festival.ts +51 -0
  165. package/template/src/config/modules/headerBar.ts +64 -0
  166. package/template/src/config/setting.ts +109 -0
  167. package/template/src/directives/core/auth.ts +66 -0
  168. package/template/src/directives/core/highlight-loader.ts +37 -0
  169. package/template/src/directives/core/highlight.ts +253 -0
  170. package/template/src/directives/core/ripple.ts +116 -0
  171. package/template/src/directives/core/roles.ts +87 -0
  172. package/template/src/directives/index.ts +14 -0
  173. package/template/src/enums/appEnum.ts +81 -0
  174. package/template/src/enums/formEnum.ts +17 -0
  175. package/template/src/env.d.ts +32 -0
  176. package/template/src/hooks/core/useAppMode.ts +45 -0
  177. package/template/src/hooks/core/useAuth.ts +74 -0
  178. package/template/src/hooks/core/useCeremony.ts +184 -0
  179. package/template/src/hooks/core/useChart.ts +745 -0
  180. package/template/src/hooks/core/useCommon.ts +87 -0
  181. package/template/src/hooks/core/useFastEnter.ts +55 -0
  182. package/template/src/hooks/core/useHeaderBar.ts +201 -0
  183. package/template/src/hooks/core/useLayoutHeight.ts +148 -0
  184. package/template/src/hooks/core/useTableColumns.ts +313 -0
  185. package/template/src/hooks/core/useTheme.ts +174 -0
  186. package/template/src/hooks/index.ts +29 -0
  187. package/template/src/locales/index.ts +123 -0
  188. package/template/src/locales/langs/en.json +283 -0
  189. package/template/src/locales/langs/zh.json +283 -0
  190. package/template/src/main.ts +29 -0
  191. package/template/src/mock/auth.ts +46 -0
  192. package/template/src/plugins/echarts.ts +76 -0
  193. package/template/src/plugins/index.ts +6 -0
  194. package/template/src/router/core/ComponentLoader.ts +82 -0
  195. package/template/src/router/core/IframeRouteManager.ts +78 -0
  196. package/template/src/router/core/MenuProcessor.ts +280 -0
  197. package/template/src/router/core/RoutePermissionValidator.ts +161 -0
  198. package/template/src/router/core/RouteRegistry.ts +90 -0
  199. package/template/src/router/core/RouteTransformer.ts +132 -0
  200. package/template/src/router/core/RouteValidator.ts +187 -0
  201. package/template/src/router/core/index.ts +14 -0
  202. package/template/src/router/guards/afterEach.ts +34 -0
  203. package/template/src/router/guards/beforeEach.ts +442 -0
  204. package/template/src/router/index.ts +24 -0
  205. package/template/src/router/modules/dashboard.ts +23 -0
  206. package/template/src/router/modules/examples.ts +109 -0
  207. package/template/src/router/modules/exception.ts +46 -0
  208. package/template/src/router/modules/index.ts +12 -0
  209. package/template/src/router/modules/result.ts +32 -0
  210. package/template/src/router/routes/asyncRoutes.ts +9 -0
  211. package/template/src/router/routes/staticRoutes.ts +60 -0
  212. package/template/src/router/routesAlias.ts +8 -0
  213. package/template/src/services/auth.ts +15 -0
  214. package/template/src/store/index.ts +52 -0
  215. package/template/src/store/modules/menu.ts +109 -0
  216. package/template/src/store/modules/setting.ts +450 -0
  217. package/template/src/store/modules/user.ts +218 -0
  218. package/template/src/store/modules/worktab.ts +568 -0
  219. package/template/src/types/api/api.d.ts +86 -0
  220. package/template/src/types/common/index.ts +95 -0
  221. package/template/src/types/common/response.ts +32 -0
  222. package/template/src/types/component/chart.ts +324 -0
  223. package/template/src/types/component/index.ts +86 -0
  224. package/template/src/types/config/index.ts +253 -0
  225. package/template/src/types/directive/directive.d.ts +15 -0
  226. package/template/src/types/import/auto-imports.d.ts +319 -0
  227. package/template/src/types/import/components.d.ts +126 -0
  228. package/template/src/types/index.ts +22 -0
  229. package/template/src/types/router/index.ts +80 -0
  230. package/template/src/types/store/index.ts +157 -0
  231. package/template/src/utils/form/index.ts +9 -0
  232. package/template/src/utils/form/validator.ts +316 -0
  233. package/template/src/utils/http/contract.ts +39 -0
  234. package/template/src/utils/http/error.ts +182 -0
  235. package/template/src/utils/http/index.ts +226 -0
  236. package/template/src/utils/http/status.ts +18 -0
  237. package/template/src/utils/index.ts +31 -0
  238. package/template/src/utils/navigation/index.ts +10 -0
  239. package/template/src/utils/navigation/jump.ts +68 -0
  240. package/template/src/utils/navigation/route.ts +85 -0
  241. package/template/src/utils/navigation/worktab.ts +67 -0
  242. package/template/src/utils/router.ts +63 -0
  243. package/template/src/utils/socket/index.ts +423 -0
  244. package/template/src/utils/storage/index.ts +7 -0
  245. package/template/src/utils/storage/storage-config.ts +127 -0
  246. package/template/src/utils/storage/storage-key-manager.ts +97 -0
  247. package/template/src/utils/storage/storage.ts +250 -0
  248. package/template/src/utils/sys/console.ts +9 -0
  249. package/template/src/utils/sys/error-handle.ts +143 -0
  250. package/template/src/utils/sys/index.ts +2 -0
  251. package/template/src/utils/sys/mittBus.ts +61 -0
  252. package/template/src/utils/ui/animation.ts +80 -0
  253. package/template/src/utils/ui/colors.ts +273 -0
  254. package/template/src/utils/ui/emojo.ts +24 -0
  255. package/template/src/utils/ui/iconify-loader.ts +31 -0
  256. package/template/src/utils/ui/index.ts +11 -0
  257. package/template/src/utils/ui/loading.ts +158 -0
  258. package/template/src/utils/ui/tabs.ts +60 -0
  259. package/template/src/views/auth/forget-password/index.vue +62 -0
  260. package/template/src/views/auth/login/index.vue +166 -0
  261. package/template/src/views/auth/login/style.css +38 -0
  262. package/template/src/views/auth/register/index.vue +240 -0
  263. package/template/src/views/dashboard/console/index.vue +173 -0
  264. package/template/src/views/examples/analytics/index.vue +389 -0
  265. package/template/src/views/examples/complex-form/index.vue +395 -0
  266. package/template/src/views/examples/crud-workspace/index.vue +412 -0
  267. package/template/src/views/examples/navigation/detail/index.vue +151 -0
  268. package/template/src/views/examples/navigation/state/index.vue +226 -0
  269. package/template/src/views/examples/overview/index.vue +309 -0
  270. package/template/src/views/examples/permissions/index.vue +303 -0
  271. package/template/src/views/examples/search-table/index.vue +182 -0
  272. package/template/src/views/examples/search-table/search.config.ts +81 -0
  273. package/template/src/views/examples/search-table/service.ts +116 -0
  274. package/template/src/views/examples/search-table/table.config.ts +37 -0
  275. package/template/src/views/exception/403/index.vue +16 -0
  276. package/template/src/views/exception/404/index.vue +16 -0
  277. package/template/src/views/exception/500/index.vue +16 -0
  278. package/template/src/views/index/index.vue +29 -0
  279. package/template/src/views/index/style.scss +93 -0
  280. package/template/src/views/outside/Iframe.vue +42 -0
  281. package/template/src/views/result/fail/index.vue +28 -0
  282. package/template/src/views/result/success/index.vue +21 -0
  283. package/template/tests/e2e/auth.spec.ts +14 -0
  284. package/template/tests/e2e/search-table.spec.ts +154 -0
  285. package/template/tests/unit/adapters/auth.spec.ts +38 -0
  286. package/template/tests/unit/config/app-config.spec.ts +17 -0
  287. package/template/tests/unit/directives/highlight.spec.ts +20 -0
  288. package/template/tests/unit/http/contract.spec.ts +47 -0
  289. package/template/tests/unit/mock/search-table.spec.ts +62 -0
  290. package/template/tests/unit/router/examples.spec.ts +52 -0
  291. package/template/tsconfig.json +28 -0
  292. package/template/vite.config.ts +181 -0
  293. package/template/vitest.config.ts +27 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * ECharts 插件配置
3
+ *
4
+ * 按需导入 ECharts 图表和组件,减小打包体积。
5
+ * 只注册项目中实际使用的图表类型和组件。
6
+ *
7
+ * @module plugins/echarts
8
+ * @author Art Design Pro Team
9
+ */
10
+
11
+ // ECharts 按需导入配置
12
+ import * as echarts from 'echarts/core'
13
+
14
+ // 导入图表类型
15
+ import {
16
+ BarChart,
17
+ LineChart,
18
+ PieChart,
19
+ ScatterChart,
20
+ RadarChart,
21
+ MapChart,
22
+ CandlestickChart
23
+ } from 'echarts/charts'
24
+
25
+ // 导入组件
26
+ import {
27
+ TitleComponent,
28
+ TooltipComponent,
29
+ GridComponent,
30
+ LegendComponent,
31
+ DataZoomComponent,
32
+ MarkPointComponent,
33
+ MarkLineComponent,
34
+ ToolboxComponent,
35
+ BrushComponent,
36
+ GeoComponent,
37
+ VisualMapComponent
38
+ } from 'echarts/components'
39
+
40
+ // 导入渲染器
41
+ import { CanvasRenderer } from 'echarts/renderers'
42
+
43
+ // 注册必要的组件
44
+ echarts.use([
45
+ // 图表类型
46
+ BarChart,
47
+ LineChart,
48
+ PieChart,
49
+ ScatterChart,
50
+ RadarChart,
51
+ MapChart,
52
+ CandlestickChart,
53
+
54
+ // 组件
55
+ TitleComponent,
56
+ TooltipComponent,
57
+ GridComponent,
58
+ LegendComponent,
59
+ DataZoomComponent,
60
+ MarkPointComponent,
61
+ MarkLineComponent,
62
+ ToolboxComponent,
63
+ BrushComponent,
64
+ GeoComponent,
65
+ VisualMapComponent,
66
+
67
+ // 渲染器
68
+ CanvasRenderer
69
+ ])
70
+
71
+ // 导出 echarts 实例和类型
72
+ export { echarts }
73
+ export type { EChartsOption, BarSeriesOption } from 'echarts'
74
+
75
+ // 导出常用的图形工具
76
+ export const graphic = echarts.graphic
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 插件统一导出
3
+ * 集中管理第三方库的封装和配置
4
+ */
5
+
6
+ export * from './echarts'
@@ -0,0 +1,82 @@
1
+ /**
2
+ * 组件加载器
3
+ *
4
+ * 负责动态加载 Vue 组件
5
+ *
6
+ * @module router/core/ComponentLoader
7
+ * @author Art Design Pro Team
8
+ */
9
+
10
+ import { h } from 'vue'
11
+
12
+ export class ComponentLoader {
13
+ private modules: Record<string, () => Promise<any>>
14
+
15
+ constructor() {
16
+ // 动态导入 views 目录下所有 .vue 组件
17
+ this.modules = import.meta.glob('../../views/**/*.vue')
18
+ }
19
+
20
+ /**
21
+ * 加载组件
22
+ */
23
+ load(componentPath: string): () => Promise<any> {
24
+ if (!componentPath) {
25
+ return this.createEmptyComponent()
26
+ }
27
+
28
+ // 构建可能的路径
29
+ const fullPath = `../../views${componentPath}.vue`
30
+ const fullPathWithIndex = `../../views${componentPath}/index.vue`
31
+
32
+ // 先尝试直接路径,再尝试添加/index的路径
33
+ const module = this.modules[fullPath] || this.modules[fullPathWithIndex]
34
+
35
+ if (!module) {
36
+ console.error(
37
+ `[ComponentLoader] 未找到组件: ${componentPath},尝试过的路径: ${fullPath} 和 ${fullPathWithIndex}`
38
+ )
39
+ return this.createErrorComponent(componentPath)
40
+ }
41
+
42
+ return module
43
+ }
44
+
45
+ /**
46
+ * 加载布局组件
47
+ */
48
+ loadLayout(): () => Promise<any> {
49
+ return () => import('@/views/index/index.vue')
50
+ }
51
+
52
+ /**
53
+ * 加载 iframe 组件
54
+ */
55
+ loadIframe(): () => Promise<any> {
56
+ return () => import('@/views/outside/Iframe.vue')
57
+ }
58
+
59
+ /**
60
+ * 创建空组件
61
+ */
62
+ private createEmptyComponent(): () => Promise<any> {
63
+ return () =>
64
+ Promise.resolve({
65
+ render() {
66
+ return h('div', {})
67
+ }
68
+ })
69
+ }
70
+
71
+ /**
72
+ * 创建错误提示组件
73
+ */
74
+ private createErrorComponent(componentPath: string): () => Promise<any> {
75
+ return () =>
76
+ Promise.resolve({
77
+ render() {
78
+ return h('div', { class: 'route-error' }, `组件未找到: ${componentPath}`)
79
+ }
80
+ })
81
+ }
82
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Iframe 路由管理器
3
+ *
4
+ * 负责管理 iframe 类型的路由
5
+ *
6
+ * @module router/core/IframeRouteManager
7
+ * @author Art Design Pro Team
8
+ */
9
+
10
+ import type { AppRouteRecord } from '@/types/router'
11
+
12
+ export class IframeRouteManager {
13
+ private static instance: IframeRouteManager
14
+ private iframeRoutes: AppRouteRecord[] = []
15
+
16
+ private constructor() {}
17
+
18
+ static getInstance(): IframeRouteManager {
19
+ if (!IframeRouteManager.instance) {
20
+ IframeRouteManager.instance = new IframeRouteManager()
21
+ }
22
+ return IframeRouteManager.instance
23
+ }
24
+
25
+ /**
26
+ * 添加 iframe 路由
27
+ */
28
+ add(route: AppRouteRecord): void {
29
+ if (!this.iframeRoutes.find((r) => r.path === route.path)) {
30
+ this.iframeRoutes.push(route)
31
+ }
32
+ }
33
+
34
+ /**
35
+ * 获取所有 iframe 路由
36
+ */
37
+ getAll(): AppRouteRecord[] {
38
+ return this.iframeRoutes
39
+ }
40
+
41
+ /**
42
+ * 根据路径查找 iframe 路由
43
+ */
44
+ findByPath(path: string): AppRouteRecord | undefined {
45
+ return this.iframeRoutes.find((route) => route.path === path)
46
+ }
47
+
48
+ /**
49
+ * 清空所有 iframe 路由
50
+ */
51
+ clear(): void {
52
+ this.iframeRoutes = []
53
+ }
54
+
55
+ /**
56
+ * 保存到 sessionStorage
57
+ */
58
+ save(): void {
59
+ if (this.iframeRoutes.length > 0) {
60
+ sessionStorage.setItem('iframeRoutes', JSON.stringify(this.iframeRoutes))
61
+ }
62
+ }
63
+
64
+ /**
65
+ * 从 sessionStorage 加载
66
+ */
67
+ load(): void {
68
+ try {
69
+ const data = sessionStorage.getItem('iframeRoutes')
70
+ if (data) {
71
+ this.iframeRoutes = JSON.parse(data)
72
+ }
73
+ } catch (error) {
74
+ console.error('[IframeRouteManager] 加载 iframe 路由失败:', error)
75
+ this.iframeRoutes = []
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,280 @@
1
+ /**
2
+ * 菜单处理器
3
+ *
4
+ * 负责菜单数据的获取、过滤和处理
5
+ *
6
+ * @module router/core/MenuProcessor
7
+ * @author Art Design Pro Team
8
+ */
9
+
10
+ import type { AppRouteRecord } from '@/types/router'
11
+ import { useUserStore } from '@/store/modules/user'
12
+ import { useAppMode } from '@/hooks/core/useAppMode'
13
+ import { navigationAdapter } from '@/adapters/navigation'
14
+ import { asyncRoutes } from '../routes/asyncRoutes'
15
+ import { RoutesAlias } from '../routesAlias'
16
+ import { formatMenuTitle } from '@/utils'
17
+
18
+ export class MenuProcessor {
19
+ /**
20
+ * 获取菜单数据
21
+ */
22
+ async getMenuList(): Promise<AppRouteRecord[]> {
23
+ const { isFrontendMode } = useAppMode()
24
+
25
+ let menuList: AppRouteRecord[]
26
+ if (isFrontendMode.value) {
27
+ menuList = await this.processFrontendMenu()
28
+ } else {
29
+ menuList = await this.processBackendMenu()
30
+ }
31
+
32
+ // 在规范化路径之前,验证原始路径配置
33
+ this.validateMenuPaths(menuList)
34
+
35
+ // 规范化路径(将相对路径转换为完整路径)
36
+ return this.normalizeMenuPaths(menuList)
37
+ }
38
+
39
+ /**
40
+ * 处理前端控制模式的菜单
41
+ */
42
+ private async processFrontendMenu(): Promise<AppRouteRecord[]> {
43
+ const userStore = useUserStore()
44
+ const roles = userStore.info?.roles
45
+
46
+ let menuList = [...asyncRoutes]
47
+
48
+ // 根据角色过滤菜单
49
+ if (roles && roles.length > 0) {
50
+ menuList = this.filterMenuByRoles(menuList, roles)
51
+ }
52
+
53
+ return this.filterEmptyMenus(menuList)
54
+ }
55
+
56
+ /**
57
+ * 处理后端控制模式的菜单
58
+ */
59
+ private async processBackendMenu(): Promise<AppRouteRecord[]> {
60
+ const list = await navigationAdapter.getMenuList()
61
+ return this.filterEmptyMenus(list)
62
+ }
63
+
64
+ /**
65
+ * 根据角色过滤菜单
66
+ */
67
+ private filterMenuByRoles(menu: AppRouteRecord[], roles: string[]): AppRouteRecord[] {
68
+ return menu.reduce((acc: AppRouteRecord[], item) => {
69
+ const itemRoles = item.meta?.roles
70
+ const hasPermission = !itemRoles || itemRoles.some((role) => roles?.includes(role))
71
+
72
+ if (hasPermission) {
73
+ const filteredItem = { ...item }
74
+ if (filteredItem.children?.length) {
75
+ filteredItem.children = this.filterMenuByRoles(filteredItem.children, roles)
76
+ }
77
+ acc.push(filteredItem)
78
+ }
79
+
80
+ return acc
81
+ }, [])
82
+ }
83
+
84
+ /**
85
+ * 递归过滤空菜单项
86
+ */
87
+ private filterEmptyMenus(menuList: AppRouteRecord[]): AppRouteRecord[] {
88
+ return menuList
89
+ .map((item) => {
90
+ // 如果有子菜单,先递归过滤子菜单
91
+ if (item.children && item.children.length > 0) {
92
+ const filteredChildren = this.filterEmptyMenus(item.children)
93
+ return {
94
+ ...item,
95
+ children: filteredChildren
96
+ }
97
+ }
98
+ return item
99
+ })
100
+ .filter((item) => {
101
+ // 如果定义了 children 属性(即使是空数组),说明这是一个目录菜单,应该保留
102
+ if ('children' in item) {
103
+ return true
104
+ }
105
+
106
+ // 如果有外链或 iframe,保留
107
+ if (item.meta?.isIframe === true || item.meta?.link) {
108
+ return true
109
+ }
110
+
111
+ // 如果有有效的 component,保留
112
+ if (item.component && item.component !== '' && item.component !== RoutesAlias.Layout) {
113
+ return true
114
+ }
115
+
116
+ // 其他情况过滤掉
117
+ return false
118
+ })
119
+ }
120
+
121
+ /**
122
+ * 验证菜单列表是否有效
123
+ */
124
+ validateMenuList(menuList: AppRouteRecord[]): boolean {
125
+ return Array.isArray(menuList) && menuList.length > 0
126
+ }
127
+
128
+ /**
129
+ * 规范化菜单路径
130
+ * 将相对路径转换为完整路径,确保菜单跳转正确
131
+ */
132
+ private normalizeMenuPaths(menuList: AppRouteRecord[], parentPath = ''): AppRouteRecord[] {
133
+ return menuList.map((item) => {
134
+ // 构建完整路径
135
+ const fullPath = this.buildFullPath(item.path || '', parentPath)
136
+
137
+ // 递归处理子菜单
138
+ const children = item.children?.length
139
+ ? this.normalizeMenuPaths(item.children, fullPath)
140
+ : item.children
141
+
142
+ const redirect = item.redirect || this.resolveDefaultRedirect(children)
143
+
144
+ return {
145
+ ...item,
146
+ path: fullPath,
147
+ redirect,
148
+ children
149
+ }
150
+ })
151
+ }
152
+
153
+ /**
154
+ * 为目录型菜单推导默认跳转地址
155
+ */
156
+ private resolveDefaultRedirect(children?: AppRouteRecord[]): string | undefined {
157
+ if (!children?.length) {
158
+ return undefined
159
+ }
160
+
161
+ for (const child of children) {
162
+ if (this.isNavigableRoute(child)) {
163
+ return child.path
164
+ }
165
+
166
+ const nestedRedirect = this.resolveDefaultRedirect(child.children)
167
+ if (nestedRedirect) {
168
+ return nestedRedirect
169
+ }
170
+ }
171
+
172
+ return undefined
173
+ }
174
+
175
+ /**
176
+ * 判断子路由是否可以作为默认落点
177
+ */
178
+ private isNavigableRoute(route: AppRouteRecord): boolean {
179
+ return Boolean(
180
+ route.path &&
181
+ route.path !== '/' &&
182
+ !route.meta?.link &&
183
+ route.meta?.isIframe !== true &&
184
+ route.component &&
185
+ route.component !== ''
186
+ )
187
+ }
188
+
189
+ /**
190
+ * 验证菜单路径配置
191
+ * 检测非一级菜单是否错误使用了 / 开头的路径
192
+ */
193
+ /**
194
+ * 验证菜单路径配置
195
+ * 检测非一级菜单是否错误使用了 / 开头的路径
196
+ */
197
+ private validateMenuPaths(menuList: AppRouteRecord[], level = 1): void {
198
+ menuList.forEach((route) => {
199
+ if (!route.children?.length) return
200
+
201
+ const parentName = String(route.name || route.path || '未知路由')
202
+
203
+ route.children.forEach((child) => {
204
+ const childPath = child.path || ''
205
+
206
+ // 跳过合法的绝对路径:外部链接和 iframe 路由
207
+ if (this.isValidAbsolutePath(childPath)) return
208
+
209
+ // 检测非法的绝对路径
210
+ if (childPath.startsWith('/')) {
211
+ this.logPathError(child, childPath, parentName, level)
212
+ }
213
+ })
214
+
215
+ // 递归检查更深层级的子路由
216
+ this.validateMenuPaths(route.children, level + 1)
217
+ })
218
+ }
219
+
220
+ /**
221
+ * 判断是否为合法的绝对路径
222
+ */
223
+ private isValidAbsolutePath(path: string): boolean {
224
+ return (
225
+ path.startsWith('http://') ||
226
+ path.startsWith('https://') ||
227
+ path.startsWith('/outside/iframe/')
228
+ )
229
+ }
230
+
231
+ /**
232
+ * 输出路径配置错误日志
233
+ */
234
+ private logPathError(
235
+ route: AppRouteRecord,
236
+ path: string,
237
+ parentName: string,
238
+ level: number
239
+ ): void {
240
+ const routeName = String(route.name || path || '未知路由')
241
+ const menuTitle = route.meta?.title || routeName
242
+ const suggestedPath = path.split('/').pop() || path.slice(1)
243
+
244
+ console.error(
245
+ `[路由配置错误] 菜单 "${formatMenuTitle(menuTitle)}" (name: ${routeName}, path: ${path}) 配置错误\n` +
246
+ ` 位置: ${parentName} > ${routeName}\n` +
247
+ ` 问题: ${level + 1}级菜单的 path 不能以 / 开头\n` +
248
+ ` 当前配置: path: '${path}'\n` +
249
+ ` 应该改为: path: '${suggestedPath}'`
250
+ )
251
+ }
252
+
253
+ /**
254
+ * 构建完整路径
255
+ */
256
+ private buildFullPath(path: string, parentPath: string): string {
257
+ if (!path) return ''
258
+
259
+ // 外部链接直接返回
260
+ if (path.startsWith('http://') || path.startsWith('https://')) {
261
+ return path
262
+ }
263
+
264
+ // 如果已经是绝对路径,直接返回
265
+ if (path.startsWith('/')) {
266
+ return path
267
+ }
268
+
269
+ // 拼接父路径和当前路径
270
+ if (parentPath) {
271
+ // 移除父路径末尾的斜杠,移除子路径开头的斜杠,然后拼接
272
+ const cleanParent = parentPath.replace(/\/$/, '')
273
+ const cleanChild = path.replace(/^\//, '')
274
+ return `${cleanParent}/${cleanChild}`
275
+ }
276
+
277
+ // 没有父路径,添加前导斜杠
278
+ return `/${path}`
279
+ }
280
+ }
@@ -0,0 +1,161 @@
1
+ /**
2
+ * 路由权限验证模块
3
+ *
4
+ * 提供路由权限验证和路径检查功能
5
+ *
6
+ * ## 主要功能
7
+ *
8
+ * - 验证路径是否在用户菜单权限中
9
+ * - 构建菜单路径集合(扁平化处理)
10
+ * - 支持动态路由参数匹配
11
+ * - 路径前缀匹配
12
+ *
13
+ * ## 使用场景
14
+ *
15
+ * - 路由守卫中验证用户权限
16
+ * - 动态路由注册后的权限检查
17
+ * - 防止用户访问无权限的页面
18
+ *
19
+ * @module router/core/RoutePermissionValidator
20
+ * @author Art Design Pro Team
21
+ */
22
+
23
+ import type { AppRouteRecord } from '@/types/router'
24
+
25
+ /**
26
+ * 路由权限验证器
27
+ */
28
+ export class RoutePermissionValidator {
29
+ /**
30
+ * 验证路径是否在用户菜单权限中
31
+ * @param targetPath 目标路径
32
+ * @param menuList 菜单列表
33
+ * @returns 是否有权限访问
34
+ */
35
+ static hasPermission(targetPath: string, menuList: AppRouteRecord[]): boolean {
36
+ // 根路径始终允许访问
37
+ if (targetPath === '/') {
38
+ return true
39
+ }
40
+
41
+ return this.matchRoute(targetPath, menuList)
42
+ }
43
+
44
+ /**
45
+ * 构建菜单路径集合(扁平化处理)
46
+ * @param menuList 菜单列表
47
+ * @param pathSet 路径集合
48
+ * @returns 路径集合
49
+ */
50
+ static buildMenuPathSet(
51
+ menuList: AppRouteRecord[],
52
+ pathSet: Set<string> = new Set()
53
+ ): Set<string> {
54
+ if (!Array.isArray(menuList) || menuList.length === 0) {
55
+ return pathSet
56
+ }
57
+
58
+ for (const menuItem of menuList) {
59
+ if (!menuItem.path) {
60
+ continue
61
+ }
62
+
63
+ // 标准化路径并添加到集合
64
+ const menuPath = menuItem.path.startsWith('/') ? menuItem.path : `/${menuItem.path}`
65
+ pathSet.add(menuPath)
66
+
67
+ // 递归处理子菜单
68
+ if (menuItem.children?.length) {
69
+ this.buildMenuPathSet(menuItem.children, pathSet)
70
+ }
71
+ }
72
+
73
+ return pathSet
74
+ }
75
+
76
+ /**
77
+ * 检查目标路径是否匹配集合中的某个路径前缀
78
+ * 用于支持动态路由参数匹配,如 /user/123 匹配 /user
79
+ * @param targetPath 目标路径
80
+ * @param pathSet 路径集合
81
+ * @returns 是否匹配
82
+ */
83
+ static checkPathPrefix(targetPath: string, pathSet: Set<string>): boolean {
84
+ // 遍历路径集合,检查是否有前缀匹配
85
+ for (const menuPath of pathSet) {
86
+ if (targetPath.startsWith(`${menuPath}/`)) {
87
+ return true
88
+ }
89
+ }
90
+ return false
91
+ }
92
+
93
+ /**
94
+ * 递归匹配路由配置,支持隐藏路由和动态参数路由
95
+ */
96
+ static matchRoute(targetPath: string, routes: AppRouteRecord[]): boolean {
97
+ if (!Array.isArray(routes) || routes.length === 0) {
98
+ return false
99
+ }
100
+
101
+ for (const route of routes) {
102
+ if (!route.path) {
103
+ continue
104
+ }
105
+
106
+ const routePath = route.path.startsWith('/') ? route.path : `/${route.path}`
107
+
108
+ if (
109
+ routePath === targetPath ||
110
+ this.isDynamicRouteMatch(targetPath, routePath) ||
111
+ targetPath.startsWith(`${routePath}/`)
112
+ ) {
113
+ return true
114
+ }
115
+
116
+ if (route.children?.length && this.matchRoute(targetPath, route.children)) {
117
+ return true
118
+ }
119
+ }
120
+
121
+ return false
122
+ }
123
+
124
+ /**
125
+ * 检查目标路径是否匹配动态参数路由,如 /demo/123 匹配 /demo/:id
126
+ */
127
+ static isDynamicRouteMatch(targetPath: string, routePath: string): boolean {
128
+ if (!routePath.includes(':')) {
129
+ return false
130
+ }
131
+
132
+ const pattern = routePath
133
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
134
+ .replace(/:([^/]+)/g, '[^/]+')
135
+ .replace(/\\\*/g, '.*')
136
+
137
+ return new RegExp(`^${pattern}$`).test(targetPath)
138
+ }
139
+
140
+ /**
141
+ * 验证并返回有效的路径
142
+ * 如果目标路径无权限,返回首页路径
143
+ * @param targetPath 目标路径
144
+ * @param menuList 菜单列表
145
+ * @param homePath 首页路径
146
+ * @returns 验证后的路径
147
+ */
148
+ static validatePath(
149
+ targetPath: string,
150
+ menuList: AppRouteRecord[],
151
+ homePath: string = '/'
152
+ ): { path: string; hasPermission: boolean } {
153
+ const hasPermission = this.hasPermission(targetPath, menuList)
154
+
155
+ if (hasPermission) {
156
+ return { path: targetPath, hasPermission: true }
157
+ }
158
+
159
+ return { path: homePath, hasPermission: false }
160
+ }
161
+ }