提交 de0cf3da 编写于 作者: 陈帅

use new local

上级 37644852
......@@ -31,7 +31,7 @@ export interface DefaultSettings {
* sticky siderbar
*/
fixSiderbar: boolean;
menu: { disableLocal: boolean };
menu: { locale: boolean };
title: string;
pwa: boolean;
// Your custom iconfont Symbol script Url
......@@ -52,7 +52,7 @@ export default {
fixSiderbar: false,
colorWeak: false,
menu: {
disableLocal: false,
locale: true,
},
title: 'Ant Design Pro',
pwa: true,
......
......@@ -132,7 +132,7 @@
"umi": "^2.6.17",
"umi-plugin-ga": "^1.1.3",
"umi-plugin-pro-block": "^1.3.0",
"umi-plugin-react": "^1.7.2",
"umi-plugin-react": "^1.8.0-beta.1",
"umi-request": "^1.0.0"
},
"optionalDependencies": {
......
......@@ -4,6 +4,7 @@ import PromiseRender from './PromiseRender';
import { CURRENT } from './renderAuthorize';
export type IAuthorityType =
| undefined
| string
| string[]
| Promise<any>
......
......@@ -12,7 +12,7 @@ interface SelectLangProps {
const SelectLang: React.FC<SelectLangProps> = props => {
const { className } = props;
const selectedLang = getLocale();
const changeLang = ({ key }: ClickParam) => setLocale(key);
const changeLang = ({ key }: ClickParam) => setLocale(key, false);
const locales = ['zh-CN', 'zh-TW', 'en-US', 'pt-BR'];
const languageLabels = {
'zh-CN': '简体中文',
......
......@@ -3,6 +3,8 @@ import RightContent from '@/components/GlobalHeader/RightContent';
import { connect } from 'dva';
import React, { useState } from 'react';
import logo from '../assets/logo.svg';
import Authorized from '@/utils/Authorized';
import { formatMessage } from 'umi-plugin-react/locale';
import {
BasicLayout as BasicLayoutComponents,
BasicLayoutProps as BasicLayoutComponentsProps,
......@@ -21,6 +23,19 @@ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
breadcrumbNameMap: { [path: string]: MenuDataItem };
};
/**
* default menuLocal
*/
const filterMenuData = (menuList: MenuDataItem[], locale: boolean) => {
return menuList.map(item => {
const localItem = {
...item,
name: item.locale && locale ? formatMessage({ id: item.locale }) : item.name,
};
return Authorized.check(item.authority, localItem, null) as MenuDataItem;
});
};
const BasicLayout: React.FC<BasicLayoutProps> = props => {
const { dispatch, children, settings } = props;
/**
......@@ -35,7 +50,9 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
*/
const handleMenuCollapse = (payload: boolean) =>
dispatch!({ type: 'global/changeLayoutCollapsed', payload });
const {
menu: { locale },
} = settings;
return (
<>
<BasicLayoutComponents
......@@ -44,6 +61,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
menuItemRender={(menuItemProps, defaultDom) => {
return <Link to={menuItemProps.path}>{defaultDom}</Link>;
}}
filterMenuData={menuList => filterMenuData(menuList, locale)}
rightContentRender={rightProps => <RightContent {...rightProps} />}
{...props}
{...settings}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册