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
P
pro-blocks
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
pro-blocks
Commits
81774c23
Commit
81774c23
authored
Jul 05, 2018
by
陈帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rebase: rebase v2
parent
f07927f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
17 deletions
+30
-17
src/router.js
src/router.js
+30
-17
No files found.
src/router.js
View file @
81774c23
import
React
from
'
react
'
;
import
{
routerRedux
,
Route
,
Switch
}
from
'
dva/router
'
;
import
{
Spin
}
from
'
antd
'
;
import
{
LocaleProvider
,
Spin
}
from
'
antd
'
;
import
dynamic
from
'
dva/dynamic
'
;
import
{
LocalComponent
}
from
'
./locale/localeContext
'
;
import
{
addLocaleData
,
IntlProvider
}
from
'
react-intl
'
;
import
{
getRouterData
}
from
'
./common/router
'
;
import
Authorized
from
'
./utils/Authorized
'
;
import
{
getQueryPath
}
from
'
./utils/utils
'
;
import
styles
from
'
./index.less
'
;
import
enLocale
from
'
./locale/en-US
'
;
import
cnLocale
from
'
./locale/zh-CN
'
;
const
{
ConnectedRouter
}
=
routerRedux
;
const
{
AuthorizedRoute
}
=
Authorized
;
dynamic
.
setDefaultLoadingComponent
(()
=>
{
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
})
{
const
routerData
=
getRouterData
(
app
);
const
UserLayout
=
routerData
[
'
/user
'
].
component
;
const
BasicLayout
=
routerData
[
'
/
'
].
component
;
const
appLocale
=
getLang
()
===
'
zh-CN
'
?
cnLocale
:
enLocale
;
addLocaleData
(
appLocale
.
data
);
return
(
<
LocalComponent
>
<
ConnectedRouter
history
=
{
history
}
>
<
Switch
>
<
Route
path
=
"
/user
"
component
=
{
UserLayout
}
/
>
<
AuthorizedRoute
path
=
"
/
"
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
authority
=
{[
'
admin
'
,
'
user
'
]}
redirectPath
=
"
/user/login
"
/>
<
/Switch
>
<
/ConnectedRouter
>
<
/LocalComponent
>
<
IntlProvider
locale
=
{
appLocale
.
locale
}
messages
=
{
appLocale
.
messages
}
>
<
LocaleProvider
locale
=
{
appLocale
.
antd
}
>
<
ConnectedRouter
history
=
{
history
}
>
<
Switch
>
<
Route
path
=
"
/user
"
component
=
{
UserLayout
}
/
>
<
AuthorizedRoute
path
=
"
/
"
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
authority
=
{[
'
admin
'
,
'
user
'
]}
redirectPath
=
{
getQueryPath
(
'
/user/login
'
,
{
redirect
:
window
.
location
.
href
,
})}
/
>
<
/Switch
>
<
/ConnectedRouter
>
<
/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