Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
najiu-frontend
najiu-admin-template
Commits
7bae4c37
Commit
7bae4c37
authored
Dec 07, 2020
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(menu): fix externalLink not work
parent
e921e7b9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
7 deletions
+15
-7
menuHelper.ts
src/router/helper/menuHelper.ts
+4
-2
index.ts
src/router/menus/index.ts
+6
-1
iframe.ts
src/router/menus/modules/demo/iframe.ts
+1
-1
iframe.ts
src/router/routes/modules/demo/iframe.ts
+2
-2
types.d.ts
src/router/types.d.ts
+2
-1
No files found.
src/router/helper/menuHelper.ts
View file @
7bae4c37
...
@@ -3,6 +3,7 @@ import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types';
...
@@ -3,6 +3,7 @@ import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types';
import
{
findPath
,
forEach
,
treeMap
,
treeToList
}
from
'
/@/utils/helper/treeHelper
'
;
import
{
findPath
,
forEach
,
treeMap
,
treeToList
}
from
'
/@/utils/helper/treeHelper
'
;
import
{
cloneDeep
}
from
'
lodash-es
'
;
import
{
cloneDeep
}
from
'
lodash-es
'
;
import
{
isUrl
}
from
'
/@/utils/is
'
;
export
function
getAllParentPath
(
treeData
:
any
[],
path
:
string
)
{
export
function
getAllParentPath
(
treeData
:
any
[],
path
:
string
)
{
const
menuList
=
findPath
(
treeData
,
(
n
)
=>
n
.
path
===
path
)
as
Menu
[];
const
menuList
=
findPath
(
treeData
,
(
n
)
=>
n
.
path
===
path
)
as
Menu
[];
...
@@ -39,7 +40,7 @@ export function transformMenuModule(menuModule: MenuModule): Menu {
...
@@ -39,7 +40,7 @@ export function transformMenuModule(menuModule: MenuModule): Menu {
const
menuList
=
[
menu
];
const
menuList
=
[
menu
];
forEach
(
menuList
,
(
m
)
=>
{
forEach
(
menuList
,
(
m
)
=>
{
joinParentPath
(
menuList
,
m
);
!
isUrl
(
m
.
path
)
&&
joinParentPath
(
menuList
,
m
);
});
});
return
menuList
[
0
];
return
menuList
[
0
];
}
}
...
@@ -58,7 +59,8 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
...
@@ -58,7 +59,8 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
return
treeMap
(
routeList
,
{
return
treeMap
(
routeList
,
{
conversion
:
(
node
:
AppRouteRecordRaw
)
=>
{
conversion
:
(
node
:
AppRouteRecordRaw
)
=>
{
const
{
meta
:
{
title
,
icon
}
=
{}
}
=
node
;
const
{
meta
:
{
title
,
icon
}
=
{}
}
=
node
;
joinParentPath
(
routeList
,
node
);
!
isUrl
(
node
.
path
)
&&
joinParentPath
(
routeList
,
node
);
return
{
return
{
name
:
title
,
name
:
title
,
icon
,
icon
,
...
...
src/router/menus/index.ts
View file @
7bae4c37
...
@@ -89,12 +89,17 @@ export async function getFlatChildrenMenus(children: Menu[]) {
...
@@ -89,12 +89,17 @@ export async function getFlatChildrenMenus(children: Menu[]) {
function
basicFilter
(
routes
:
RouteRecordNormalized
[])
{
function
basicFilter
(
routes
:
RouteRecordNormalized
[])
{
return
(
menu
:
Menu
)
=>
{
return
(
menu
:
Menu
)
=>
{
const
matchRoute
=
routes
.
find
((
route
)
=>
{
const
matchRoute
=
routes
.
find
((
route
)
=>
{
if
(
route
.
meta
.
externalLink
)
{
return
true
;
}
if
(
route
.
meta
)
{
if
(
route
.
meta
)
{
if
(
route
.
meta
.
carryParam
)
{
if
(
route
.
meta
.
carryParam
)
{
return
pathToRegexp
(
route
.
path
).
test
(
menu
.
path
);
return
pathToRegexp
(
route
.
path
).
test
(
menu
.
path
);
}
}
if
(
route
.
meta
.
ignoreAuth
)
return
fals
e
;
if
(
route
.
meta
.
ignoreAuth
)
return
tru
e
;
}
}
return
route
.
path
===
menu
.
path
;
return
route
.
path
===
menu
.
path
;
});
});
...
...
src/router/menus/modules/demo/iframe.ts
View file @
7bae4c37
...
@@ -15,7 +15,7 @@ const menu: MenuModule = {
...
@@ -15,7 +15,7 @@ const menu: MenuModule = {
name
:
'
routes.demo.iframe.doc
'
,
name
:
'
routes.demo.iframe.doc
'
,
},
},
{
{
path
:
'
docExternal
'
,
path
:
'
https://vvbin.cn/doc-next/
'
,
name
:
'
routes.demo.iframe.docExternal
'
,
name
:
'
routes.demo.iframe.docExternal
'
,
},
},
],
],
...
...
src/router/routes/modules/demo/iframe.ts
View file @
7bae4c37
...
@@ -33,11 +33,11 @@ const iframe: AppRouteModule = {
...
@@ -33,11 +33,11 @@ const iframe: AppRouteModule = {
},
},
},
},
{
{
path
:
'
docExternal
'
,
path
:
'
https://vvbin.cn/doc-next/
'
,
name
:
'
DocExternal
'
,
name
:
'
DocExternal
'
,
component
:
IFrame
,
component
:
IFrame
,
meta
:
{
meta
:
{
externalLink
:
'
https://vvbin.cn/doc-next/
'
,
externalLink
:
true
,
title
:
'
routes.demo.iframe.docExternal
'
,
title
:
'
routes.demo.iframe.docExternal
'
,
},
},
},
},
...
...
src/router/types.d.ts
View file @
7bae4c37
...
@@ -17,7 +17,7 @@ export interface RouteMeta {
...
@@ -17,7 +17,7 @@ export interface RouteMeta {
// Jump address
// Jump address
frameSrc
?:
string
;
frameSrc
?:
string
;
// Outer link jump address
// Outer link jump address
externalLink
?:
string
;
externalLink
?:
boolean
;
// current page transition
// current page transition
transitionName
?:
string
;
transitionName
?:
string
;
...
@@ -28,6 +28,7 @@ export interface RouteMeta {
...
@@ -28,6 +28,7 @@ export interface RouteMeta {
// Carrying parameters
// Carrying parameters
carryParam
?:
boolean
;
carryParam
?:
boolean
;
// Used internally to mark single-level menus
single
?:
boolean
;
single
?:
boolean
;
}
}
...
...
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