Unverified Commit 8ce6a73c authored by 陈帅's avatar 陈帅 Committed by GitHub

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
parent 5a9d3c07
{ {
"name": "ant-design-pro", "name": "ant-design-pro",
"version": "2.2.0", "version": "2.2.1",
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"private": true, "private": true,
"scripts": { "scripts": {
......
...@@ -6,5 +6,8 @@ module.exports = { ...@@ -6,5 +6,8 @@ module.exports = {
fixedHeader: false, // sticky header fixedHeader: false, // sticky header
autoHideHeader: false, // auto hide header autoHideHeader: false, // auto hide header
fixSiderbar: false, // sticky siderbar fixSiderbar: false, // sticky siderbar
menu: {
disableLocal: false,
},
title: 'Ant Design Pro', title: 'Ant Design Pro',
}; };
...@@ -17,7 +17,8 @@ import Context from './MenuContext'; ...@@ -17,7 +17,8 @@ import Context from './MenuContext';
import Exception403 from '../pages/Exception/403'; import Exception403 from '../pages/Exception/403';
import PageLoading from '@/components/PageLoading'; import PageLoading from '@/components/PageLoading';
import SiderMenu from '@/components/SiderMenu'; import SiderMenu from '@/components/SiderMenu';
import { title } from '../defaultSettings'; import { menu, title } from '../defaultSettings';
import styles from './BasicLayout.less'; import styles from './BasicLayout.less';
// lazy load SettingDrawer // lazy load SettingDrawer
...@@ -118,10 +119,12 @@ class BasicLayout extends React.PureComponent { ...@@ -118,10 +119,12 @@ class BasicLayout extends React.PureComponent {
if (!currRouterData) { if (!currRouterData) {
return title; return title;
} }
const pageName = formatMessage({ const pageName = menu.disableLocal
id: currRouterData.locale || currRouterData.name, ? currRouterData.name
defaultMessage: currRouterData.name, : formatMessage({
}); id: currRouterData.locale || currRouterData.name,
defaultMessage: currRouterData.name,
});
return `${pageName} - ${title}`; return `${pageName} - ${title}`;
}; };
...@@ -220,11 +223,11 @@ class BasicLayout extends React.PureComponent { ...@@ -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, collapsed: global.collapsed,
layout: setting.layout, layout: setting.layout,
menuData: menu.menuData, menuData: menuModel.menuData,
breadcrumbNameMap: menu.breadcrumbNameMap, breadcrumbNameMap: menuModel.breadcrumbNameMap,
...setting, ...setting,
}))(props => ( }))(props => (
<Media query="(max-width: 599px)"> <Media query="(max-width: 599px)">
......
...@@ -2,6 +2,7 @@ import memoizeOne from 'memoize-one'; ...@@ -2,6 +2,7 @@ import memoizeOne from 'memoize-one';
import isEqual from 'lodash/isEqual'; import isEqual from 'lodash/isEqual';
import { formatMessage } from 'umi/locale'; import { formatMessage } from 'umi/locale';
import Authorized from '@/utils/Authorized'; import Authorized from '@/utils/Authorized';
import { menu } from '../defaultSettings';
const { check } = Authorized; const { check } = Authorized;
...@@ -19,10 +20,14 @@ function formatter(data, parentAuthority, parentName) { ...@@ -19,10 +20,14 @@ function formatter(data, parentAuthority, parentName) {
} else { } else {
locale = `menu.${item.name}`; 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 = { const result = {
...item, ...item,
name: formatMessage({ id: locale, defaultMessage: item.name }), name,
locale, locale,
authority: item.authority || parentAuthority, authority: item.authority || parentAuthority,
}; };
......
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