@pubinfo/core 2.0.0-rc.2 → 2.0.0-rc.4

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 (133) hide show
  1. package/dist/{AppSetting-D2RJrc9O.js → AppSetting-BI-oNc4e.js} +19 -19
  2. package/dist/{HCheckList.vue_vue_type_script_setup_true_lang-DusVz35O.js → HCheckList.vue_vue_type_script_setup_true_lang-BdLpkcoh.js} +1 -1
  3. package/dist/{HToggle-DMcVgMVY.js → HToggle-DxdWLgp-.js} +1 -1
  4. package/dist/{PreferencesContent-Dtd9rtew.js → PreferencesContent-CCYkZeCT.js} +52 -52
  5. package/dist/{SettingBreadcrumb-QSCSviKM.js → SettingBreadcrumb-BTyfiy4k.js} +5 -5
  6. package/dist/{SettingCopyright-Dr5P6yfq.js → SettingCopyright-g6UHi8pZ.js} +2 -2
  7. package/dist/{SettingEnableTransition-DGiHEbCI.js → SettingEnableTransition-Ci-5bhbR.js} +12 -12
  8. package/dist/{SettingHome-CEPcBlds.js → SettingHome-K4Iel0Hr.js} +8 -8
  9. package/dist/{SettingMenu-BJdjnRA6.js → SettingMenu-BYLWzA5i.js} +14 -14
  10. package/dist/{SettingMode-BnuCHoEY.js → SettingMode-tRisyKtg.js} +3 -3
  11. package/dist/{SettingNavSearch-CiU4BmlU.js → SettingNavSearch-CSM6mPf8.js} +6 -6
  12. package/dist/{SettingOther-DTHjVlFe.js → SettingOther-Bj5KF_vC.js} +11 -11
  13. package/dist/{SettingPage-D75_Nf05.js → SettingPage-CFjmrVI7.js} +2 -2
  14. package/dist/{SettingTabbar-D48dzvgA.js → SettingTabbar-uFYiaZhK.js} +13 -13
  15. package/dist/{SettingThemes-D-8vTs5n.js → SettingThemes-C-tMq9o5.js} +12 -12
  16. package/dist/{SettingToolbar-DjIjm9V-.js → SettingToolbar-BfDzijNU.js} +10 -10
  17. package/dist/{SettingTopbar-Cg30OTH3.js → SettingTopbar-DTDv4NXD.js} +6 -6
  18. package/dist/{SettingWidthMode-BKV_7kb8.js → SettingWidthMode-PkiwrHe3.js} +11 -11
  19. package/dist/{TopThinMode-JFYsp_lJ.js → TopThinMode-BrvA8pV0.js} +3 -3
  20. package/dist/built-in/authentication/alova/helper.d.ts +34 -0
  21. package/dist/built-in/authentication/alova/token.d.ts +16 -0
  22. package/dist/built-in/authentication/helper.d.ts +10 -1
  23. package/dist/built-in/index.d.ts +0 -1
  24. package/dist/built-in/layout-component/Layout.vue.d.ts +1 -0
  25. package/dist/built-in/layout-component/components/Tools/Fullscreen.vue.d.ts +2 -0
  26. package/dist/built-in/layout-component/components/Tools/PageReload.vue.d.ts +2 -0
  27. package/dist/built-in/layout-component/components/Tools/SearchBar.vue.d.ts +2 -0
  28. package/dist/built-in/layout-component/components/Tools/index.vue.d.ts +47 -1
  29. package/dist/built-in/layout-component/components/Tools/interface.d.ts +26 -0
  30. package/dist/built-in/layout-component/components/ui/HDropdownMenu.vue.d.ts +2 -7
  31. package/dist/built-in/layout-component/components/ui/HSlideover.vue.d.ts +1 -1
  32. package/dist/built-in/layout-component/composables/useContext.d.ts +1 -1
  33. package/dist/built-in/layout-component/composables/useHotkey.d.ts +1 -5
  34. package/dist/built-in/layout-component/composables/useMainPage.d.ts +1 -1
  35. package/dist/built-in/layout-component/composables/useMenu.d.ts +1 -1
  36. package/dist/built-in/layout-component/composables/useTabbar.d.ts +1 -1
  37. package/dist/built-in/layout-component/composables/useTitle.d.ts +3 -2
  38. package/dist/built-in/layout-component/composables/useWatermark.d.ts +3 -1
  39. package/dist/built-in/layout-component/index.d.ts +9 -6
  40. package/dist/built-in/layout-component/utils/index.d.ts +0 -1
  41. package/dist/{colors-CODcBxrF.js → colors-VoaDbOhe.js} +1 -1
  42. package/dist/core/interface.d.ts +14 -5
  43. package/dist/core/request.d.ts +2 -8
  44. package/dist/features/api/modules/auth/renzhengfuwu.d.ts +8 -8
  45. package/dist/features/api/modules/configData/heibaimingdanfuwu.d.ts +5 -5
  46. package/dist/features/api/modules/configData/xitongpeizhifuwu.d.ts +14 -14
  47. package/dist/features/api/modules/configData/zidifuwu.d.ts +10 -10
  48. package/dist/features/api/modules/rbac/gangweijiekou.d.ts +6 -6
  49. package/dist/features/api/modules/rbac/jiaosejiekou.d.ts +7 -7
  50. package/dist/features/api/modules/rbac/pubJiaosezukongzhiqi.d.ts +7 -7
  51. package/dist/features/api/modules/rbac/shujuquanxianzhubiaokongzhiqi.d.ts +9 -9
  52. package/dist/features/api/modules/rbac/yonghujiekou.d.ts +15 -15
  53. package/dist/features/api/modules/rbac/yonghushoucangbiaojiekou.d.ts +5 -5
  54. package/dist/features/api/modules/rbac/yonghuzuijinchangyongbiaojiekou.d.ts +4 -4
  55. package/dist/features/api/modules/rbac/ziyuanjiekou.d.ts +13 -13
  56. package/dist/features/api/modules/rbac/zuhuguanlijiekou.d.ts +5 -5
  57. package/dist/features/api/modules/rbac/zuzhijiaosebiaokongzhiqi.d.ts +4 -4
  58. package/dist/features/api/modules/rbac/zuzhijiekou.d.ts +9 -9
  59. package/dist/features/api/system/user.d.ts +4 -4
  60. package/dist/{index-RT-QBzm0.js → index-BSevJVD5.js} +10 -15
  61. package/dist/{index-BVLkBCRY.js → index-BfGqLWFB.js} +6418 -6439
  62. package/dist/{index-DQn1WFMa.js → index-CYoFRwvw.js} +2 -2
  63. package/dist/{index-DmcblkoZ.js → index-ConeY38N.js} +13 -13
  64. package/dist/{index-BAoB7aoj.js → index-DV3hkzKA.js} +1 -1
  65. package/dist/{index-D4_xmL_A.js → index-Ddw98rJ5.js} +25 -25
  66. package/dist/{index-DvJr0paY.js → index-DrC787X_.js} +2 -2
  67. package/dist/{index-BROqFYXS.js → index-Dv9ndBoi.js} +1 -1
  68. package/dist/{index-Jd3PYkpj.js → index-IAYhIBQH.js} +16815 -16694
  69. package/dist/index.d.ts +4 -2
  70. package/dist/index.js +53 -55
  71. package/dist/{pick-BLJM77QN.js → pick-vpv9EEvu.js} +1 -1
  72. package/dist/style.css +1 -1
  73. package/package.json +11 -11
  74. package/src/built-in/authentication/alova/helper.ts +158 -0
  75. package/src/built-in/authentication/alova/token.ts +122 -0
  76. package/src/built-in/authentication/helper.ts +7 -3
  77. package/src/built-in/authentication/index.ts +6 -20
  78. package/src/built-in/index.ts +0 -1
  79. package/src/built-in/layout-component/Layout.vue +11 -22
  80. package/src/built-in/layout-component/components/Header/TopMode/index.vue +4 -4
  81. package/src/built-in/layout-component/components/Menu/item.vue +3 -3
  82. package/src/built-in/layout-component/components/Sidebar/MainSidebar.vue +4 -4
  83. package/src/built-in/layout-component/components/Sidebar/index.vue +1 -1
  84. package/src/built-in/layout-component/components/Tools/DarkModeToggle.vue +108 -0
  85. package/src/built-in/layout-component/components/Tools/Fullscreen.vue +24 -0
  86. package/src/built-in/layout-component/components/Tools/PageReload.vue +22 -0
  87. package/src/built-in/layout-component/components/Tools/SearchBar.vue +42 -0
  88. package/src/built-in/layout-component/components/Tools/{Search.vue → SearchPanel.vue} +13 -21
  89. package/src/built-in/layout-component/components/Tools/index.vue +71 -142
  90. package/src/built-in/layout-component/components/Tools/interface.ts +27 -0
  91. package/src/built-in/layout-component/components/Topbar/Tabbar/MoreAction.vue +9 -12
  92. package/src/built-in/layout-component/components/Topbar/Tabbar/index.vue +12 -15
  93. package/src/built-in/layout-component/components/Topbar/Toolbar/Favorites.vue +4 -7
  94. package/src/built-in/layout-component/components/Topbar/Toolbar/index.vue +6 -6
  95. package/src/built-in/layout-component/components/ui/HDropdownMenu.vue +19 -26
  96. package/src/built-in/layout-component/composables/useContext.ts +1 -1
  97. package/src/built-in/layout-component/composables/useGetComputedStyle.ts +2 -3
  98. package/src/built-in/layout-component/composables/useHotkey.ts +6 -10
  99. package/src/built-in/layout-component/composables/useMainPage.ts +5 -6
  100. package/src/built-in/layout-component/composables/useMenu.ts +3 -5
  101. package/src/built-in/layout-component/composables/useTabbar.ts +3 -5
  102. package/src/built-in/layout-component/composables/useTitle.ts +10 -17
  103. package/src/built-in/layout-component/composables/useWatermark.ts +25 -12
  104. package/src/built-in/layout-component/index.ts +21 -12
  105. package/src/built-in/layout-component/provider.ts +7 -3
  106. package/src/built-in/layout-component/utils/index.ts +0 -1
  107. package/src/built-in/settings/router.ts +5 -1
  108. package/src/core/interface.ts +18 -5
  109. package/src/core/request.ts +35 -15
  110. package/src/features/router/systemRoutes.ts +0 -1
  111. package/src/features/stores/modules/favorites.ts +0 -1
  112. package/src/features/stores/modules/route.ts +2 -9
  113. package/src/features/stores/modules/tabbar.ts +0 -3
  114. package/src/features/stores/utils/routerHelper.ts +38 -4
  115. package/src/index.ts +7 -11
  116. package/types/vue-router.d.ts +0 -3
  117. package/dist/built-in/layout-component/utils/eventBus.d.ts +0 -5
  118. package/dist/built-in/locales/helpler.d.ts +0 -594
  119. package/dist/built-in/locales/index.d.ts +0 -5
  120. package/dist/built-in/locales/lang/en.json.d.ts +0 -99
  121. package/dist/built-in/locales/lang/zh-cn.json.d.ts +0 -100
  122. package/dist/built-in/locales/lang/zh-tw.json.d.ts +0 -100
  123. package/dist/built-in/locales/ui.d.ts +0 -3
  124. package/src/built-in/layout-component/components/Tools/DayNightSwitch.vue +0 -70
  125. package/src/built-in/layout-component/utils/eventBus.ts +0 -8
  126. package/src/built-in/locales/helpler.ts +0 -76
  127. package/src/built-in/locales/index.ts +0 -20
  128. package/src/built-in/locales/lang/en.json +0 -96
  129. package/src/built-in/locales/lang/zh-cn.json +0 -97
  130. package/src/built-in/locales/lang/zh-tw.json +0 -97
  131. package/src/built-in/locales/ui.ts +0 -3
  132. /package/dist/built-in/layout-component/components/Tools/{DayNightSwitch.vue.d.ts → DarkModeToggle.vue.d.ts} +0 -0
  133. /package/dist/built-in/layout-component/components/Tools/{Search.vue.d.ts → SearchPanel.vue.d.ts} +0 -0
@@ -106,7 +106,11 @@ function hitCache(
106
106
  cache?: RouterMetaRawBaseOptions['cache'],
107
107
  noCache?: RouterMetaRawBaseOptions['noCache'],
108
108
  ) {
109
- return cache && matched(name, cache) && !matched(name, noCache);
109
+ if (typeof cache === 'boolean') {
110
+ return cache && !matched(name, noCache);
111
+ }
112
+
113
+ return matched(name, cache) && !matched(name, noCache);
110
114
  }
111
115
 
112
116
  function matched(
@@ -1,5 +1,5 @@
1
1
  import type { AdapterCreateOptions, AlovaAxiosRequestConfig } from '@alova/adapter-axios';
2
- import type { Alova, AlovaGenerics, AlovaOptions, Method } from 'alova';
2
+ import type { Alova, AlovaGenerics, AlovaOptions, Method, ResponseCompleteHandler, ResponseErrorHandler } from 'alova';
3
3
  import type { AxiosResponse, AxiosResponseHeaders } from 'axios';
4
4
  import type { Pinia } from 'pinia';
5
5
  import type { App, Component } from 'vue';
@@ -77,13 +77,26 @@ export type FalsyModule = false | null | undefined;
77
77
 
78
78
  export type ModuleOptions = Module | ModuleOptions[] | FalsyModule;
79
79
 
80
- type AG = AlovaGenerics<any, any, AlovaAxiosRequestConfig, AxiosResponse<any, any>, AxiosResponseHeaders, any, any, any>;
80
+ export type AG = AlovaGenerics<any, any, AlovaAxiosRequestConfig, AxiosResponse<any, any>, AxiosResponseHeaders, any, any, any>;
81
81
 
82
- export type RequestOptions = Omit<AlovaOptions<AG>, 'statesHook' | 'requestAdapter'> & { axios?: AdapterCreateOptions };
82
+ export type RequestOptions = Omit<AlovaOptions<AG>, 'statesHook' | 'requestAdapter' | 'beforeRequest' | 'responded'> & {
83
+ axios?: AdapterCreateOptions
84
+ beforeRequest?: Hooks['http:request']
85
+ responded?: Hooks['http:response']
86
+ };
83
87
  export type RequestInstance = Alova<AG>;
84
88
  export type RequestMethod = Method<AG>;
85
89
 
86
90
  export interface Hooks {
87
- 'http:request': AlovaOptions<AG>['beforeRequest']
88
- 'http:response': AlovaOptions<AG>['responded']
91
+ 'http:request': (method: Method<AG>) => void | Promise<void>
92
+ 'http:response': RespondedHandler<AG> | RespondedHandlerRecord<AG>
93
+ }
94
+
95
+ // overwrite alova
96
+ type Fn = () => void;
97
+ export type RespondedHandler<AG extends AlovaGenerics> = (response: AG['Response'], methodInstance: Method<AG>, stop: Fn) => any;
98
+ export interface RespondedHandlerRecord<AG extends AlovaGenerics> {
99
+ onSuccess?: RespondedHandler<AG>
100
+ onError?: ResponseErrorHandler<AG>
101
+ onComplete?: ResponseCompleteHandler<AG>
89
102
  }
@@ -1,8 +1,8 @@
1
+ import type { AxiosResponse } from 'axios';
1
2
  import type { RequestOptions } from './interface';
2
3
  import { axiosRequestAdapter } from '@alova/adapter-axios';
3
4
  import { createAlova } from 'alova';
4
5
  import vueHook from 'alova/vue';
5
- import { createTokenAuthentication } from '@/built-in';
6
6
  import { hooks } from './ctx';
7
7
 
8
8
  function normalizedResponded(handler: RequestOptions['responded']) {
@@ -12,9 +12,13 @@ function normalizedResponded(handler: RequestOptions['responded']) {
12
12
  return handler;
13
13
  }
14
14
 
15
- export function createRequest(options: RequestOptions) {
16
- const { onAuthRequired, onResponseRefreshToken } = createTokenAuthentication();
17
- const { axios, beforeRequest, responded: _responded, ...restOptions } = options;
15
+ export function createRequest(options: RequestOptions = {}) {
16
+ const {
17
+ axios,
18
+ beforeRequest,
19
+ responded: _responded,
20
+ ...restOptions
21
+ } = options;
18
22
 
19
23
  const responded = normalizedResponded(_responded);
20
24
 
@@ -25,25 +29,41 @@ export function createRequest(options: RequestOptions) {
25
29
  timeout: 60 * 1000,
26
30
  ...restOptions,
27
31
 
28
- beforeRequest: onAuthRequired(async (method) => {
32
+ beforeRequest: async (method) => {
29
33
  await hooks.callHook('http:request', method);
30
34
  await beforeRequest?.(method);
31
- }),
35
+ },
32
36
 
33
- responded: onResponseRefreshToken({
37
+ responded: {
34
38
  onSuccess: async (response, method) => {
35
- const res = await hooks.callHook('http:response:onSuccess', response, method) ?? response;
36
- return responded?.onSuccess?.(res, method) ?? res;
39
+ let stopped = false;
40
+
41
+ const res = await hooks.callHookWith(
42
+ async (hookFns, args) => {
43
+ let _response = args[0];
44
+ for (const fn of hookFns) {
45
+ if (stopped) {
46
+ break;
47
+ }
48
+ _response = await fn(_response, method, () => stopped = true);
49
+ }
50
+ return _response;
51
+ },
52
+ 'http:response:onSuccess',
53
+ response,
54
+ ) as AxiosResponse<any, any>;
55
+
56
+ return stopped ? res : (responded?.onSuccess?.(res, method, () => stopped = true) ?? res);
37
57
  },
38
- onError: (err, method) => {
39
- hooks.callHook('http:response:onError', err, method);
40
- responded?.onError?.(err, method);
58
+ onError: async (err, method) => {
59
+ await hooks.callHook('http:response:onError', err, method);
60
+ return responded?.onError?.(err, method);
41
61
  },
42
- onComplete: (method) => {
43
- hooks.callHook('http:response:onComplete', method);
62
+ onComplete: async (method) => {
63
+ await hooks.callHook('http:response:onComplete', method);
44
64
  responded?.onComplete?.(method);
45
65
  },
46
- }),
66
+ },
47
67
  });
48
68
 
49
69
  return instance;
@@ -18,7 +18,6 @@ const systemRoutes: RouteRecordRaw[] = [
18
18
  component: () => import('@/features/pages/profile/index.vue'),
19
19
  meta: {
20
20
  title: '个人中心',
21
- i18n: 'route.personal.profile',
22
21
  icon: 'i-iconamoon-profile-duotone',
23
22
  },
24
23
  },
@@ -113,7 +113,6 @@ const useFavoritesStore = defineStore(
113
113
  list.value.push({
114
114
  fullPath: route.fullPath,
115
115
  title: meta?.title,
116
- i18n: meta?.i18n,
117
116
  icon: meta?.icon ?? meta?.breadcrumbNeste?.findLast(item => item.icon)?.icon,
118
117
  });
119
118
  }
@@ -40,12 +40,11 @@ const useRouteStore = defineStore(
40
40
  * @returns 面包屑对象
41
41
  */
42
42
  function createBreadcrumb(currentRouter: RouteRecordRaw, baseUrl?: RouteRecordRaw['path']): Route.breadcrumb {
43
- const { title, i18n, icon, activeIcon, breadcrumb = true } = defaultTo(currentRouter.meta, {} as RouteMeta);
43
+ const { title, icon, activeIcon, breadcrumb = true } = defaultTo(currentRouter.meta, {} as RouteMeta);
44
44
  const path = defaultTo(baseUrl, currentRouter.path);
45
45
  return {
46
46
  path,
47
47
  title,
48
- i18n,
49
48
  icon,
50
49
  activeIcon,
51
50
  hide: !breadcrumb,
@@ -163,7 +162,6 @@ const useRouteStore = defineStore(
163
162
 
164
163
  if (routesRaw.value.length) {
165
164
  routesRaw.value.forEach((item) => {
166
- // CLOSE: 开发模式应用的子路由不应该被扁平化到vue-router中
167
165
  // 开发模式应用只在TopMode中显示,点击时显示开发状态
168
166
  if (get(item, 'meta.isDev', false)) {
169
167
  useWarn(`开发模式应用"${item.meta?.title}"的子路由将不会被注册到vue-router中`);
@@ -304,7 +302,6 @@ const useRouteStore = defineStore(
304
302
  component: item.component,
305
303
  meta: {
306
304
  title: item.meta.title,
307
- i18n: item.meta.i18n,
308
305
  sidebar: false,
309
306
  breadcrumb: false,
310
307
  },
@@ -364,7 +361,6 @@ const useRouteStore = defineStore(
364
361
  // 将本地应用替换成静态路由
365
362
  if (route.type === RESOURCE_TYPE.APP) {
366
363
  const foundStaticRoute = staticRoutes.find(staticRoute => staticRoute.meta?.auth === route.code);
367
- // CLOSE: 静态应用如果是开发模式,仍然要返回路由对象供TopMode显示
368
364
  // 但其子路由不会被注册到vue-router中,这由菜单系统和路由扁平化逻辑处理
369
365
  if (foundStaticRoute && get(foundStaticRoute, 'meta.isDev', false)) {
370
366
  useWarn(`静态应用"${foundStaticRoute.meta?.title}"处于开发模式,将在TopMode中显示开发状态`);
@@ -374,10 +370,10 @@ const useRouteStore = defineStore(
374
370
 
375
371
  // 将动态应用数据格式化成路由数据
376
372
  if (route.type === RESOURCE_TYPE.DYNAMIC_APP) {
377
- // CLOSE: 动态应用如果是开发模式,仍然要返回路由对象供TopMode显示
378
373
  if (route.meta?.isDev) {
379
374
  useWarn(`动态应用"${route.name}"处于开发模式,将在TopMode中显示开发状态`);
380
375
  }
376
+
381
377
  return formatBackRoutes([route])[0] as any;
382
378
  }
383
379
 
@@ -400,9 +396,6 @@ const useRouteStore = defineStore(
400
396
  }
401
397
  });
402
398
 
403
- // FIX-ME routesRaw 最终会被 routes 使用,在 menuStore 中作为生成 allMenus 的数据源。
404
- // 为了解决这个问题,我们需要重构一下逻辑,想办法将 路由 和 菜单 分开处理。
405
- // 可以考虑直接让 menuStore 的菜单根据 remoteRoutesRaw 生成。
406
399
  routesRaw.value = [...remoteRoutes, ...restStaticRoutes];
407
400
  }
408
401
 
@@ -37,7 +37,6 @@ const useTabbarStore = defineStore(
37
37
  routeName: route.name,
38
38
  activeMenu: route.meta.activeMenu,
39
39
  title: typeof route.meta.title === 'function' ? route.meta.title() : route.meta.title,
40
- i18n: route.meta.i18n,
41
40
  iframe: route.meta.iframe,
42
41
  icon: route.meta?.icon ?? route.meta?.breadcrumbNeste?.findLast(item => item.icon)?.icon,
43
42
  activeIcon: route.meta?.activeIcon ?? route.meta?.breadcrumbNeste?.findLast(item => item.activeIcon)?.activeIcon,
@@ -95,7 +94,6 @@ const useTabbarStore = defineStore(
95
94
  routeName: route.name!,
96
95
  activeMenu: meta?.activeMenu,
97
96
  title: typeof meta?.title === 'function' ? meta.title() : meta?.title,
98
- i18n: meta?.i18n,
99
97
  iframe: meta?.iframe,
100
98
  icon: meta?.icon ?? meta?.breadcrumbNeste?.findLast(item => item.icon)?.icon,
101
99
  activeIcon: meta?.activeIcon ?? meta?.breadcrumbNeste?.findLast(item => item.activeIcon)?.activeIcon,
@@ -121,7 +119,6 @@ const useTabbarStore = defineStore(
121
119
  findTab.routeName = route.name!;
122
120
  findTab.activeMenu = meta?.activeMenu;
123
121
  findTab.title = typeof meta?.title === 'function' ? meta.title() : meta?.title;
124
- findTab.i18n = meta?.i18n;
125
122
  findTab.iframe = meta?.iframe;
126
123
  findTab.icon = meta?.icon ?? meta?.breadcrumbNeste?.findLast(item => item.icon)?.icon;
127
124
  findTab.activeIcon = meta?.activeIcon ?? meta?.breadcrumbNeste?.findLast(item => item.activeIcon)?.activeIcon;
@@ -1,6 +1,6 @@
1
1
  import type { RouterMetaRawBaseOptions } from '#/vue-router';
2
2
  import type { RequireExactlyOne } from 'type-fest';
3
- import { cloneDeep, isUndefined, omitBy } from 'lodash-es';
3
+ import { cloneDeep, isEmpty, isUndefined, omitBy } from 'lodash-es';
4
4
  import { setupDefaultLayout, setupPage } from '@/core';
5
5
  import { RESOURCE_TYPE } from '@/features/enum';
6
6
 
@@ -26,7 +26,7 @@ export function formatBackRoutes(
26
26
  ): BackEndRoute[] {
27
27
  const backEndRoutes = filterRoutes(routes, [RESOURCE_TYPE.BUTTON]);
28
28
 
29
- return backEndRoutes.map((route: API.PubResourceTreeBo) => {
29
+ const formatRoutes = backEndRoutes.map((route: API.PubResourceTreeBo) => {
30
30
  const children = route?.children && route.children.length > 0
31
31
  ? formatBackRoutes(route.children, route)
32
32
  : [];
@@ -37,7 +37,6 @@ export function formatBackRoutes(
37
37
  icon: route?.icon,
38
38
  ...route?.meta,
39
39
 
40
- // CLOSE: 根据资源类型设置正确的显示属性
41
40
  // 应用和动态应用不需要在侧边栏和标签栏显示,因为它们通过TopMode渲染
42
41
  ...(route.type === RESOURCE_TYPE.APP || route.type === RESOURCE_TYPE.DYNAMIC_APP
43
42
  ? {
@@ -56,7 +55,6 @@ export function formatBackRoutes(
56
55
  : {}),
57
56
  }, isUndefined) as BackEndRoute['meta'];
58
57
 
59
- // TODO: 这里的逻辑可能需要根据实际情况调整
60
58
  const finalRoute = cloneDeep(omitBy<BackEndRoute>({
61
59
  name: route?.meta?.routeName ?? undefined,
62
60
  path: route?.meta?.url ?? undefined,
@@ -87,6 +85,8 @@ export function formatBackRoutes(
87
85
  return finalRoute;
88
86
  }
89
87
  });
88
+
89
+ return isEmpty(parent) ? filterEmptyComponentRoutes(formatRoutes) : formatRoutes;
90
90
  }
91
91
 
92
92
  /** 过滤指定类型的路由 */
@@ -99,6 +99,37 @@ function filterRoutes(routes: API.PubResourceTreeBo[] = [], excludes: string[])
99
99
  });
100
100
  }
101
101
 
102
+ /** 过滤找不到SFC组件的路由 */
103
+ function filterEmptyComponentRoutes(routes: BackEndRoute[], minDepth = 3): BackEndRoute[] {
104
+ function recurse(route: BackEndRoute): BackEndRoute | null {
105
+ const children = route.children?.map(recurse).filter(Boolean) as BackEndRoute[] | undefined;
106
+
107
+ if (children && children.length > 0) {
108
+ return { ...route, children };
109
+ }
110
+
111
+ if (children?.length === 0 && route.component) {
112
+ // 叶子且有 component
113
+ const { children, ...rest } = route;
114
+ return { ...rest, children: [] };
115
+ }
116
+
117
+ return null;
118
+ }
119
+
120
+ function maxDepth(route: BackEndRoute): number {
121
+ if (!route.children || route.children.length === 0) {
122
+ return 1;
123
+ }
124
+ return 1 + Math.max(...route.children.map(maxDepth));
125
+ }
126
+
127
+ return routes
128
+ .map(recurse)
129
+ .filter((r): r is BackEndRoute => !!r)
130
+ .filter(r => maxDepth(r) >= minDepth);
131
+ }
132
+
102
133
  /** 转换目录 */
103
134
  function transformIndex(route: BackEndRoute, parent: API.PubResourceTreeBo = {}): BackEndRoute {
104
135
  switch (parent.type) {
@@ -136,6 +167,7 @@ function transformMenuAndIframe(route: BackEndRoute, parent: API.PubResourceTree
136
167
  const menuRouteChildren: BackEndRoute[] = [
137
168
  {
138
169
  path: '',
170
+ name: route.name,
139
171
  component: replaceComponent(route.component, route.meta?.scope),
140
172
  meta: {
141
173
  ...route.meta,
@@ -155,6 +187,7 @@ function transformMenuAndIframe(route: BackEndRoute, parent: API.PubResourceTree
155
187
  menuRoute = {
156
188
  ...route,
157
189
  path: startsWithSlash(route.path),
190
+ name: undefined,
158
191
  component: setupDefaultLayout(),
159
192
  children: menuRouteChildren,
160
193
  };
@@ -165,6 +198,7 @@ function transformMenuAndIframe(route: BackEndRoute, parent: API.PubResourceTree
165
198
  menuRoute = {
166
199
  ...route,
167
200
  path: route.path,
201
+ name: undefined,
168
202
  component: undefined,
169
203
  children: menuRouteChildren,
170
204
  };
package/src/index.ts CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  Authentication,
4
4
  Authorization,
5
5
  LayoutComponent,
6
- Locales,
7
6
  NProgress,
8
7
  PiniaPlugin,
9
8
  PreAccess,
@@ -71,29 +70,27 @@ export function createPubinfo(options: PubinfoOptions) {
71
70
  Authorization(),
72
71
  LayoutComponent(),
73
72
  Settings(),
74
- Locales(),
75
73
  NProgress(),
76
74
  ...(options.modules ?? []),
77
75
  ],
78
76
  });
79
77
  }
80
78
 
79
+ export { RESPONSE_CODE } from './built-in/authentication';
81
80
  export {
82
- BackTop,
83
81
  Copyright,
84
82
  Layout,
85
83
  LayoutContent,
86
84
  LayoutHeader,
87
85
  LayoutProvider,
86
+ LayoutSidebar,
87
+ LayoutTopbar,
88
88
  Logo,
89
- Menu,
90
- RESPONSE_CODE,
91
- SettingBar,
92
- Sidebar,
89
+ Tool,
93
90
  Tools,
94
- Topbar,
95
- } from './built-in';
96
- export { eventBus } from './built-in/layout-component/utils';
91
+ } from './built-in/layout-component';
92
+ export type { DropdownMenu, DropdownMenuRender } from './built-in/layout-component';
93
+ export { updateWatermark } from './built-in/layout-component/composables/useWatermark';
97
94
 
98
95
  export {
99
96
  createRequest,
@@ -103,7 +100,6 @@ export {
103
100
  getAllRouteModules,
104
101
  readProjectModules,
105
102
  } from './core';
106
-
107
103
  export * from './core/interface';
108
104
 
109
105
  export * from './features';
@@ -4,7 +4,6 @@ import type { User } from './user';
4
4
 
5
5
  export interface RouterMetaRawBaseOptions {
6
6
  title: string | (() => string)
7
- i18n: string
8
7
  icon: string
9
8
  activeIcon: string
10
9
  defaultOpened: boolean
@@ -36,7 +35,6 @@ export declare namespace Route {
36
35
 
37
36
  type mainMeta
38
37
  = | 'title'
39
- | 'i18n'
40
38
  | 'icon'
41
39
  | 'activeIcon'
42
40
  | 'auth'
@@ -60,7 +58,6 @@ export declare namespace Route {
60
58
  interface breadcrumb {
61
59
  path: string
62
60
  title?: string | (() => string)
63
- i18n?: string
64
61
  icon?: string
65
62
  activeIcon?: string
66
63
  hide: boolean
@@ -1,5 +0,0 @@
1
- interface MittTypes {
2
- [key: PropertyKey]: any;
3
- }
4
- export declare const eventBus: import('mitt').Emitter<MittTypes>;
5
- export {};