Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivWeb
Commits
1b8d8427
Commit
1b8d8427
authored
3 years ago
by
邓晓峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feat/commonmenu
parents
28a2affc
7c9ea365
Pipeline
#35575
passed with stages
in 58 minutes 19 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
50 deletions
+0
-50
index.js
src/containers/App/index.js
+0
-50
No files found.
src/containers/App/index.js
View file @
1b8d8427
...
...
@@ -21,56 +21,6 @@ const config = require('../../../config/config');
const
defaultSetting
=
config
.
layout
;
const
createRoute
=
routes
=>
{
return
(
<
Switch
>
{
routes
.
map
((
route
,
index
)
=>
createFixRoute
(
route
,
index
)
)
}
<
Redirect
from
=
'/*'
to
=
'/'
/>
<
/Switch
>
);
};
//该组件通过递归的方式,将所有route中带有children路由的父路由进行解构,最终用createBasicRoute函数来渲染
const
createFixRoute
=
(
route
,
index
)
=>
{
const
{
path
,
component
:
RouteComponent
,
routes
}
=
route
;
if
(
routes
)
{
return
(
<
Route
key
=
{
index
}
path
=
{
path
}
children
=
{
props
=>
{
let
redirectPath
=
null
;
return
<
RouteComponent
{...
props
}
route
=
{
route
}
routes
=
{
route
.
routes
}
params
=
{
route
.
params
}
>
<
Switch
>
{
routes
.
map
((
child
,
index2
)
=>
{
const
{
path
:
childPath
,
redirect
}
=
child
;
if
(
redirect
){
redirectPath
=
childPath
;
}
return
createFixRoute
({...
child
,
path
:
path
+
childPath
},
`
${
index
}
-
${
index2
}
`
);
})}
<
Redirect
from
=
{
`
${
path
}
`
}
to
=
{
`
${
path
}${
redirectPath
||
routes
[
0
].
path
}
`
}
/
>
<
/Switch
>
<
/RouteComponent>
;
}}
/
>
);
}
else
{
return
createBasicRoute
(
route
,
index
);
}
};
const
createBasicRoute
=
(
route
,
index
)
=>
{
// 最基础的Router 用法
const
{
path
,
component
:
Component
}
=
route
;
return
<
Route
exact
key
=
{
index
}
path
=
{
path
}
component
=
{
props
=>
{
return
<
Component
{...
props
}
route
=
{
route
}
routes
=
{
route
.
routes
}
params
=
{
route
.
params
}
/>
;
}}
/>
;
};
function
App
(
props
)
{
const
{
routes
}
=
dyRoutes
(
props
.
menu
);
console
.
log
(
"routes"
,
routes
)
...
...
This diff is collapsed.
Click to expand it.
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