diff --git a/src/router.js b/src/router.js index bfc78e82529378d954cb4de3b681c9be5c225ce9..9cbe5402147f0b057380c05b2cd44959ec838736 100644 --- a/src/router.js +++ b/src/router.js @@ -1,14 +1,12 @@ import React from 'react'; import { routerRedux, Route, Switch } from 'dva/router'; -import { LocaleProvider, Spin } from 'antd'; +import { Spin } from 'antd'; import dynamic from 'dva/dynamic'; -import { addLocaleData, IntlProvider } from 'react-intl'; import { getRouterData } from './common/router'; import Authorized from './utils/Authorized'; import { getQueryPath } from './utils/utils'; +import { LocalComponent } from './locale/localeContext'; import styles from './index.less'; -import enLocale from './locale/en-US'; -import cnLocale from './locale/zh-CN'; const { ConnectedRouter } = routerRedux; const { AuthorizedRoute } = Authorized; @@ -16,37 +14,26 @@ dynamic.setDefaultLoadingComponent(() => { return ; }); -function getLang() { - return (window.localStorage && localStorage.getItem('locale')) || - (navigator.language || navigator.browserLanguage).toLowerCase() === 'en-us' - ? 'en-US' - : 'zh-CN'; -} - function RouterConfig({ history, app }) { const routerData = getRouterData(app); const UserLayout = routerData['/user'].component; const BasicLayout = routerData['/'].component; - const appLocale = getLang() === 'zh-CN' ? cnLocale : enLocale; - addLocaleData(appLocale.data); return ( - - - - - - } - authority={['admin', 'user']} - redirectPath={getQueryPath('/user/login', { - redirect: window.location.href, - })} - /> - - - - + + + + + } + authority={['admin', 'user']} + redirectPath={getQueryPath('/user/login', { + redirect: window.location.href, + })} + /> + + + ); }