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
2431d2f8
Commit
2431d2f8
authored
2 years ago
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 添加跳转菜单事件
parent
ab768c93
master
dev
devNew
patch-1
soundai
test
zhongyi
No related merge requests found
Pipeline
#55460
waiting for manual action with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
BasicLayout.js
src/layouts/BasicLayout.js
+31
-0
No files found.
src/layouts/BasicLayout.js
View file @
2431d2f8
...
...
@@ -351,6 +351,37 @@ const Layout = (props) => {
props
.
global
.
transformDevAssetsBaseURL
(
props
.
global
.
get
(
'bannerLogo'
))
:
defaultSetting
.
logo
;
// 添加一个路由跳转事件
useEffect
(()
=>
{
const
{
share
,
history
}
=
window
;
const
findMenuPath
=
(
flatMenu
,
url
)
=>
{
const
[
path
,
param
=
''
]
=
url
.
split
(
'|'
);
let
params
=
param
.
split
(
'&'
).
reduce
((
pre
,
item
)
=>
{
if
(
!
item
)
return
pre
;
const
[
key
,
value
]
=
item
.
split
(
'='
);
pre
[
key
]
=
value
;
return
pre
;
},
{});
let
menu
=
null
;
if
(
params
.
widget
)
{
menu
=
flatMenu
.
find
(
item
=>
item
.
params
&&
item
.
params
.
widget
===
params
.
widget
);
// 根据widget匹配菜单
}
else
{
menu
=
flatMenu
.
find
(
item
=>
item
.
path
.
indexOf
(
path
)
>
-
1
);
// 根据路径匹配菜单
}
return
menu
?
menu
.
path
.
replace
(
/^
\/
/
,
''
)
:
''
;
};
const
skipHandler
=
(
data
,
title
,
url
)
=>
{
const
targetMenuPath
=
findMenuPath
(
props
.
flatMenu
,
url
);
if
(
targetMenuPath
)
{
history
.
pushState
(
data
,
title
,
`/civbase/
${
targetMenuPath
}
`
);
}
}
share
&&
share
.
event
&&
share
.
event
.
on
(
'route:pushState'
,
skipHandler
);
return
()
=>
{
share
&&
share
.
event
&&
share
.
event
.
removeListener
(
'route:pushState'
,
skipHandler
);
}
},
[]);
return
(
<
SecurityLayout
{...
props
}
>
<
BasicLayout
...
...
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