diff --git a/src/common/menu.js b/src/common/menu.js index ebb219e4c894d340c041e63b94df5ba6434ee966..8293907383cac7284cef319d58397336c02ec1ee 100644 --- a/src/common/menu.js +++ b/src/common/menu.js @@ -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', }, ], diff --git a/src/components/SiderMenu/BaseMenu.js b/src/components/SiderMenu/BaseMenu.js index bdee72ac0661547cb853a77a265605386ca94cf2..fb86f7651db920fb74c03493e5ca64c703f89ad9 100644 --- a/src/components/SiderMenu/BaseMenu.js +++ b/src/components/SiderMenu/BaseMenu.js @@ -1,6 +1,7 @@ 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 = ; return ( {getIcon(item.icon)} - {item.name} + {name} ) : ( - item.name + name ) } key={item.path} > - {this.getNavMenuItems(item.children)} + {this.getNavMenuItems(item.children, id)} ); } else { - return {this.getMenuItemPath(item)}; + return {this.getMenuItemPath(item, parent)}; } }; @@ -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 = ; 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 ( diff --git a/src/components/SiderMenu/SliderMenu.js b/src/components/SiderMenu/SliderMenu.js index 3f61152f72d414e922b891ec049c76354e8c52b9..5dc9eb6020914524fd6e539a61646b70c5ec951e 100644 --- a/src/components/SiderMenu/SliderMenu.js +++ b/src/components/SiderMenu/SliderMenu.js @@ -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 ( {icon} - {name} + + + ); } @@ -131,7 +135,9 @@ export default class SiderMenu extends PureComponent { } > {icon} - {name} + + + ); }; diff --git a/src/locale/en-US.js b/src/locale/en-US.js index a87f05315cfeda92e7352bc367a010462a284abe..38af6eaba93ff54bd8de8999dd70af7887e894aa 100644 --- a/src/locale/en-US.js +++ b/src/locale/en-US.js @@ -9,6 +9,7 @@ export default { messages: { 'app.home.introduce': 'introduce', 'app.analysis.test': 'Gongzhuan road No.{no} shop', - // ...enMessages, + + // ...enMessages, }, }; diff --git a/src/locale/zh-CN.js b/src/locale/zh-CN.js index 9f5cb2231cec759af39077766bdc9a1d7e68661a..b3eb7138a23405da06fd7833a8642d2f6a256504 100644 --- a/src/locale/zh-CN.js +++ b/src/locale/zh-CN.js @@ -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, }, }; diff --git a/src/router.js b/src/router.js index 88c8351739dc056c2f57e7bf22cae9b3e90edbd8..8c296afcaca2bbec8b24ecb7af8311365746c9fd 100644 --- a/src/router.js +++ b/src/router.js @@ -12,6 +12,7 @@ import cnLocale from './locale/zh-CN'; const { ConnectedRouter } = routerRedux; const { AuthorizedRoute } = Authorized; + dynamic.setDefaultLoadingComponent(() => { return ; });