Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
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
wangpeng
dinky
Commits
83fb5103
Unverified
Commit
83fb5103
authored
Aug 17, 2023
by
yqwoe
Committed by
GitHub
Aug 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 前端路由监听修改默认跳转路由; (#2231)
* feat: use-service hooks * fix: 前端路由监听修改默认跳转路由;
parent
582c2263
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
app.tsx
dinky-web/src/app.tsx
+11
-11
No files found.
dinky-web/src/app.tsx
View file @
83fb5103
...
...
@@ -34,6 +34,7 @@ import {Reducer, StoreEnhancer} from 'redux';
import
{
API
}
from
"./services/data"
;
import
{
AccessContextProvider
}
from
'@/hooks/useAccess'
;
import
{
Navigate
}
from
'umi'
;
import
{
SysMenu
}
from
"@/types/RegCenter/data"
;
// const isDev = process.env.NODE_ENV === "development";
const
loginPath
=
API_CONSTANTS
.
LOGIN_PATH
;
...
...
@@ -42,7 +43,8 @@ const whiteList = ['/user','/user/login']
let
extraRoutes
;
let
extraRoutes
=
[];
let
rendered
=
false
;
/**
* 初始化路由鉴权
...
...
@@ -193,7 +195,7 @@ export const dva = {
/***
* 动态修改默认跳转路由
*/
const
patch
=
(
oldrRoutes
,
routes
)
=>
{
const
patch
=
(
oldrRoutes
,
routes
:
SysMenu
[]
)
=>
{
oldrRoutes
[
1
].
routes
=
oldrRoutes
[
1
].
routes
.
map
(
route
=>
{
if
(
route
.
routes
&&
route
.
routes
.
length
){
const
redirect
=
routes
.
filter
(
r
=>
r
.
path
.
startsWith
(
route
.
path
))
...
...
@@ -219,19 +221,17 @@ export function patchClientRoutes({ routes }) {
}
/***
*
动态加载路由
*
路由切换并只加载首次
*/
export
function
render
(
oldRender
)
{
const
{
location
}
=
history
;
if
(
location
.
pathname
!==
loginPath
)
{
export
function
onRouteChange
({
location
,
clientRoutes
,
routes
,
action
})
{
if
(
location
.
pathname
!==
loginPath
&&
!
rendered
)
{
const
filterMenus
=
(
menus
=
[])
=>
{
return
menus
.
filter
(
menu
=>
menu
.
type
!==
'F'
)
}
queryCurrentUser
().
then
(
res
=>
{
extraRoutes
=
filterMenus
(
res
.
datas
.
menuList
)
oldRender
();
})
extraRoutes
=
filterMenus
(
extraRoutes
)
patchClientRoutes
({
routes
:
clientRoutes
})
rendered
=
true
}
}
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