diff --git a/package.json b/package.json index f2b4fe0e6f5a575dd0a705db4a6b97a144b95e10..52f298c9b3c7cf68b8743e0abdb966815f91ff5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ant-design-pro", - "version": "2.2.0", + "version": "2.2.1", "description": "An out-of-box UI solution for enterprise applications", "private": true, "scripts": { diff --git a/src/defaultSettings.js b/src/defaultSettings.js index 0c61109719fe305522f29e963194a502fb1d33f1..ad025caec5651ce2b2b942991ca3ae54bc034ced 100644 --- a/src/defaultSettings.js +++ b/src/defaultSettings.js @@ -6,5 +6,8 @@ module.exports = { fixedHeader: false, // sticky header autoHideHeader: false, // auto hide header fixSiderbar: false, // sticky siderbar + menu: { + disableLocal: false, + }, title: 'Ant Design Pro', }; diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 914f47f8ce81adc592bde2361c6587893d21a59a..bd7e6eb9d447f05b14a6438ebec43f6bbea670ac 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -17,7 +17,8 @@ import Context from './MenuContext'; import Exception403 from '../pages/Exception/403'; import PageLoading from '@/components/PageLoading'; import SiderMenu from '@/components/SiderMenu'; -import { title } from '../defaultSettings'; +import { menu, title } from '../defaultSettings'; + import styles from './BasicLayout.less'; // lazy load SettingDrawer @@ -118,10 +119,12 @@ class BasicLayout extends React.PureComponent { if (!currRouterData) { return title; } - const pageName = formatMessage({ - id: currRouterData.locale || currRouterData.name, - defaultMessage: currRouterData.name, - }); + const pageName = menu.disableLocal + ? currRouterData.name + : formatMessage({ + id: currRouterData.locale || currRouterData.name, + defaultMessage: currRouterData.name, + }); return `${pageName} - ${title}`; }; @@ -220,11 +223,11 @@ class BasicLayout extends React.PureComponent { } } -export default connect(({ global, setting, menu }) => ({ +export default connect(({ global, setting, menu: menuModel }) => ({ collapsed: global.collapsed, layout: setting.layout, - menuData: menu.menuData, - breadcrumbNameMap: menu.breadcrumbNameMap, + menuData: menuModel.menuData, + breadcrumbNameMap: menuModel.breadcrumbNameMap, ...setting, }))(props => ( diff --git a/src/models/menu.js b/src/models/menu.js index 9cc54fb5d0857d944176c86577b586a0a38b7737..218c706513ea54fb2eb97ef0e2baf7195a8608b3 100644 --- a/src/models/menu.js +++ b/src/models/menu.js @@ -2,6 +2,7 @@ import memoizeOne from 'memoize-one'; import isEqual from 'lodash/isEqual'; import { formatMessage } from 'umi/locale'; import Authorized from '@/utils/Authorized'; +import { menu } from '../defaultSettings'; const { check } = Authorized; @@ -19,10 +20,14 @@ function formatter(data, parentAuthority, parentName) { } else { locale = `menu.${item.name}`; } - + // if enableMenuLocale use item.name, + // close menu international + const name = menu.disableLocal + ? item.name + : formatMessage({ id: locale, defaultMessage: item.name }); const result = { ...item, - name: formatMessage({ id: locale, defaultMessage: item.name }), + name, locale, authority: item.authority || parentAuthority, };