From 8ce6a73cf07795f942bbce104c94823638292564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Thu, 17 Jan 2019 20:17:16 +0800 Subject: [PATCH] feat: add new config "menu.enableLocale" (#3310) * feat: add new config "layoutLocal" * Use enableLayoutLocale instead of layoutLocale * Use enableMenuLocale instead of enableMenuLocale * use menu.disableLocal --- package.json | 2 +- src/defaultSettings.js | 3 +++ src/layouts/BasicLayout.js | 19 +++++++++++-------- src/models/menu.js | 9 +++++++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index f2b4fe0e..52f298c9 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 0c611097..ad025cae 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 914f47f8..bd7e6eb9 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 9cc54fb5..218c7065 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, }; -- GitLab