Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/pro-layout/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash';
import last from 'lodash/last';
import { useContext, useMemo } from 'react';
import { useLocation } from 'react-router';
import { RouteContext } from './layouts/RouteLayout';
Expand Down Expand Up @@ -32,6 +32,6 @@ export const useRouteMeta = (inherit = true): Partial<Meta> => {
return prev;
}, {});
}
return _.last(routes)?.meta ?? {};
return last(routes)?.meta ?? {};
}, [inherit, routes]);
};
8 changes: 4 additions & 4 deletions packages/pro-layout/src/layouts/BasicLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-param-reassign */
import { Layout, Menu } from 'antd';
import _ from 'lodash';
import isEmpty from 'lodash/isEmpty';
import React, { useMemo } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { useMatchedRoutes } from '../hooks';
Expand All @@ -13,7 +13,7 @@ const { SubMenu, Item: MenuItem } = Menu;

const renderMenu = (routes: RouteConfig[]) => {
return routes.map((m) => {
if (!_.isEmpty(m.routes)) {
if (!isEmpty(m.routes)) {
return (
<SubMenu
key={m.path}
Expand Down Expand Up @@ -100,7 +100,7 @@ function BasicLayout<AuthorityType = any>({
m.routes = undefined;
return true;
}
if (!_.isEmpty(m.routes)) {
if (!isEmpty(m.routes)) {
m.routes = filterNode(m.routes!);
// 子节点为空时,是否隐藏父节点
return m.routes.length;
Expand All @@ -121,7 +121,7 @@ function BasicLayout<AuthorityType = any>({
if (cloneNode.component) {
cloneNode.component = withAuthorized(cloneNode.component, cloneNode.meta);
}
if (!_.isEmpty(cloneNode.routes)) {
if (!isEmpty(cloneNode.routes)) {
cloneNode.routes = wrapNode(cloneNode.routes!);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/pro-layout/src/layouts/BlankLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash';
import isEmpty from 'lodash/isEmpty';
import React from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
import type { RouteConfig } from '../type';
Expand Down Expand Up @@ -45,7 +45,7 @@ const BlankLayout: React.FC<BlankLayoutProps> = (props) => {
childComp && React.createElement(childComp),
);
}
if (!_.isEmpty(routes)) {
if (!isEmpty(routes)) {
return <BlankLayout routes={routes!} />;
}
}}
Expand Down
6 changes: 3 additions & 3 deletions packages/pro-layout/src/layouts/PageContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { PageHeaderProps, TabPaneProps, TabsProps } from 'antd';
import { Breadcrumb, PageHeader, Space, Spin, Tabs } from 'antd';
import _ from 'lodash';
import classNames from 'classnames';
import last from 'lodash/last';
import React from 'react';
import { Link } from 'react-router-dom';
import { useMatchedRoutes } from '../hooks';
import './PageContainer.less';
import classNames from 'classnames';

const { TabPane } = Tabs;

Expand Down Expand Up @@ -70,7 +70,7 @@ const PageContainer: React.FC<PageContainerProps> = ({
))}
</Breadcrumb>
}
title={title ?? _.last(crumbs)?.name}
title={title ?? last(crumbs)?.name}
footer={
tabList && (
<Tabs activeKey={tabActiveKey} onChange={onTabChange} {...tabProps}>
Expand Down
8 changes: 4 additions & 4 deletions packages/pro-layout/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash';
import isEmpty from 'lodash/isEmpty';
import type { RouteConfig } from './type';

/**
Expand All @@ -25,7 +25,7 @@ export function getRouteConfigByPath(routes: RouteConfig[], path: string): Route
if (route.path === path) {
return route;
}
if (!_.isEmpty(route.routes)) {
if (!isEmpty(route.routes)) {
const node = getRouteConfigByPath(route.routes!, path);

if (node) {
Expand All @@ -46,7 +46,7 @@ export function getFirstLeafNode(routes: RouteConfig[]): RouteConfig | undefined
if (!firstNode) {
return firstNode;
}
if (_.isEmpty(firstNode.routes)) {
if (isEmpty(firstNode.routes)) {
return firstNode;
}
return getFirstLeafNode(firstNode.routes!);
Expand Down Expand Up @@ -74,7 +74,7 @@ export function getRouteNode(
return result;
}
result.push(route);
if (_.isEmpty(route.routes)) {
if (isEmpty(route.routes)) {
return result;
}

Expand Down