Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
9d25d636
Commit
9d25d636
authored
Jul 07, 2018
by
ιεΈ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: fix locale context is null
parent
aa50ab40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
30 deletions
+17
-30
src/router.js
src/router.js
+17
-30
No files found.
src/router.js
View file @
9d25d636
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
routerRedux
,
Route
,
Switch
}
from
'
dva/router
'
;
import
{
routerRedux
,
Route
,
Switch
}
from
'
dva/router
'
;
import
{
LocaleProvider
,
Spin
}
from
'
antd
'
;
import
{
Spin
}
from
'
antd
'
;
import
dynamic
from
'
dva/dynamic
'
;
import
dynamic
from
'
dva/dynamic
'
;
import
{
addLocaleData
,
IntlProvider
}
from
'
react-intl
'
;
import
{
getRouterData
}
from
'
./common/router
'
;
import
{
getRouterData
}
from
'
./common/router
'
;
import
Authorized
from
'
./utils/Authorized
'
;
import
Authorized
from
'
./utils/Authorized
'
;
import
{
getQueryPath
}
from
'
./utils/utils
'
;
import
{
getQueryPath
}
from
'
./utils/utils
'
;
import
{
LocalComponent
}
from
'
./locale/localeContext
'
;
import
styles
from
'
./index.less
'
;
import
styles
from
'
./index.less
'
;
import
enLocale
from
'
./locale/en-US
'
;
import
cnLocale
from
'
./locale/zh-CN
'
;
const
{
ConnectedRouter
}
=
routerRedux
;
const
{
ConnectedRouter
}
=
routerRedux
;
const
{
AuthorizedRoute
}
=
Authorized
;
const
{
AuthorizedRoute
}
=
Authorized
;
...
@@ -16,37 +14,26 @@ dynamic.setDefaultLoadingComponent(() => {
...
@@ -16,37 +14,26 @@ dynamic.setDefaultLoadingComponent(() => {
return
<
Spin
size
=
"
large
"
className
=
{
styles
.
globalSpin
}
/>
;
return
<
Spin
size
=
"
large
"
className
=
{
styles
.
globalSpin
}
/>
;
});
});
function
getLang
()
{
return
(
window
.
localStorage
&&
localStorage
.
getItem
(
'
locale
'
))
||
(
navigator
.
language
||
navigator
.
browserLanguage
).
toLowerCase
()
===
'
en-us
'
?
'
en-US
'
:
'
zh-CN
'
;
}
function
RouterConfig
({
history
,
app
})
{
function
RouterConfig
({
history
,
app
})
{
const
routerData
=
getRouterData
(
app
);
const
routerData
=
getRouterData
(
app
);
const
UserLayout
=
routerData
[
'
/user
'
].
component
;
const
UserLayout
=
routerData
[
'
/user
'
].
component
;
const
BasicLayout
=
routerData
[
'
/
'
].
component
;
const
BasicLayout
=
routerData
[
'
/
'
].
component
;
const
appLocale
=
getLang
()
===
'
zh-CN
'
?
cnLocale
:
enLocale
;
addLocaleData
(
appLocale
.
data
);
return
(
return
(
<
IntlProvider
locale
=
{
appLocale
.
locale
}
messages
=
{
appLocale
.
messages
}
>
<
LocalComponent
>
<
LocaleProvider
locale
=
{
appLocale
.
antd
}
>
<
ConnectedRouter
history
=
{
history
}
>
<
ConnectedRouter
history
=
{
history
}
>
<
Switch
>
<
Switch
>
<
Route
path
=
"
/user
"
component
=
{
UserLayout
}
/
>
<
Route
path
=
"
/user
"
component
=
{
UserLayout
}
/
>
<
AuthorizedRoute
<
AuthorizedRoute
path
=
"
/
"
path
=
"
/
"
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
authority
=
{[
'
admin
'
,
'
user
'
]}
authority
=
{[
'
admin
'
,
'
user
'
]}
redirectPath
=
{
getQueryPath
(
'
/user/login
'
,
{
redirectPath
=
{
getQueryPath
(
'
/user/login
'
,
{
redirect
:
window
.
location
.
href
,
redirect
:
window
.
location
.
href
,
})}
})}
/
>
/
>
<
/Switch
>
<
/Switch
>
<
/ConnectedRouter
>
<
/ConnectedRouter
>
<
/LocalComponent
>
<
/LocaleProvider
>
<
/IntlProvider
>
);
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment