Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
a3887f8c
提交
a3887f8c
authored
11月 10, 2020
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add tag display to the menu
上级
4baf90a5
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
76 行增加
和
2 行删除
+76
-2
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
MenuContent.tsx
src/components/Menu/src/MenuContent.tsx
+23
-2
index.less
src/components/Menu/src/index.less
+39
-0
dashboard.ts
src/router/menus/modules/dashboard.ts
+6
-0
types.d.ts
src/router/types.d.ts
+7
-0
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
a3887f8c
...
...
@@ -3,6 +3,7 @@
### ✨ Features
-
表单项的
`componentsProps`
支持函数类型
-
菜单新增 tag 显示
### ⚡ Performance Improvements
...
...
src/components/Menu/src/MenuContent.tsx
浏览文件 @
a3887f8c
...
...
@@ -35,6 +35,23 @@ export default defineComponent({
return
icon
?
<
Icon
icon=
{
icon
}
size=
{
18
}
class=
"menu-item-icon"
/>
:
null
;
}
function
renderTag
()
{
const
{
item
,
showTitle
}
=
props
;
if
(
!
item
||
showTitle
)
return
null
;
const
{
tag
}
=
item
;
if
(
!
tag
)
return
null
;
const
{
dot
,
content
,
type
=
'error'
}
=
tag
;
if
(
!
dot
&&
!
content
)
return
null
;
const
cls
=
[
'basic-menu__tag'
];
dot
&&
cls
.
push
(
'dot'
);
type
&&
cls
.
push
(
type
);
return
<
span
class=
{
cls
}
>
{
dot
?
''
:
content
}
</
span
>;
}
return
()
=>
{
if
(
!
props
.
item
)
{
return
null
;
...
...
@@ -46,17 +63,21 @@ export default defineComponent({
const
beforeStr
=
name
.
substr
(
0
,
index
);
const
afterStr
=
name
.
substr
(
index
+
searchValue
.
length
);
const
cls
=
showTitle
?
'show-title'
:
'basic-menu__name'
;
return
(
<>
{
renderIcon
(
icon
!
)
}
{
index
>
-
1
&&
searchValue
?
(
<
span
class=
{
showTitle
?
'show-title'
:
''
}
>
<
span
class=
{
cls
}
>
{
beforeStr
}
<
span
class=
{
`basic-menu__keyword`
}
>
{
searchValue
}
</
span
>
{
afterStr
}
</
span
>
)
:
(
<
span
class=
{
[
showTitle
?
'show-title'
:
''
]
}
>
{
name
}
</
span
>
<
span
class=
{
[
cls
]
}
>
{
name
}
{
renderTag
()
}
</
span
>
)
}
</>
);
...
...
src/components/Menu/src/index.less
浏览文件 @
a3887f8c
...
...
@@ -51,6 +51,45 @@
// collapsed show title end
&__name {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
}
&__tag {
display: inline-block;
padding: 2px 4px;
margin-right: 4px;
font-size: 12px;
line-height: 14px;
color: #fff;
border-radius: 2px;
&.dot {
width: 8px;
height: 8px;
padding: 0;
border-radius: 50%;
}
&.primary {
background: @primary-color;
}
&.error {
background: @error-color;
}
&.success {
background: @success-color;
}
&.warn {
background: @warning-color;
}
}
// scrollbar -s tart
&__content {
/* 滚动槽 */
...
...
src/router/menus/modules/dashboard.ts
浏览文件 @
a3887f8c
...
...
@@ -4,10 +4,16 @@ const menu: MenuModule = {
menu
:
{
name
:
'Dashboard'
,
path
:
'/dashboard'
,
// tag: {
// dot: true,
// },
children
:
[
{
path
:
'/workbench'
,
name
:
'工作台'
,
// tag: {
// content: 'new',
// },
},
{
path
:
'/analysis'
,
...
...
src/router/types.d.ts
浏览文件 @
a3887f8c
...
...
@@ -43,6 +43,11 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
props
?:
any
;
fullPath
?:
string
;
}
export
interface
MenuTag
{
type
?:
'primary'
|
'error'
|
'warn'
|
'success'
;
content
?:
string
;
dot
?:
boolean
;
}
export
interface
Menu
{
name
:
string
;
...
...
@@ -60,6 +65,8 @@ export interface Menu {
roles
?:
RoleEnum
[];
meta
?:
Partial
<
RouteMeta
>
;
tag
?:
MenuTag
;
}
export
interface
MenuModule
{
orderNo
?:
number
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论