Commit 113fe538 authored by afc163's avatar afc163

Merge branch 'master' of github.com:ant-design/ant-design-pro

parents 780c13fa 14210374
...@@ -15,6 +15,7 @@ export default [ ...@@ -15,6 +15,7 @@ export default [
path: '/', path: '/',
component: '../layouts/BasicLayout', component: '../layouts/BasicLayout',
Routes: ['src/pages/Authorized'], Routes: ['src/pages/Authorized'],
authority: ['admin', 'user'],
routes: [ routes: [
// dashboard // dashboard
{ path: '/', redirect: '/dashboard/analysis' }, { path: '/', redirect: '/dashboard/analysis' },
...@@ -82,6 +83,7 @@ export default [ ...@@ -82,6 +83,7 @@ export default [
{ {
path: '/form/advanced-form', path: '/form/advanced-form',
name: 'advancedform', name: 'advancedform',
authority: ['admin'],
component: './Forms/AdvancedForm', component: './Forms/AdvancedForm',
}, },
], ],
...@@ -149,6 +151,7 @@ export default [ ...@@ -149,6 +151,7 @@ export default [
{ {
path: '/profile/advanced', path: '/profile/advanced',
name: 'advanced', name: 'advanced',
authority: ['admin'],
component: './Profile/AdvancedProfile', component: './Profile/AdvancedProfile',
}, },
], ],
......
import * as React from 'react'; import * as React from 'react';
export interface IChartCardProps { import { CardProps } from 'antd/lib/card';
export interface IChartCardProps extends CardProps {
title: React.ReactNode; title: React.ReactNode;
action?: React.ReactNode; action?: React.ReactNode;
total?: React.ReactNode | number | (() => React.ReactNode | number); total?: React.ReactNode | number | (() => React.ReactNode | number);
......
...@@ -21,7 +21,7 @@ export interface IMiniAreaProps { ...@@ -21,7 +21,7 @@ export interface IMiniAreaProps {
xAxis?: IAxis; xAxis?: IAxis;
yAxis?: IAxis; yAxis?: IAxis;
data: Array<{ data: Array<{
x: number; x: number | string;
y: number; y: number;
}>; }>;
} }
......
...@@ -74,7 +74,7 @@ export default class GlobalHeaderRight extends PureComponent { ...@@ -74,7 +74,7 @@ export default class GlobalHeaderRight extends PureComponent {
<Menu.Divider /> <Menu.Divider />
<Menu.Item key="logout"> <Menu.Item key="logout">
<Icon type="logout" /> <Icon type="logout" />
退出登录 <FormattedMessage id="menu.account.logout" defaultMessage="logout" />
</Menu.Item> </Menu.Item>
</Menu> </Menu>
); );
......
...@@ -55,7 +55,6 @@ i.trigger { ...@@ -55,7 +55,6 @@ i.trigger {
transition: all 0.3s; transition: all 0.3s;
height: 100%; height: 100%;
> i { > i {
font-size: 18px;
vertical-align: middle; vertical-align: middle;
color: @text-color; color: @text-color;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
} }
.icon { .icon {
font-size: 18px;
padding: 4px; padding: 4px;
} }
......
...@@ -87,7 +87,7 @@ export default class SiderMenu extends PureComponent { ...@@ -87,7 +87,7 @@ export default class SiderMenu extends PureComponent {
}; };
render() { render() {
const { logo, collapsed, onCollapse, fixSiderbar, theme } = this.props; const { logo, collapsed, fixSiderbar, theme } = this.props;
const { openKeys } = this.state; const { openKeys } = this.state;
const defaultProps = collapsed ? {} : { openKeys }; const defaultProps = collapsed ? {} : { openKeys };
...@@ -95,14 +95,12 @@ export default class SiderMenu extends PureComponent { ...@@ -95,14 +95,12 @@ export default class SiderMenu extends PureComponent {
[styles.fixSiderbar]: fixSiderbar, [styles.fixSiderbar]: fixSiderbar,
[styles.light]: theme === 'light', [styles.light]: theme === 'light',
}); });
return ( return (
<Sider <Sider
trigger={null} trigger={null}
collapsible collapsible
collapsed={collapsed} collapsed={collapsed}
breakpoint="lg" breakpoint="lg"
onCollapse={onCollapse}
width={256} width={256}
theme={theme} theme={theme}
className={siderClassName} className={siderClassName}
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
position: fixed; position: fixed;
top: 0; top: 0;
width: 100%; width: 100%;
z-index: 9; // > @zindex-tooltip
z-index: 1061;
transition: width 0.2s; transition: width 0.2s;
} }
...@@ -35,6 +35,7 @@ export default { ...@@ -35,6 +35,7 @@ export default {
'menu.account.center': 'Account Center', 'menu.account.center': 'Account Center',
'menu.account.settings': 'Account Settings', 'menu.account.settings': 'Account Settings',
'menu.account.trigger': 'Trigger Error', 'menu.account.trigger': 'Trigger Error',
'menu.account.logout': 'Logout',
'app.home.introduce': 'introduce', 'app.home.introduce': 'introduce',
'app.analysis.test': 'Gongzhuan No.{no} shop', 'app.analysis.test': 'Gongzhuan No.{no} shop',
'app.analysis.introduce': 'Introduce', 'app.analysis.introduce': 'Introduce',
......
...@@ -37,6 +37,7 @@ export default { ...@@ -37,6 +37,7 @@ export default {
'menu.account.center': '个人中心', 'menu.account.center': '个人中心',
'menu.account.settings': '个人设置', 'menu.account.settings': '个人设置',
'menu.account.trigger': '触发报错', 'menu.account.trigger': '触发报错',
'menu.account.logout': '退出登录',
'app.home.introduce': '介绍', 'app.home.introduce': '介绍',
'app.analysis.test': '工专路 {no} 号店', 'app.analysis.test': '工专路 {no} 号店',
'app.analysis.introduce': '指标说明', 'app.analysis.introduce': '指标说明',
......
...@@ -2,24 +2,15 @@ import React from 'react'; ...@@ -2,24 +2,15 @@ import React from 'react';
import RenderAuthorized from '@/components/Authorized'; import RenderAuthorized from '@/components/Authorized';
import Exception from '@/components/Exception'; import Exception from '@/components/Exception';
import { getAuthority } from '@/utils/authority'; import { getAuthority } from '@/utils/authority';
import { matchRoutes } from 'react-router-config';
import intersection from 'lodash/intersection';
import { formatMessage } from 'umi/locale'; import { formatMessage } from 'umi/locale';
import Link from 'umi/link'; import Link from 'umi/link';
import Redirect from 'umi/redirect';
const Authorized = RenderAuthorized(getAuthority()); const Authority = getAuthority();
const Authorized = RenderAuthorized(Authority);
export default ({ children, route, location }) => { export default ({ children }) => {
const routes = matchRoutes(route.routes, location.pathname); let noMatch = (
const authorities = [];
routes.forEach(item => {
if (Array.isArray(item.route.authority) && item.route.authority.length) {
authorities.push(item.route.authority);
} else if (typeof item.route.authority === 'string' && item.route.authority) {
authorities.push([item.route.authority]);
}
});
const noMatch = (
<Exception <Exception
type="403" type="403"
desc={formatMessage({ id: 'app.exception.description.403' })} desc={formatMessage({ id: 'app.exception.description.403' })}
...@@ -27,11 +18,13 @@ export default ({ children, route, location }) => { ...@@ -27,11 +18,13 @@ export default ({ children, route, location }) => {
backText={formatMessage({ id: 'app.exception.back' })} backText={formatMessage({ id: 'app.exception.back' })}
/> />
); );
// if Authority === ['guest'] redirect to /user/login
// You can implement the logic here.
if (Authority.join('') === 'guest') {
noMatch = <Redirect to="/user/login" />;
}
return ( return (
<Authorized <Authorized authority={children.props.route.authority} noMatch={noMatch}>
authority={authorities.length === 0 ? undefined : intersection(...authorities)}
noMatch={noMatch}
>
{children} {children}
</Authorized> </Authorized>
); );
......
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