Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
7d9ac724
提交
7d9ac724
authored
2月 28, 2023
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 优化菜单 tag 实现,改用 Badge 并优化样式
上级
19c76089
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
46 行增加
和
20 行删除
+46
-20
SimpleMenuTag.vue
src/components/SimpleMenu/src/SimpleMenuTag.vue
+21
-19
index.less
src/components/SimpleMenu/src/index.less
+10
-0
menuHelper.ts
src/router/helper/menuHelper.ts
+1
-0
tools.ts
src/router/routes/modules/demo/tools.ts
+6
-0
types.ts
src/router/types.ts
+2
-1
vue-router.d.ts
types/vue-router.d.ts
+6
-0
没有找到文件。
src/components/SimpleMenu/src/SimpleMenuTag.vue
浏览文件 @
7d9ac724
<
template
>
<
template
>
<span
:class=
"getTagClass"
v-if=
"getShowTag"
>
{{
getContent
}}
</span>
<Badge
v-if=
"getShowTag"
:class=
"['vben-simple-menu-badge', !getContent ? 'vben-simple-menu-badge--dot' : '']"
:dot=
"!getContent"
:count=
"getContent"
:number-style=
"
{
color: 'f8f8f8',
lineHeight: '18px',
boxShadow: `0 0 0 1px #979797`,
}"
/>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
type
{
Menu
}
from
'/@/router/types'
import
type
{
Menu
}
from
'/@/router/types'
import
{
defineComponent
,
computed
}
from
'vue'
import
{
defineComponent
,
computed
}
from
'vue'
import
{
Badge
}
from
'ant-design-vue'
import
{
useDesign
}
from
'/@/hooks/web/useDesign'
import
{
propTypes
}
from
'/@/utils/propTypes'
import
{
propTypes
}
from
'/@/utils/propTypes'
export
default
defineComponent
({
export
default
defineComponent
({
name
:
'SimpleMenuTag'
,
name
:
'SimpleMenuTag'
,
components
:
{
Badge
},
props
:
{
props
:
{
item
:
{
item
:
{
type
:
Object
as
PropType
<
Menu
>
,
type
:
Object
as
PropType
<
Menu
>
,
...
@@ -20,8 +31,6 @@
...
@@ -20,8 +31,6 @@
collapseParent
:
propTypes
.
bool
,
collapseParent
:
propTypes
.
bool
,
},
},
setup
(
props
)
{
setup
(
props
)
{
const
{
prefixCls
}
=
useDesign
(
'simple-menu'
)
const
getShowTag
=
computed
(()
=>
{
const
getShowTag
=
computed
(()
=>
{
const
{
item
}
=
props
const
{
item
}
=
props
...
@@ -43,23 +52,16 @@
...
@@ -43,23 +52,16 @@
return
dot
||
collapseParent
?
''
:
content
return
dot
||
collapseParent
?
''
:
content
})
})
const
getTagClass
=
computed
(()
=>
{
const
getType
=
computed
(()
=>
{
const
{
item
,
collapseParent
}
=
props
if
(
!
getShowTag
.
value
)
return
'error'
const
{
tag
=
{}
}
=
item
||
{}
const
{
item
}
=
props
const
{
dot
,
type
=
'error'
}
=
tag
const
{
tag
}
=
item
const
tagCls
=
`
${
prefixCls
}
-tag`
const
{
type
}
=
tag
!
return
[
return
type
??
'error'
tagCls
,
[
`
${
tagCls
}
--
${
type
}
`
],
{
[
`
${
tagCls
}
--collapse`
]:
collapseParent
,
[
`
${
tagCls
}
--dot`
]:
dot
||
props
.
dot
,
},
]
})
})
return
{
return
{
getT
agClass
,
getT
ype
,
getShowTag
,
getShowTag
,
getContent
,
getContent
,
}
}
...
...
src/components/SimpleMenu/src/index.less
浏览文件 @
7d9ac724
...
@@ -33,6 +33,16 @@
...
@@ -33,6 +33,16 @@
transition:
all
0.3
s
;
transition:
all
0.3
s
;
}
}
&-badge
{
position:
absolute
;
right:
16
px
;
z-index:
1
;
&--dot
{
right:
initial
;
}
}
&-tag
{
&-tag
{
position:
absolute
;
position:
absolute
;
top:
calc
(
50
%
-
8
px
);
top:
calc
(
50
%
-
8
px
);
...
...
src/router/helper/menuHelper.ts
浏览文件 @
7d9ac724
...
@@ -72,6 +72,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi
...
@@ -72,6 +72,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi
hideMenu
,
hideMenu
,
path
:
node
.
path
,
path
:
node
.
path
,
...(
node
.
redirect
?
{
redirect
:
node
.
redirect
}
:
{}),
...(
node
.
redirect
?
{
redirect
:
node
.
redirect
}
:
{}),
...(
node
.
tag
?
{
tag
:
node
.
tag
}
:
{}),
}
}
},
},
})
})
...
...
src/router/routes/modules/demo/tools.ts
浏览文件 @
7d9ac724
...
@@ -13,6 +13,9 @@ const tools: AppRouteModule = {
...
@@ -13,6 +13,9 @@ const tools: AppRouteModule = {
icon
:
'carbon:tools'
,
icon
:
'carbon:tools'
,
title
:
t
(
'routes.demo.tools.moduleName'
),
title
:
t
(
'routes.demo.tools.moduleName'
),
},
},
tag
:
{
dot
:
true
,
},
children
:
[
children
:
[
{
{
path
:
'file'
,
path
:
'file'
,
...
@@ -49,6 +52,9 @@ const tools: AppRouteModule = {
...
@@ -49,6 +52,9 @@ const tools: AppRouteModule = {
icon
:
'mdi:database-lock-outline'
,
icon
:
'mdi:database-lock-outline'
,
},
},
component
:
()
=>
import
(
'/@/views/demo/tools/database/index.vue'
),
component
:
()
=>
import
(
'/@/views/demo/tools/database/index.vue'
),
tag
:
{
content
:
'开发中'
,
},
},
},
{
{
path
:
'online'
,
path
:
'online'
,
...
...
src/router/types.ts
浏览文件 @
7d9ac724
...
@@ -17,10 +17,11 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
...
@@ -17,10 +17,11 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
children
?:
AppRouteRecordRaw
[]
children
?:
AppRouteRecordRaw
[]
props
?:
Recordable
props
?:
Recordable
fullPath
?:
string
fullPath
?:
string
tag
?:
MenuTag
}
}
export
interface
MenuTag
{
export
interface
MenuTag
{
type
?:
'
primary'
|
'error'
|
'warn'
|
'success
'
type
?:
'
default'
|
'warning'
|
'error'
|
'success'
|
'processing
'
content
?:
string
content
?:
string
dot
?:
boolean
dot
?:
boolean
}
}
...
...
types/vue-router.d.ts
浏览文件 @
7d9ac724
...
@@ -47,5 +47,11 @@ declare module 'vue-router' {
...
@@ -47,5 +47,11 @@ declare module 'vue-router' {
hideLayout
?:
boolean
hideLayout
?:
boolean
// 自动全屏
// 自动全屏
autoFullScreen
?:
boolean
autoFullScreen
?:
boolean
// tag
tag
?:
{
type
?:
'primary'
|
'error'
|
'warn'
|
'success'
content
?:
string
dot
?:
boolean
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论