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
a3887f8c
Commit
a3887f8c
authored
Nov 10, 2020
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add tag display to the menu
parent
4baf90a5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
2 deletions
+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
No files found.
CHANGELOG.zh_CN.md
View file @
a3887f8c
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
### ✨ Features
### ✨ Features
-
表单项的
`componentsProps`
支持函数类型
-
表单项的
`componentsProps`
支持函数类型
-
菜单新增 tag 显示
### ⚡ Performance Improvements
### ⚡ Performance Improvements
...
...
src/components/Menu/src/MenuContent.tsx
View file @
a3887f8c
...
@@ -35,6 +35,23 @@ export default defineComponent({
...
@@ -35,6 +35,23 @@ export default defineComponent({
return
icon
?
<
Icon
icon=
{
icon
}
size=
{
18
}
class=
"menu-item-icon"
/>
:
null
;
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
()
=>
{
return
()
=>
{
if
(
!
props
.
item
)
{
if
(
!
props
.
item
)
{
return
null
;
return
null
;
...
@@ -46,17 +63,21 @@ export default defineComponent({
...
@@ -46,17 +63,21 @@ export default defineComponent({
const
beforeStr
=
name
.
substr
(
0
,
index
);
const
beforeStr
=
name
.
substr
(
0
,
index
);
const
afterStr
=
name
.
substr
(
index
+
searchValue
.
length
);
const
afterStr
=
name
.
substr
(
index
+
searchValue
.
length
);
const
cls
=
showTitle
?
'
show-title
'
:
'
basic-menu__name
'
;
return
(
return
(
<>
<>
{
renderIcon
(
icon
!
)
}
{
renderIcon
(
icon
!
)
}
{
index
>
-
1
&&
searchValue
?
(
{
index
>
-
1
&&
searchValue
?
(
<
span
class=
{
showTitle
?
'
show-title
'
:
''
}
>
<
span
class=
{
cls
}
>
{
beforeStr
}
{
beforeStr
}
<
span
class=
{
`basic-menu__keyword`
}
>
{
searchValue
}
</
span
>
<
span
class=
{
`basic-menu__keyword`
}
>
{
searchValue
}
</
span
>
{
afterStr
}
{
afterStr
}
</
span
>
</
span
>
)
:
(
)
:
(
<
span
class=
{
[
showTitle
?
'
show-title
'
:
''
]
}
>
{
name
}
</
span
>
<
span
class=
{
[
cls
]
}
>
{
name
}
{
renderTag
()
}
</
span
>
)
}
)
}
</>
</>
);
);
...
...
src/components/Menu/src/index.less
View file @
a3887f8c
...
@@ -51,6 +51,45 @@
...
@@ -51,6 +51,45 @@
// collapsed show title end
// 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
// scrollbar -s tart
&__content {
&__content {
/* 滚动槽 */
/* 滚动槽 */
...
...
src/router/menus/modules/dashboard.ts
View file @
a3887f8c
...
@@ -4,10 +4,16 @@ const menu: MenuModule = {
...
@@ -4,10 +4,16 @@ const menu: MenuModule = {
menu
:
{
menu
:
{
name
:
'
Dashboard
'
,
name
:
'
Dashboard
'
,
path
:
'
/dashboard
'
,
path
:
'
/dashboard
'
,
// tag: {
// dot: true,
// },
children
:
[
children
:
[
{
{
path
:
'
/workbench
'
,
path
:
'
/workbench
'
,
name
:
'
工作台
'
,
name
:
'
工作台
'
,
// tag: {
// content: 'new',
// },
},
},
{
{
path
:
'
/analysis
'
,
path
:
'
/analysis
'
,
...
...
src/router/types.d.ts
View file @
a3887f8c
...
@@ -43,6 +43,11 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
...
@@ -43,6 +43,11 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
props
?:
any
;
props
?:
any
;
fullPath
?:
string
;
fullPath
?:
string
;
}
}
export
interface
MenuTag
{
type
?:
'
primary
'
|
'
error
'
|
'
warn
'
|
'
success
'
;
content
?:
string
;
dot
?:
boolean
;
}
export
interface
Menu
{
export
interface
Menu
{
name
:
string
;
name
:
string
;
...
@@ -60,6 +65,8 @@ export interface Menu {
...
@@ -60,6 +65,8 @@ export interface Menu {
roles
?:
RoleEnum
[];
roles
?:
RoleEnum
[];
meta
?:
Partial
<
RouteMeta
>
;
meta
?:
Partial
<
RouteMeta
>
;
tag
?:
MenuTag
;
}
}
export
interface
MenuModule
{
export
interface
MenuModule
{
orderNo
?:
number
;
orderNo
?:
number
;
...
...
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