mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 细节完善、迁移页面
This commit is contained in:
@ -36,14 +36,16 @@ function getBreadcrumbMenu(activeKey: string, menus: GlobalMenuOption[]) {
|
||||
*/
|
||||
function getBreadcrumbMenuItem(activeKey: string, menu: GlobalMenuOption) {
|
||||
const breadcrumbMenu: GlobalMenuOption[] = [];
|
||||
if (activeKey.includes(menu.routeName)) {
|
||||
if (activeKey === menu.routeName) {
|
||||
breadcrumbMenu.push(menu);
|
||||
}
|
||||
if (menu.children && menu.children.length) {
|
||||
if (activeKey.includes(menu.routeName) && menu.children && menu.children.length) {
|
||||
breadcrumbMenu.push(menu);
|
||||
breadcrumbMenu.push(
|
||||
...menu.children.map(item => getBreadcrumbMenuItem(activeKey, item as GlobalMenuOption)).flat(1)
|
||||
);
|
||||
}
|
||||
|
||||
return breadcrumbMenu;
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,27 @@ import {
|
||||
ServiceError,
|
||||
DashboardAnalysis,
|
||||
DashboardWorkbench,
|
||||
DocumentVue,
|
||||
DocumentVueNew,
|
||||
DocumentVite,
|
||||
DocumentNaive,
|
||||
About,
|
||||
MultiMenuFirstSecond
|
||||
MultiMenuFirstSecond,
|
||||
MultiMenuFirstSecondNewThird
|
||||
} from '@/views';
|
||||
|
||||
/** 需要用到自身vue组件的页面 */
|
||||
type ViewComponentKey = Exclude<AuthRoute.RouteKey, 'root' | 'dashboard' | 'multi-menu' | 'multi-menu_first'>;
|
||||
type ViewComponentKey = Exclude<
|
||||
AuthRoute.RouteKey,
|
||||
| 'root'
|
||||
| 'dashboard'
|
||||
| 'document'
|
||||
| 'document_project'
|
||||
| 'multi-menu'
|
||||
| 'multi-menu_first'
|
||||
| 'multi-menu_first_second-new'
|
||||
| 'exception'
|
||||
>;
|
||||
|
||||
type ViewComponent = {
|
||||
[key in ViewComponentKey]: () => Promise<Component>;
|
||||
@ -28,8 +43,16 @@ export function getViewComponent(routeKey: AuthRoute.RouteKey) {
|
||||
'service-error',
|
||||
'dashboard_analysis',
|
||||
'dashboard_workbench',
|
||||
'document_vue',
|
||||
'document_vue-new',
|
||||
'document_vite',
|
||||
'document_naive',
|
||||
'about',
|
||||
'multi-menu_first_second',
|
||||
'multi-menu_first_second-new_third',
|
||||
'exception_403',
|
||||
'exception_404',
|
||||
'exception_500',
|
||||
'not-found-page'
|
||||
];
|
||||
|
||||
@ -42,9 +65,17 @@ export function getViewComponent(routeKey: AuthRoute.RouteKey) {
|
||||
'service-error': ServiceError,
|
||||
dashboard_analysis: DashboardAnalysis,
|
||||
dashboard_workbench: DashboardWorkbench,
|
||||
about: About,
|
||||
document_vue: DocumentVue,
|
||||
'document_vue-new': DocumentVueNew,
|
||||
document_vite: DocumentVite,
|
||||
document_naive: DocumentNaive,
|
||||
'multi-menu_first_second': MultiMenuFirstSecond,
|
||||
'not-found-page': NotFound
|
||||
'multi-menu_first_second-new_third': MultiMenuFirstSecondNewThird,
|
||||
'not-found-page': NotFound,
|
||||
exception_403: NoPermission,
|
||||
exception_404: NotFound,
|
||||
exception_500: ServiceError,
|
||||
about: About
|
||||
};
|
||||
|
||||
return () => setViewComponentName(viewComponent[key], key) as Promise<Component>;
|
||||
|
@ -24,10 +24,17 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
|
||||
const itemRoute = { ...item } as RouteRecordRaw;
|
||||
|
||||
// 动态path
|
||||
if (hasDynamicPath(item)) {
|
||||
Object.assign(itemRoute, { path: item.meta.dynamicPath });
|
||||
}
|
||||
|
||||
// 外链路由
|
||||
if (hasHref(item)) {
|
||||
Object.assign(itemRoute, { component: getViewComponent('not-found-page') });
|
||||
}
|
||||
|
||||
// 路由组件
|
||||
if (hasComponent(item)) {
|
||||
const action: ComponentAction = {
|
||||
basic() {
|
||||
@ -87,6 +94,7 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
}
|
||||
}
|
||||
|
||||
// 子路由
|
||||
if (hasChildren(item)) {
|
||||
const children = item.children!.map(child => transformAuthRouteToVueRoute(child)).flat();
|
||||
|
||||
@ -106,11 +114,20 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
}
|
||||
itemRoute.redirect = redirectPath;
|
||||
}
|
||||
|
||||
resultRoute.push(itemRoute);
|
||||
|
||||
return resultRoute;
|
||||
}
|
||||
|
||||
function hasHref(item: AuthRoute.Route) {
|
||||
return Boolean(item.meta.href);
|
||||
}
|
||||
|
||||
function hasDynamicPath(item: AuthRoute.Route) {
|
||||
return Boolean(item.meta.dynamicPath);
|
||||
}
|
||||
|
||||
function hasComponent(item: AuthRoute.Route) {
|
||||
return Boolean(item.component);
|
||||
}
|
||||
@ -119,10 +136,6 @@ function hasChildren(item: AuthRoute.Route) {
|
||||
return Boolean(item.children && item.children.length);
|
||||
}
|
||||
|
||||
function hasDynamicPath(item: AuthRoute.Route) {
|
||||
return Boolean(item.meta.dynamicPath);
|
||||
}
|
||||
|
||||
function isSingleRoute(item: AuthRoute.Route) {
|
||||
return Boolean(item.meta.singleLayout);
|
||||
}
|
||||
|
Reference in New Issue
Block a user