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

fix pageHeader error

parent bdbf9cff
...@@ -37,11 +37,14 @@ const findAllInstallRouter = router => { ...@@ -37,11 +37,14 @@ const findAllInstallRouter = router => {
return routers; return routers;
}; };
const filterParentRouter = router => { const filterParentRouter = (router, layout) => {
return [...router] return [...router]
.map(item => { .map(item => {
if (item.routes) { if (item.routes && (!router.component || layout)) {
return { ...item, routes: filterParentRouter(item.routes) }; return { ...item, routes: filterParentRouter(item.routes, false) };
}
if (item.redirect) {
return item;
} }
return null; return null;
}) })
...@@ -70,7 +73,7 @@ const execCmd = shell => { ...@@ -70,7 +73,7 @@ const execCmd = shell => {
}; };
// replace router config // replace router config
const parentRouter = filterParentRouter(router); const parentRouter = filterParentRouter(router, true);
const { routesPath, code } = getNewRouteCode(relativePath, parentRouter); const { routesPath, code } = getNewRouteCode(relativePath, parentRouter);
// write ParentRouter // write ParentRouter
fs.writeFileSync(routesPath, code); fs.writeFileSync(routesPath, code);
...@@ -89,7 +92,7 @@ const installBlock = async () => { ...@@ -89,7 +92,7 @@ const installBlock = async () => {
if (gitFiles.find(file => file.path === gitPath)) { if (gitFiles.find(file => file.path === gitPath)) {
console.log('install ' + chalk.green(item.name) + ' to: ' + chalk.yellow(item.path)); console.log('install ' + chalk.green(item.name) + ' to: ' + chalk.yellow(item.path));
gitFiles = gitFiles.filter(file => file.path !== gitPath); 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 item.path
}`; }`;
try { try {
......
...@@ -4,7 +4,6 @@ module.exports = [ ...@@ -4,7 +4,6 @@ module.exports = [
path: '/user', path: '/user',
component: '../layouts/UserLayout', component: '../layouts/UserLayout',
routes: [ routes: [
{ path: '/user', redirect: '/user/login' },
{ path: '/user/login', name: 'login', component: './User/Login' }, { path: '/user/login', name: 'login', component: './User/Login' },
{ path: '/user/register', name: 'register', component: './User/Register' }, { path: '/user/register', name: 'register', component: './User/Register' },
{ {
...@@ -12,6 +11,7 @@ module.exports = [ ...@@ -12,6 +11,7 @@ module.exports = [
name: 'register.result', name: 'register.result',
component: './User/RegisterResult', component: './User/RegisterResult',
}, },
{ path: '/user', redirect: '/user/login' },
{ {
component: '404', component: '404',
}, },
...@@ -25,7 +25,6 @@ module.exports = [ ...@@ -25,7 +25,6 @@ module.exports = [
authority: ['admin', 'user'], authority: ['admin', 'user'],
routes: [ routes: [
// dashboard // dashboard
{ path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] },
{ {
path: '/dashboard', path: '/dashboard',
name: 'dashboard', name: 'dashboard',
...@@ -63,28 +62,6 @@ module.exports = [ ...@@ -63,28 +62,6 @@ module.exports = [
path: '/form/step-form', path: '/form/step-form',
name: 'stepform', name: 'stepform',
component: './Form/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', path: '/form/advanced-form',
...@@ -120,10 +97,6 @@ module.exports = [ ...@@ -120,10 +97,6 @@ module.exports = [
name: 'search-list', name: 'search-list',
component: './list/search', component: './list/search',
routes: [ routes: [
{
path: '/list/search',
redirect: '/list/search/articles',
},
{ {
path: '/list/search/articles', path: '/list/search/articles',
name: 'articles', name: 'articles',
...@@ -139,6 +112,10 @@ module.exports = [ ...@@ -139,6 +112,10 @@ module.exports = [
name: 'applications', name: 'applications',
component: './list/Applications', component: './list/Applications',
}, },
{
path: '/list/search',
redirect: '/list/search/articles',
},
], ],
}, },
], ],
...@@ -213,51 +190,11 @@ module.exports = [ ...@@ -213,51 +190,11 @@ module.exports = [
path: '/account/center', path: '/account/center',
name: 'center', name: 'center',
component: './Account/Center/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', path: '/account/settings',
name: 'settings', name: 'settings',
component: './Account/Settings/Info', 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 = [ ...@@ -284,6 +221,7 @@ module.exports = [
}, },
], ],
}, },
{ path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] },
{ {
component: '404', component: '404',
}, },
......
...@@ -25,17 +25,13 @@ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & { ...@@ -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 => { return menuList.map(item => {
const localItem = { const localItem = {
...item, ...item,
name: children: item.children ? menuDataRender(item.children) : [],
item.locale && locale
? formatMessage({ id: item.locale, defaultMessage: item.name })
: item.name,
children: item.children ? filterMenuData(item.children, locale) : [],
}; };
return Authorized.check(item.authority, localItem, null) as MenuDataItem; return Authorized.check(item.authority, localItem, null) as MenuDataItem;
...@@ -56,9 +52,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => { ...@@ -56,9 +52,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
*/ */
const handleMenuCollapse = (payload: boolean) => const handleMenuCollapse = (payload: boolean) =>
dispatch!({ type: 'global/changeLayoutCollapsed', payload }); dispatch!({ type: 'global/changeLayoutCollapsed', payload });
const {
menu: { locale },
} = settings;
return ( return (
<> <>
<BasicLayoutComponents <BasicLayoutComponents
...@@ -67,7 +61,20 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => { ...@@ -67,7 +61,20 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
menuItemRender={(menuItemProps, defaultDom) => { menuItemRender={(menuItemProps, defaultDom) => {
return <Link to={menuItemProps.path}>{defaultDom}</Link>; 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} />} rightContentRender={rightProps => <RightContent {...rightProps} />}
{...props} {...props}
{...settings} {...settings}
...@@ -85,7 +92,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => { ...@@ -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