Commit 3b2f0085 authored by ι™ˆεΈ…'s avatar ι™ˆεΈ…

fix pageHeader error

parent bdbf9cff
......@@ -37,11 +37,14 @@ const findAllInstallRouter = router => {
return routers;
};
const filterParentRouter = router => {
const filterParentRouter = (router, layout) => {
return [...router]
.map(item => {
if (item.routes) {
return { ...item, routes: filterParentRouter(item.routes) };
if (item.routes && (!router.component || layout)) {
return { ...item, routes: filterParentRouter(item.routes, false) };
}
if (item.redirect) {
return item;
}
return null;
})
......@@ -70,7 +73,7 @@ const execCmd = shell => {
};
// replace router config
const parentRouter = filterParentRouter(router);
const parentRouter = filterParentRouter(router, true);
const { routesPath, code } = getNewRouteCode(relativePath, parentRouter);
// write ParentRouter
fs.writeFileSync(routesPath, code);
......@@ -89,7 +92,7 @@ const installBlock = async () => {
if (gitFiles.find(file => file.path === gitPath)) {
console.log('install ' + chalk.green(item.name) + ' to: ' + chalk.yellow(item.path));
gitFiles = gitFiles.filter(file => file.path !== gitPath);
const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${gitPath} --path=${
const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${gitPath} --npm-client=cnpm --path=${
item.path
}`;
try {
......
......@@ -4,7 +4,6 @@ module.exports = [
path: '/user',
component: '../layouts/UserLayout',
routes: [
{ path: '/user', redirect: '/user/login' },
{ path: '/user/login', name: 'login', component: './User/Login' },
{ path: '/user/register', name: 'register', component: './User/Register' },
{
......@@ -12,6 +11,7 @@ module.exports = [
name: 'register.result',
component: './User/RegisterResult',
},
{ path: '/user', redirect: '/user/login' },
{
component: '404',
},
......@@ -25,7 +25,6 @@ module.exports = [
authority: ['admin', 'user'],
routes: [
// dashboard
{ path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] },
{
path: '/dashboard',
name: 'dashboard',
......@@ -63,28 +62,6 @@ module.exports = [
path: '/form/step-form',
name: 'stepform',
component: './Form/StepForm',
hideChildrenInMenu: true,
// routes: [
// {
// path: '/form/step-form',
// redirect: '/form/step-form/info',
// },
// {
// path: '/form/step-form/info',
// name: 'info',
// component: './Form/StepForm/Step1',
// },
// {
// path: '/form/step-form/confirm',
// name: 'confirm',
// component: './Form/StepForm/Step2',
// },
// {
// path: '/form/step-form/result',
// name: 'result',
// component: './Form/StepForm/Step3',
// },
// ],
},
{
path: '/form/advanced-form',
......@@ -120,10 +97,6 @@ module.exports = [
name: 'search-list',
component: './list/search',
routes: [
{
path: '/list/search',
redirect: '/list/search/articles',
},
{
path: '/list/search/articles',
name: 'articles',
......@@ -139,6 +112,10 @@ module.exports = [
name: 'applications',
component: './list/Applications',
},
{
path: '/list/search',
redirect: '/list/search/articles',
},
],
},
],
......@@ -213,51 +190,11 @@ module.exports = [
path: '/account/center',
name: 'center',
component: './Account/Center/Center',
// routes: [
// {
// path: '/account/center',
// redirect: '/account/center/articles',
// },
// {
// path: '/account/center/articles',
// component: './Account/Center/Articles',
// },
// {
// path: '/account/center/applications',
// component: './Account/Center/Applications',
// },
// {
// path: '/account/center/projects',
// component: './Account/Center/Projects',
// },
// ],
},
{
path: '/account/settings',
name: 'settings',
component: './Account/Settings/Info',
// routes: [
// {
// path: '/account/settings',
// redirect: '/account/settings/base',
// },
// {
// path: '/account/settings/base',
// component: './Account/Settings/BaseView',
// },
// {
// path: '/account/settings/security',
// component: './Account/Settings/SecurityView',
// },
// {
// path: '/account/settings/binding',
// component: './Account/Settings/BindingView',
// },
// {
// path: '/account/settings/notification',
// component: './Account/Settings/NotificationView',
// },
// ],
},
],
},
......@@ -284,6 +221,7 @@ module.exports = [
},
],
},
{ path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] },
{
component: '404',
},
......
......@@ -25,17 +25,13 @@ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
};
/**
* default menuLocal
* use Authorized check all menu item
*/
const filterMenuData = (menuList: MenuDataItem[], locale: boolean): MenuDataItem[] => {
const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => {
return menuList.map(item => {
const localItem = {
...item,
name:
item.locale && locale
? formatMessage({ id: item.locale, defaultMessage: item.name })
: item.name,
children: item.children ? filterMenuData(item.children, locale) : [],
children: item.children ? menuDataRender(item.children) : [],
};
return Authorized.check(item.authority, localItem, null) as MenuDataItem;
......@@ -56,9 +52,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
*/
const handleMenuCollapse = (payload: boolean) =>
dispatch!({ type: 'global/changeLayoutCollapsed', payload });
const {
menu: { locale },
} = settings;
return (
<>
<BasicLayoutComponents
......@@ -67,7 +61,20 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
menuItemRender={(menuItemProps, defaultDom) => {
return <Link to={menuItemProps.path}>{defaultDom}</Link>;
}}
filterMenuData={menuList => filterMenuData(menuList, locale)}
breadcrumbRender={(routers = []) => {
return [
{
path: '/',
breadcrumbName: formatMessage({
id: 'menu.home',
defaultMessage: 'Home',
}),
},
...routers,
];
}}
menuDataRender={menuDataRender}
formatMessage={formatMessage}
rightContentRender={rightProps => <RightContent {...rightProps} />}
{...props}
{...settings}
......@@ -85,7 +92,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
}
/>
)}
<CopyBlock url={location.pathname} />
<CopyBlock url={location!.pathname} />
</>
);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment