@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.
- package/dist/{AppSetting-D2RJrc9O.js → AppSetting-BI-oNc4e.js} +19 -19
- package/dist/{HCheckList.vue_vue_type_script_setup_true_lang-DusVz35O.js → HCheckList.vue_vue_type_script_setup_true_lang-BdLpkcoh.js} +1 -1
- package/dist/{HToggle-DMcVgMVY.js → HToggle-DxdWLgp-.js} +1 -1
- package/dist/{PreferencesContent-Dtd9rtew.js → PreferencesContent-CCYkZeCT.js} +52 -52
- package/dist/{SettingBreadcrumb-QSCSviKM.js → SettingBreadcrumb-BTyfiy4k.js} +5 -5
- package/dist/{SettingCopyright-Dr5P6yfq.js → SettingCopyright-g6UHi8pZ.js} +2 -2
- package/dist/{SettingEnableTransition-DGiHEbCI.js → SettingEnableTransition-Ci-5bhbR.js} +12 -12
- package/dist/{SettingHome-CEPcBlds.js → SettingHome-K4Iel0Hr.js} +8 -8
- package/dist/{SettingMenu-BJdjnRA6.js → SettingMenu-BYLWzA5i.js} +14 -14
- package/dist/{SettingMode-BnuCHoEY.js → SettingMode-tRisyKtg.js} +3 -3
- package/dist/{SettingNavSearch-CiU4BmlU.js → SettingNavSearch-CSM6mPf8.js} +6 -6
- package/dist/{SettingOther-DTHjVlFe.js → SettingOther-Bj5KF_vC.js} +11 -11
- package/dist/{SettingPage-D75_Nf05.js → SettingPage-CFjmrVI7.js} +2 -2
- package/dist/{SettingTabbar-D48dzvgA.js → SettingTabbar-uFYiaZhK.js} +13 -13
- package/dist/{SettingThemes-D-8vTs5n.js → SettingThemes-C-tMq9o5.js} +12 -12
- package/dist/{SettingToolbar-DjIjm9V-.js → SettingToolbar-BfDzijNU.js} +10 -10
- package/dist/{SettingTopbar-Cg30OTH3.js → SettingTopbar-DTDv4NXD.js} +6 -6
- package/dist/{SettingWidthMode-BKV_7kb8.js → SettingWidthMode-PkiwrHe3.js} +11 -11
- package/dist/{TopThinMode-JFYsp_lJ.js → TopThinMode-BrvA8pV0.js} +3 -3
- package/dist/built-in/authentication/alova/helper.d.ts +34 -0
- package/dist/built-in/authentication/alova/token.d.ts +16 -0
- package/dist/built-in/authentication/helper.d.ts +10 -1
- package/dist/built-in/index.d.ts +0 -1
- package/dist/built-in/layout-component/Layout.vue.d.ts +1 -0
- package/dist/built-in/layout-component/components/Tools/Fullscreen.vue.d.ts +2 -0
- package/dist/built-in/layout-component/components/Tools/PageReload.vue.d.ts +2 -0
- package/dist/built-in/layout-component/components/Tools/SearchBar.vue.d.ts +2 -0
- package/dist/built-in/layout-component/components/Tools/index.vue.d.ts +47 -1
- package/dist/built-in/layout-component/components/Tools/interface.d.ts +26 -0
- package/dist/built-in/layout-component/components/ui/HDropdownMenu.vue.d.ts +2 -7
- package/dist/built-in/layout-component/components/ui/HSlideover.vue.d.ts +1 -1
- package/dist/built-in/layout-component/composables/useContext.d.ts +1 -1
- package/dist/built-in/layout-component/composables/useHotkey.d.ts +1 -5
- package/dist/built-in/layout-component/composables/useMainPage.d.ts +1 -1
- package/dist/built-in/layout-component/composables/useMenu.d.ts +1 -1
- package/dist/built-in/layout-component/composables/useTabbar.d.ts +1 -1
- package/dist/built-in/layout-component/composables/useTitle.d.ts +3 -2
- package/dist/built-in/layout-component/composables/useWatermark.d.ts +3 -1
- package/dist/built-in/layout-component/index.d.ts +9 -6
- package/dist/built-in/layout-component/utils/index.d.ts +0 -1
- package/dist/{colors-CODcBxrF.js → colors-VoaDbOhe.js} +1 -1
- package/dist/core/interface.d.ts +14 -5
- package/dist/core/request.d.ts +2 -8
- package/dist/features/api/modules/auth/renzhengfuwu.d.ts +8 -8
- package/dist/features/api/modules/configData/heibaimingdanfuwu.d.ts +5 -5
- package/dist/features/api/modules/configData/xitongpeizhifuwu.d.ts +14 -14
- package/dist/features/api/modules/configData/zidifuwu.d.ts +10 -10
- package/dist/features/api/modules/rbac/gangweijiekou.d.ts +6 -6
- package/dist/features/api/modules/rbac/jiaosejiekou.d.ts +7 -7
- package/dist/features/api/modules/rbac/pubJiaosezukongzhiqi.d.ts +7 -7
- package/dist/features/api/modules/rbac/shujuquanxianzhubiaokongzhiqi.d.ts +9 -9
- package/dist/features/api/modules/rbac/yonghujiekou.d.ts +15 -15
- package/dist/features/api/modules/rbac/yonghushoucangbiaojiekou.d.ts +5 -5
- package/dist/features/api/modules/rbac/yonghuzuijinchangyongbiaojiekou.d.ts +4 -4
- package/dist/features/api/modules/rbac/ziyuanjiekou.d.ts +13 -13
- package/dist/features/api/modules/rbac/zuhuguanlijiekou.d.ts +5 -5
- package/dist/features/api/modules/rbac/zuzhijiaosebiaokongzhiqi.d.ts +4 -4
- package/dist/features/api/modules/rbac/zuzhijiekou.d.ts +9 -9
- package/dist/features/api/system/user.d.ts +4 -4
- package/dist/{index-RT-QBzm0.js → index-BSevJVD5.js} +10 -15
- package/dist/{index-BVLkBCRY.js → index-BfGqLWFB.js} +6418 -6439
- package/dist/{index-DQn1WFMa.js → index-CYoFRwvw.js} +2 -2
- package/dist/{index-DmcblkoZ.js → index-ConeY38N.js} +13 -13
- package/dist/{index-BAoB7aoj.js → index-DV3hkzKA.js} +1 -1
- package/dist/{index-D4_xmL_A.js → index-Ddw98rJ5.js} +25 -25
- package/dist/{index-DvJr0paY.js → index-DrC787X_.js} +2 -2
- package/dist/{index-BROqFYXS.js → index-Dv9ndBoi.js} +1 -1
- package/dist/{index-Jd3PYkpj.js → index-IAYhIBQH.js} +16815 -16694
- package/dist/index.d.ts +4 -2
- package/dist/index.js +53 -55
- package/dist/{pick-BLJM77QN.js → pick-vpv9EEvu.js} +1 -1
- package/dist/style.css +1 -1
- package/package.json +11 -11
- package/src/built-in/authentication/alova/helper.ts +158 -0
- package/src/built-in/authentication/alova/token.ts +122 -0
- package/src/built-in/authentication/helper.ts +7 -3
- package/src/built-in/authentication/index.ts +6 -20
- package/src/built-in/index.ts +0 -1
- package/src/built-in/layout-component/Layout.vue +11 -22
- package/src/built-in/layout-component/components/Header/TopMode/index.vue +4 -4
- package/src/built-in/layout-component/components/Menu/item.vue +3 -3
- package/src/built-in/layout-component/components/Sidebar/MainSidebar.vue +4 -4
- package/src/built-in/layout-component/components/Sidebar/index.vue +1 -1
- package/src/built-in/layout-component/components/Tools/DarkModeToggle.vue +108 -0
- package/src/built-in/layout-component/components/Tools/Fullscreen.vue +24 -0
- package/src/built-in/layout-component/components/Tools/PageReload.vue +22 -0
- package/src/built-in/layout-component/components/Tools/SearchBar.vue +42 -0
- package/src/built-in/layout-component/components/Tools/{Search.vue → SearchPanel.vue} +13 -21
- package/src/built-in/layout-component/components/Tools/index.vue +71 -142
- package/src/built-in/layout-component/components/Tools/interface.ts +27 -0
- package/src/built-in/layout-component/components/Topbar/Tabbar/MoreAction.vue +9 -12
- package/src/built-in/layout-component/components/Topbar/Tabbar/index.vue +12 -15
- package/src/built-in/layout-component/components/Topbar/Toolbar/Favorites.vue +4 -7
- package/src/built-in/layout-component/components/Topbar/Toolbar/index.vue +6 -6
- package/src/built-in/layout-component/components/ui/HDropdownMenu.vue +19 -26
- package/src/built-in/layout-component/composables/useContext.ts +1 -1
- package/src/built-in/layout-component/composables/useGetComputedStyle.ts +2 -3
- package/src/built-in/layout-component/composables/useHotkey.ts +6 -10
- package/src/built-in/layout-component/composables/useMainPage.ts +5 -6
- package/src/built-in/layout-component/composables/useMenu.ts +3 -5
- package/src/built-in/layout-component/composables/useTabbar.ts +3 -5
- package/src/built-in/layout-component/composables/useTitle.ts +10 -17
- package/src/built-in/layout-component/composables/useWatermark.ts +25 -12
- package/src/built-in/layout-component/index.ts +21 -12
- package/src/built-in/layout-component/provider.ts +7 -3
- package/src/built-in/layout-component/utils/index.ts +0 -1
- package/src/built-in/settings/router.ts +5 -1
- package/src/core/interface.ts +18 -5
- package/src/core/request.ts +35 -15
- package/src/features/router/systemRoutes.ts +0 -1
- package/src/features/stores/modules/favorites.ts +0 -1
- package/src/features/stores/modules/route.ts +2 -9
- package/src/features/stores/modules/tabbar.ts +0 -3
- package/src/features/stores/utils/routerHelper.ts +38 -4
- package/src/index.ts +7 -11
- package/types/vue-router.d.ts +0 -3
- package/dist/built-in/layout-component/utils/eventBus.d.ts +0 -5
- package/dist/built-in/locales/helpler.d.ts +0 -594
- package/dist/built-in/locales/index.d.ts +0 -5
- package/dist/built-in/locales/lang/en.json.d.ts +0 -99
- package/dist/built-in/locales/lang/zh-cn.json.d.ts +0 -100
- package/dist/built-in/locales/lang/zh-tw.json.d.ts +0 -100
- package/dist/built-in/locales/ui.d.ts +0 -3
- package/src/built-in/layout-component/components/Tools/DayNightSwitch.vue +0 -70
- package/src/built-in/layout-component/utils/eventBus.ts +0 -8
- package/src/built-in/locales/helpler.ts +0 -76
- package/src/built-in/locales/index.ts +0 -20
- package/src/built-in/locales/lang/en.json +0 -96
- package/src/built-in/locales/lang/zh-cn.json +0 -97
- package/src/built-in/locales/lang/zh-tw.json +0 -97
- package/src/built-in/locales/ui.ts +0 -3
- /package/dist/built-in/layout-component/components/Tools/{DayNightSwitch.vue.d.ts → DarkModeToggle.vue.d.ts} +0 -0
- /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
|
-
|
|
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(
|
package/src/core/interface.ts
CHANGED
|
@@ -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'> & {
|
|
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':
|
|
88
|
-
'http:response':
|
|
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
|
}
|
package/src/core/request.ts
CHANGED
|
@@ -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 {
|
|
17
|
-
|
|
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:
|
|
32
|
+
beforeRequest: async (method) => {
|
|
29
33
|
await hooks.callHook('http:request', method);
|
|
30
34
|
await beforeRequest?.(method);
|
|
31
|
-
}
|
|
35
|
+
},
|
|
32
36
|
|
|
33
|
-
responded:
|
|
37
|
+
responded: {
|
|
34
38
|
onSuccess: async (response, method) => {
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
@@ -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,
|
|
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
|
-
|
|
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
|
-
|
|
90
|
-
RESPONSE_CODE,
|
|
91
|
-
SettingBar,
|
|
92
|
-
Sidebar,
|
|
89
|
+
Tool,
|
|
93
90
|
Tools,
|
|
94
|
-
|
|
95
|
-
} from './built-in';
|
|
96
|
-
export {
|
|
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';
|
package/types/vue-router.d.ts
CHANGED
|
@@ -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
|