Commit 4caebc00 authored by 陈帅's avatar 陈帅

add meun Intl

parent 663e34ab
......@@ -202,15 +202,15 @@ const menuData = [
path: 'dashboard',
children: [
{
name: '分析页',
name: 'analysis',
path: 'analysis',
},
{
name: '监控页',
name: 'monitor',
path: 'monitor',
},
{
name: '工作台',
name: 'workplace',
path: 'workplace',
// hideInBreadcrumb: true,
// hideInMenu: true,
......@@ -218,56 +218,61 @@ const menuData = [
],
},
{
name: '表单页',
name: 'form',
icon: 'form',
path: 'form',
children: [
{
name: '基础表单',
name: 'basicform',
path: 'basic-form',
},
{
name: '分步表单',
name: 'stepform',
path: 'step-form',
},
{
<<<<<<< HEAD
name: '高级表单',
// authority: 'admin',
=======
name: 'advancedform',
authority: 'admin',
>>>>>>> add meun Intl
path: 'advanced-form',
},
],
},
{
name: '列表页',
name: 'list',
icon: 'table',
path: 'list',
children: [
{
name: '查询表格',
name: 'searchlist',
path: 'table-list',
},
{
name: '标准列表',
name: 'basiclist',
path: 'basic-list',
},
{
name: '卡片列表',
name: 'cardlist',
path: 'card-list',
},
{
name: '搜索列表',
name: 'searchlist',
path: 'search',
children: [
{
name: '搜索列表(文章)',
name: 'articles',
path: 'articles',
},
{
name: '搜索列表(项目)',
name: 'projects',
path: 'projects',
},
{
name: '搜索列表(应用)',
name: 'applications',
path: 'applications',
},
],
......@@ -275,91 +280,91 @@ const menuData = [
],
},
{
name: '详情页',
name: 'profile',
icon: 'profile',
path: 'profile',
children: [
{
name: '基础详情页',
name: 'basic',
path: 'basic',
},
{
name: '高级详情页',
name: 'advanced',
path: 'advanced',
// authority: 'admin',
},
],
},
{
name: '结果页',
name: 'result',
icon: 'check-circle-o',
path: 'result',
children: [
{
name: '成功',
name: 'success',
path: 'success',
},
{
name: '失败',
name: 'fail',
path: 'fail',
},
],
},
{
name: '异常页',
name: 'exception',
icon: 'warning',
path: 'exception',
children: [
{
name: '403',
name: 'not-permission',
path: '403',
},
{
name: '404',
name: 'not-find',
path: '404',
},
{
name: '500',
name: 'server-error',
path: '500',
},
// {
// name: '触发异常',
// path: 'triggerException',
// hideInMenu: true,
// },
{
name: 'trigger',
path: 'trigger',
hideInMenu: true,
},
],
},
{
name: '账户',
name: 'user',
icon: 'user',
path: 'User',
authority: 'guest',
children: [
{
name: '登录',
name: 'login',
path: 'login',
},
{
name: '注册',
name: 'register',
path: 'register',
},
{
name: '注册结果',
name: 'register-result',
path: 'register-result',
},
],
},
{
name: '个人页',
name: 'account',
icon: 'user',
path: 'account',
children: [
{
name: '个人中心',
name: 'center',
path: 'center',
},
{
name: '个人设置',
name: 'settings',
path: 'settings',
},
],
......
import React, { PureComponent } from 'react';
import { Menu, Icon } from 'antd';
import { Link } from 'dva/router';
import { FormattedMessage } from 'react-intl';
import pathToRegexp from 'path-to-regexp';
import { urlToList } from '../_utils/pathTools';
import styles from './index.less';
......@@ -53,7 +54,7 @@ export default class BaseMenu extends PureComponent {
* 获得菜单子节点
* @memberof SiderMenu
*/
getNavMenuItems = menusData => {
getNavMenuItems = (menusData, parent) => {
if (!menusData) {
return [];
}
......@@ -61,7 +62,7 @@ export default class BaseMenu extends PureComponent {
.filter(item => item.name && !item.hideInMenu)
.map(item => {
// make dom
const ItemDom = this.getSubMenuOrItem(item);
const ItemDom = this.getSubMenuOrItem(item, parent);
return this.checkPermissionItem(item.authority, ItemDom);
})
.filter(item => item);
......@@ -78,27 +79,29 @@ export default class BaseMenu extends PureComponent {
/**
* get SubMenu or Item
*/
getSubMenuOrItem = item => {
getSubMenuOrItem = (item, parent) => {
const id = parent ? `${parent}.${item.name}` : `menu.${item.name}`;
if (item.children && item.children.some(child => child.name)) {
const name = <FormattedMessage defaultMessage={item.name} id={id} />;
return (
<SubMenu
title={
item.icon ? (
<span>
{getIcon(item.icon)}
<span>{item.name}</span>
<span>{name}</span>
</span>
) : (
item.name
name
)
}
key={item.path}
>
{this.getNavMenuItems(item.children)}
{this.getNavMenuItems(item.children, id)}
</SubMenu>
);
} else {
return <Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item>;
return <Menu.Item key={item.path}>{this.getMenuItemPath(item, parent)}</Menu.Item>;
}
};
......@@ -107,10 +110,12 @@ export default class BaseMenu extends PureComponent {
* Judge whether it is http link.return a or Link
* @memberof SiderMenu
*/
getMenuItemPath = item => {
getMenuItemPath = (item, parent) => {
const id = parent ? `${parent}.${item.name}` : `menu.${item.name}`;
const name = <FormattedMessage defaultMessage={item.name} id={id} />;
const itemPath = this.conversionPath(item.path);
const icon = getIcon(item.icon);
const { target, name } = item;
const { target } = item;
// Is it a http link
if (/^https?:\/\//.test(itemPath)) {
return (
......
......@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import { Layout, Menu, Icon } from 'antd';
import pathToRegexp from 'path-to-regexp';
import { Link } from 'dva/router';
import { FormattedMessage } from 'react-intl';
import styles from './index.less';
import BaseMenu, { getMenuMatches } from './BaseMenu';
import { urlToList } from '../_utils/pathTools';
......@@ -104,6 +105,7 @@ export default class SiderMenu extends PureComponent {
* @memberof SiderMenu
*/
getMenuItemPath = item => {
console.log(item);
const itemPath = this.conversionPath(item.path);
const icon = getIcon(item.icon);
const { target, name } = item;
......@@ -112,7 +114,9 @@ export default class SiderMenu extends PureComponent {
return (
<a href={itemPath} target={target}>
{icon}
<span>{name}</span>
<span>
<FormattedMessage id={name} />
</span>
</a>
);
}
......@@ -131,7 +135,9 @@ export default class SiderMenu extends PureComponent {
}
>
{icon}
<span>{name}</span>
<span>
<FormattedMessage id={name} />
</span>
</Link>
);
};
......
......@@ -9,6 +9,7 @@ export default {
messages: {
'app.home.introduce': 'introduce',
'app.analysis.test': 'Gongzhuan road No.{no} shop',
// ...enMessages,
// ...enMessages,
},
};
......@@ -9,6 +9,35 @@ export default {
messages: {
'app.home.introduce': '介绍',
'app.analysis.test': '工专路 {no} 号店',
// ...zhMessages,
'menu.dashboard': '仪表盘',
'menu.dashboard.analysis': '分析页',
'menu.dashboard.monitor': '监控页',
'menu.dashboard.workplace': '工作台',
'menu.form': '表单页',
'menu.form.basicform': '基础表单',
'menu.form.stepform': '分布表单',
'menu.form.advancedform': '高级表单',
'menu.list': '列表页',
'menu.list.searchlist': '搜索列表',
'menu.list.basiclist': '标准列表',
'menu.list.cardlist': '卡片列表',
'menu.list.searchlist.articles': '搜索列表(文章)',
'menu.list.searchlist.projects': '搜索列表(项目)',
'menu.list.searchlist.applications': '搜索列表(列表)',
'menu.profile': '详情页',
'menu.profile.basic': '详情页',
'menu.profile.advanced': '详情页',
'menu.result': '结果页',
'menu.result.success': '成功页',
'menu.result.fail': '成功页',
'menu.exception': '异常页',
'menu.exception.not-permission': '403',
'menu.exception.not-find': '404',
'menu.exception.server-error': '500',
'menu.exception.trigger': '触发错误',
'menu.account': '个人页',
'menu.account.center': '个人中心',
'menu.account.settings': '个人设置',
// ...zhMessages,
},
};
......@@ -12,6 +12,7 @@ import cnLocale from './locale/zh-CN';
const { ConnectedRouter } = routerRedux;
const { AuthorizedRoute } = Authorized;
dynamic.setDefaultLoadingComponent(() => {
return <Spin size="large" className={styles.globalSpin} />;
});
......
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