Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ds147000
/
react-project-storage
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b95a07dd
authored
Jul 22, 2020
by
GGbong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加登录和登录后逻辑分离
1 parent
a229f795
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
src/router/router-view.js
src/router/router-view.js
View file @
b95a07d
...
...
@@ -12,14 +12,14 @@ import { getMenu } from '@/api/user'
import
{
Modal
}
from
'antd'
import
error401
from
"@/view/error/401"
import
error404
from
"@/view/error/404"
import
error404
from
"@/view/error/404"
import
fullScreenRoute
from
'./modules/fullScreenRoute'
/** 获取全部路由的路径 */
const
getAllRouterName
=
route
=>
route
.
map
(
e
=>
e
.
url
)
/** 路由视图 */
const
RouterView
=
({
basisRoute
=
[],
serviceRoute
=
[],
userRoute
=
[],
userSatatus
,
SYSTEM_LOGIN
})
=>
{
const
RouterView
=
({
basisRoute
=
[],
serviceRoute
=
[],
userRoute
=
[],
userSatatus
,
SYSTEM_LOGIN
})
=>
{
const
[
openRoute
,
setOpenRoute
]
=
useState
([])
const
history
=
useHistory
()
...
...
@@ -30,7 +30,7 @@ const RouterView = ({basisRoute = [], serviceRoute = [], userRoute = [], userSat
const
newRoutes
=
allRoute
.
map
(
e
=>
{
const
index
=
serviceRoute
.
findIndex
(
service
=>
service
.
url
===
e
.
url
)
const
newE
=
{
...
e
}
const
newE
=
{
...
e
}
if
(
index
!==
-
1
)
newE
.
component
=
serviceRoute
[
index
].
component
...
...
@@ -38,13 +38,13 @@ const RouterView = ({basisRoute = [], serviceRoute = [], userRoute = [], userSat
const
indexOfName
=
allName
.
findIndex
(
url
=>
url
===
e
.
url
)
if
(
indexOfName
!==
-
1
)
newE
.
component
=
serviceRoute
[
index
].
component
else
else
newE
.
component
=
()
=>
{
// location.href = APP.othreDomain + newE.url
return
(
<>
{
newE
.
url
}
<
/>
)
}
}
}
return
newE
})
...
...
@@ -54,8 +54,8 @@ const RouterView = ({basisRoute = [], serviceRoute = [], userRoute = [], userSat
useEffect
(()
=>
{
const
token
=
getToken
()
if
(
userSatatus
)
return
if
(
userSatatus
)
return
else
if
(
token
)
{
show
()
http
.
setHeader
(
'sessionid'
,
token
)
...
...
@@ -68,28 +68,27 @@ const RouterView = ({basisRoute = [], serviceRoute = [], userRoute = [], userSat
hide
()
Modal
.
error
({
title
:
'错误'
,
content
:
err
,
onOk
:
()
=>
history
.
replace
(
'/login'
)
})
})
}
else
}
else
history
.
replace
(
'/login'
)
},
[])
return
(
<>
{
userSatatus
?
<
Layout
>
<
Switch
>
{
basisRoute
.
map
(
e
=>
<
Route
path
=
{
e
.
url
}
exact
=
{
e
.
exact
}
component
=
{
Guards
(
e
.
component
)}
key
=
{
e
.
url
}
/>
)
}
{
openRoute
.
map
(
e
=>
<
Route
path
=
{
e
.
url
}
exact
=
{
e
.
exact
}
component
=
{
Guards
(
e
.
component
)}
key
=
{
e
.
url
}
/>
)
}
<
Route
component
=
{
error401
}
/
>
<
/Switch
>
<
/Layout
>
:
if
(
userSatatus
)
return
(
<
Layout
>
<
Switch
>
{
fullScreenRoute
.
map
(
e
=>
<
Route
path
=
{
e
.
url
}
exact
=
{
e
.
exact
}
component
=
{
Guards
(
e
.
component
)}
key
=
{
e
.
url
}
/>
)
}
<
Route
component
=
{
error404
}
/
>
{
basisRoute
.
map
(
e
=>
<
Route
path
=
{
e
.
url
}
exact
=
{
e
.
exact
}
component
=
{
Guards
(
e
.
component
)}
key
=
{
e
.
url
}
/>
)
}
{
openRoute
.
map
(
e
=>
<
Route
path
=
{
e
.
url
}
exact
=
{
e
.
exact
}
component
=
{
Guards
(
e
.
component
)}
key
=
{
e
.
url
}
/>
)
}
<
Route
component
=
{
error401
}
/
>
<
/Switch
>
}
<
/
>
)
<
/Layout
>
)
else
return
(
<
Switch
>
{
fullScreenRoute
.
map
(
e
=>
<
Route
path
=
{
e
.
url
}
exact
=
{
e
.
exact
}
component
=
{
Guards
(
e
.
component
)}
key
=
{
e
.
url
}
/>
)
}
<
Route
component
=
{
error404
}
/
>
<
/Switch
>
)
}
export
default
connect
(
RouterView
)
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment