Skip to content

Commit

Permalink
locale example
Browse files Browse the repository at this point in the history
  • Loading branch information
zuiidea committed Feb 26, 2018
2 parents cd54fcb + 3fde5aa commit 9a4c633
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/components/Layout/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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>
Expand Down
18 changes: 11 additions & 7 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -82,9 +85,10 @@ const Routers = function ({ history, app }) {
/>
))
}
<Route component={error} />
</Switch>
</App>
<Route component={error} />
</Switch>
</App>
</LocaleProvider>
</ConnectedRouter>
)
}
Expand Down

0 comments on commit 9a4c633

Please sign in to comment.