locale example

This commit is contained in:
zuiidea
2018-02-26 19:19:42 +08:00
2 changed files with 15 additions and 9 deletions
+4 -2
View File
@@ -5,7 +5,9 @@ import { Link } from 'react-router-dom'
import { arrayToTree, queryArray } from 'utils'
import pathToRegexp from 'path-to-regexp'
const Menus = ({ siderFold, darkTheme, navOpenKeys, changeOpenKeys, menu, location }) => {
const Menus = ({
siderFold, darkTheme, navOpenKeys, changeOpenKeys, menu, location,
}) => {
// 生成树状
const menuTree = arrayToTree(menu.filter(_ => _.mpid !== '-1'), 'id', 'mpid')
const levelMap = {}
@@ -31,7 +33,7 @@ const Menus = ({ siderFold, darkTheme, navOpenKeys, changeOpenKeys, menu, locati
}
return (
<Menu.Item key={item.id}>
<Link to={item.route || '#'}>
<Link to={item.route || '#'} style={siderFoldN ? { width: 10 } : {}}>
{item.icon && <Icon type={item.icon} />}
{item.name}
</Link>
+11 -7
View File
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types'
import { Switch, Route, Redirect, routerRedux } from 'dva/router'
import dynamic from 'dva/dynamic'
import App from 'routes/app'
import { LocaleProvider } from 'antd'
import enUS from 'antd/lib/locale-provider/en_US'
const { ConnectedRouter } = routerRedux
@@ -67,10 +69,11 @@ const Routers = function ({ history, app }) {
return (
<ConnectedRouter history={history}>
<App>
<Switch>
<Route exact path="/" render={() => (<Redirect to="/dashboard" />)} />
{
<LocaleProvider locale={enUS}>
<App>
<Switch>
<Route exact path="/" render={() => (<Redirect to="/dashboard" />)} />
{
routes.map(({ path, ...dynamics }, key) => (
<Route key={key}
exact
@@ -82,9 +85,10 @@ const Routers = function ({ history, app }) {
/>
))
}
<Route component={error} />
</Switch>
</App>
<Route component={error} />
</Switch>
</App>
</LocaleProvider>
</ConnectedRouter>
)
}