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
f5e31feb
Commit
f5e31feb
authored
Jul 13, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(breadcrumb): `redirect` not worked
修复面包屑组件的重定向菜单不能工作以及eslint警告
parent
6f830703
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
10 deletions
+6
-10
Breadcrumb.vue
src/layouts/default/header/components/Breadcrumb.vue
+5
-10
menuHelper.ts
src/router/helper/menuHelper.ts
+1
-0
No files found.
src/layouts/default/header/components/Breadcrumb.vue
View file @
f5e31feb
<
template
>
<
template
>
<div
:class=
"[prefixCls, `$
{prefixCls}--${theme}`]">
<div
:class=
"[prefixCls, `$
{prefixCls}--${theme}`]">
<a-breadcrumb
:routes=
"routes"
>
<a-breadcrumb
:routes=
"routes"
>
<template
#itemRender
="
{ route, routes, paths }">
<template
#itemRender
="
{ route, routes
: routesMatched
, paths }">
<Icon
:icon=
"getIcon(route)"
v-if=
"getShowBreadCrumbIcon && getIcon(route)"
/>
<Icon
:icon=
"getIcon(route)"
v-if=
"getShowBreadCrumbIcon && getIcon(route)"
/>
<span
v-if=
"!hasRedirect(routes, route)"
>
<span
v-if=
"!hasRedirect(routes
Matched
, route)"
>
{{
t
(
route
.
name
||
route
.
meta
.
title
)
}}
{{
t
(
route
.
name
||
route
.
meta
.
title
)
}}
</span>
</span>
<router-link
v-else
to=
""
@
click=
"handleClick(route, paths, $event)"
>
<router-link
v-else
to=
""
@
click=
"handleClick(route, paths, $event)"
>
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
</template>
</template>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
type
{
RouteLocationMatched
}
from
'
vue-router
'
;
import
type
{
RouteLocationMatched
}
from
'
vue-router
'
;
import
{
useRouter
}
from
'
vue-router
'
;
import
type
{
Menu
}
from
'
/@/router/types
'
;
import
type
{
Menu
}
from
'
/@/router/types
'
;
import
{
defineComponent
,
ref
,
watchEffect
}
from
'
vue
'
;
import
{
defineComponent
,
ref
,
watchEffect
}
from
'
vue
'
;
...
@@ -26,7 +27,6 @@
...
@@ -26,7 +27,6 @@
import
{
useRootSetting
}
from
'
/@/hooks/setting/useRootSetting
'
;
import
{
useRootSetting
}
from
'
/@/hooks/setting/useRootSetting
'
;
import
{
useGo
}
from
'
/@/hooks/web/usePage
'
;
import
{
useGo
}
from
'
/@/hooks/web/usePage
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
import
{
useRouter
}
from
'
vue-router
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
import
{
isString
}
from
'
/@/utils/is
'
;
import
{
isString
}
from
'
/@/utils/is
'
;
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
}
}
function
filterItem
(
list
:
RouteLocationMatched
[])
{
function
filterItem
(
list
:
RouteLocationMatched
[])
{
let
resultList
=
filter
(
list
,
(
item
)
=>
{
return
filter
(
list
,
(
item
)
=>
{
const
{
meta
,
name
}
=
item
;
const
{
meta
,
name
}
=
item
;
if
(
!
meta
)
{
if
(
!
meta
)
{
return
!!
name
;
return
!!
name
;
...
@@ -107,8 +107,6 @@
...
@@ -107,8 +107,6 @@
}
}
return
true
;
return
true
;
}).
filter
((
item
)
=>
!
item
.
meta
?.
hideBreadcrumb
||
!
item
.
meta
?.
hideMenu
);
}).
filter
((
item
)
=>
!
item
.
meta
?.
hideBreadcrumb
||
!
item
.
meta
?.
hideMenu
);
return
resultList
;
}
}
function
handleClick
(
route
:
RouteLocationMatched
,
paths
:
string
[],
e
:
Event
)
{
function
handleClick
(
route
:
RouteLocationMatched
,
paths
:
string
[],
e
:
Event
)
{
...
@@ -140,10 +138,7 @@
...
@@ -140,10 +138,7 @@
}
}
function
hasRedirect
(
routes
:
RouteLocationMatched
[],
route
:
RouteLocationMatched
)
{
function
hasRedirect
(
routes
:
RouteLocationMatched
[],
route
:
RouteLocationMatched
)
{
if
(
routes
.
indexOf
(
route
)
===
routes
.
length
-
1
)
{
return
routes
.
indexOf
(
route
)
!==
routes
.
length
-
1
;
return
false
;
}
return
true
;
}
}
function
getIcon
(
route
)
{
function
getIcon
(
route
)
{
...
...
src/router/helper/menuHelper.ts
View file @
f5e31feb
...
@@ -62,6 +62,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi
...
@@ -62,6 +62,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi
name
:
title
,
name
:
title
,
hideMenu
,
hideMenu
,
path
:
node
.
path
,
path
:
node
.
path
,
...(
node
.
redirect
?
{
redirect
:
node
.
redirect
}
:
{}),
};
};
},
},
});
});
...
...
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