mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
build(projects): update tsconfig、eslintrc
This commit is contained in:
@ -8,7 +8,7 @@ import type { GlobalMenuOption, GlobalBreadcrumb } from '@/interface';
|
||||
*/
|
||||
export function getBreadcrumbByRouteKey(activeKey: string, menus: GlobalMenuOption[], rootPath: string) {
|
||||
const breadcrumbMenu = getBreadcrumbMenu(activeKey, menus);
|
||||
const breadcrumb = breadcrumbMenu.map(item => transformBreadcrumbMenuToBreadcrumb(item, rootPath));
|
||||
const breadcrumb = breadcrumbMenu.map((item) => transformBreadcrumbMenuToBreadcrumb(item, rootPath));
|
||||
return breadcrumb;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ export function getBreadcrumbByRouteKey(activeKey: string, menus: GlobalMenuOpti
|
||||
*/
|
||||
function getBreadcrumbMenu(activeKey: string, menus: GlobalMenuOption[]) {
|
||||
const breadcrumbMenu: GlobalMenuOption[] = [];
|
||||
menus.some(menu => {
|
||||
menus.some((menu) => {
|
||||
const flag = activeKey.includes(menu.routeName);
|
||||
if (flag) {
|
||||
breadcrumbMenu.push(...getBreadcrumbMenuItem(activeKey, menu));
|
||||
@ -42,7 +42,7 @@ function getBreadcrumbMenuItem(activeKey: string, menu: GlobalMenuOption) {
|
||||
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)
|
||||
...menu.children.map((item) => getBreadcrumbMenuItem(activeKey, item as GlobalMenuOption)).flat(1)
|
||||
);
|
||||
}
|
||||
|
||||
@ -61,13 +61,13 @@ function transformBreadcrumbMenuToBreadcrumb(menu: GlobalMenuOption, rootPath: s
|
||||
label: menu.label as string,
|
||||
routeName: menu.routeName,
|
||||
disabled: menu.routePath === rootPath,
|
||||
hasChildren
|
||||
hasChildren,
|
||||
};
|
||||
if (menu.icon) {
|
||||
breadcrumb.icon = menu.icon;
|
||||
}
|
||||
if (hasChildren) {
|
||||
breadcrumb.children = menu.children?.map(item =>
|
||||
breadcrumb.children = menu.children?.map((item) =>
|
||||
transformBreadcrumbMenuToBreadcrumb(item as GlobalMenuOption, rootPath)
|
||||
);
|
||||
}
|
||||
|
@ -6,10 +6,10 @@ import type { RouteRecordRaw } from 'vue-router';
|
||||
*/
|
||||
export function getCacheRoutes(routes: RouteRecordRaw[]) {
|
||||
const cacheNames: string[] = [];
|
||||
routes.forEach(route => {
|
||||
routes.forEach((route) => {
|
||||
// 只需要获取二级路由的缓存的组件名
|
||||
if (hasChildren(route)) {
|
||||
route.children!.forEach(item => {
|
||||
(route.children as RouteRecordRaw[]).forEach((item) => {
|
||||
if (isKeepAlive(item)) {
|
||||
cacheNames.push(item.name as string);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ type LayoutComponent = Record<LayoutComponentName, () => Promise<Component>>;
|
||||
export function getLayoutComponent(layoutType: LayoutComponentName) {
|
||||
const layoutComponent: LayoutComponent = {
|
||||
basic: BasicLayout,
|
||||
blank: BlankLayout
|
||||
blank: BlankLayout,
|
||||
};
|
||||
return () => setViewComponentName(layoutComponent[layoutType], EnumLayoutComponentName[layoutType]);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ type ComponentAction = Record<AuthRoute.RouteComponent, () => void>;
|
||||
* @description 所有多级路由都会被转换成二级路由
|
||||
*/
|
||||
export function transformAuthRoutesToVueRoutes(routes: AuthRoute.Route[]) {
|
||||
return routes.map(route => transformAuthRouteToVueRoute(route)).flat(1);
|
||||
return routes.map((route) => transformAuthRouteToVueRoute(route)).flat(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,10 +70,14 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
},
|
||||
self() {
|
||||
itemRoute.component = getViewComponent(item.name);
|
||||
}
|
||||
},
|
||||
};
|
||||
try {
|
||||
action[item.component!]();
|
||||
if (item.component) {
|
||||
action[item.component]();
|
||||
} else {
|
||||
consoleError('路由组件解析失败: ', item);
|
||||
}
|
||||
} catch {
|
||||
consoleError('路由组件解析失败: ', item);
|
||||
}
|
||||
@ -91,8 +95,8 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
{
|
||||
path: '',
|
||||
name: item.name,
|
||||
component: getViewComponent('not-found-page')
|
||||
}
|
||||
component: getViewComponent('not-found-page'),
|
||||
},
|
||||
];
|
||||
} else {
|
||||
const parentPath = `${itemRoute.path}-parent` as AuthRoute.SingleRouteParentPath;
|
||||
@ -103,7 +107,7 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
path: parentPath,
|
||||
component: layout,
|
||||
redirect: item.path,
|
||||
children: [itemRoute]
|
||||
children: [itemRoute],
|
||||
};
|
||||
|
||||
return [parentRoute];
|
||||
@ -112,10 +116,10 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
|
||||
// 子路由
|
||||
if (hasChildren(item)) {
|
||||
const children = item.children!.map(child => transformAuthRouteToVueRoute(child)).flat();
|
||||
const children = (item.children as AuthRoute.Route[]).map((child) => transformAuthRouteToVueRoute(child)).flat();
|
||||
|
||||
// 找出第一个不为多级路由中间级的子路由路径作为重定向路径
|
||||
const redirectPath: AuthRoute.RoutePath = (children.find(item => !item.meta?.multi)?.path ||
|
||||
const redirectPath: AuthRoute.RoutePath = (children.find((v) => !v.meta?.multi)?.path ||
|
||||
'/') as AuthRoute.RoutePath;
|
||||
if (redirectPath === '/') {
|
||||
consoleError('该多级路由没有有效的子路径', item);
|
||||
|
@ -24,7 +24,7 @@ function addPartialProps(menuItem: GlobalMenuOption, icon?: string, children?: G
|
||||
*/
|
||||
export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuOption[] {
|
||||
const globalMenu: GlobalMenuOption[] = [];
|
||||
routes.forEach(route => {
|
||||
routes.forEach((route) => {
|
||||
const { name, path, meta } = route;
|
||||
const routeName = name as string;
|
||||
let menuChildren: GlobalMenuOption[] | undefined;
|
||||
@ -36,7 +36,7 @@ export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuO
|
||||
key: routeName,
|
||||
label: meta.title,
|
||||
routeName,
|
||||
routePath: path
|
||||
routePath: path,
|
||||
},
|
||||
meta?.icon,
|
||||
menuChildren
|
||||
@ -56,7 +56,7 @@ export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuO
|
||||
* @param menus - 菜单数据
|
||||
*/
|
||||
export function getActiveKeyPathsOfMenus(activeKey: string, menus: GlobalMenuOption[]) {
|
||||
const keys = menus.map(menu => getActiveKeyPathsOfMenu(activeKey, menu)).flat(1);
|
||||
const keys = menus.map((menu) => getActiveKeyPathsOfMenu(activeKey, menu)).flat(1);
|
||||
return keys;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ function getActiveKeyPathsOfMenu(activeKey: string, menu: GlobalMenuOption) {
|
||||
keys.push(menu.routeName);
|
||||
}
|
||||
if (menu.children) {
|
||||
keys.push(...menu.children.map(item => getActiveKeyPathsOfMenu(activeKey, item)).flat(1));
|
||||
keys.push(...menu.children.map((item) => getActiveKeyPathsOfMenu(activeKey, item)).flat(1));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ export function getTabRoutes() {
|
||||
const routes: GlobalTabRoute[] = [];
|
||||
const data = getLocal<GlobalTabRoute[]>(EnumStorageKey['tab-routes']);
|
||||
if (data) {
|
||||
const defaultTabRoutes = data.map(item => ({
|
||||
const defaultTabRoutes = data.map((item) => ({
|
||||
...item,
|
||||
scrollPosition: {
|
||||
left: 0,
|
||||
top: 0
|
||||
}
|
||||
top: 0,
|
||||
},
|
||||
}));
|
||||
routes.push(...defaultTabRoutes);
|
||||
}
|
||||
|
Reference in New Issue
Block a user