Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-layout
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
packages
pro-layout
Commits
5b966325
Commit
5b966325
authored
Aug 30, 2021
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: menuItemRender
parent
35794cd3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
116 additions
and
5 deletions
+116
-5
README.md
README.md
+71
-0
BasicLayout.vue
examples/layouts/BasicLayout.vue
+20
-1
headerProps.ts
src/GlobalHeader/headerProps.ts
+3
-1
BaseMenu.tsx
src/SiderMenu/BaseMenu.tsx
+3
-2
index.less
src/SiderMenu/index.less
+6
-1
index.less
src/TopNavHeader/index.less
+11
-0
index.tsx
src/TopNavHeader/index.tsx
+2
-0
No files found.
README.md
View file @
5b966325
...
...
@@ -174,6 +174,77 @@ export default defineComponent({
| locale | i18n | Function (key: string) => string
\|
`false`
|
`false`
|
### Custom Render
#### Custom rightContentRender
```
vue
<
template
#
rightContentRender
>
<div
style=
"margin-right: 12px"
>
<a-avatar
shape=
"square"
size=
"small"
>
<template
#
icon
>
<UserOutlined
/>
</
template
>
</a-avatar>
</div>
</template>
```
#### Custom menu.item
```
vue
<
template
#
menuItemRender=
"{ item, icon }"
>
<a-menu-item
:key=
"item.path"
:disabled=
"item.meta?.disabled"
:danger=
"item.meta?.danger"
:icon=
"icon"
>
<router-link
:to=
"
{ path: item.path }">
<span
class=
"ant-pro-menu-item"
>
<a-badge
count=
"5"
dot
>
<span
class=
"ant-pro-menu-item-title"
>
{{
item
.
meta
.
title
}}
</span>
</a-badge>
</span>
</router-link>
</a-menu-item>
</
template
>
```
#### Custom menuExtraRender
```
vue
<
template
#
menuExtraRender=
"{ collapsed }"
>
<a-input-search
v-if=
"!collapsed"
/>
</
template
>
```
#### Custom menuFooterRender
```
vue
<
template
#
menuFooterRender
>
<div>
menu footer
</div>
</
template
>
```
#### Custom breadcrumbRender
```
vue
<
template
#
breadcrumbRender=
"{ route, params, routes }"
>
<span
v-if=
"routes.indexOf(route) === routes.length - 1"
>
{{
route
.
breadcrumbName
}}
</span>
<router-link
v-else
:to=
"
{ path: route.path, params }">
{{
route
.
breadcrumbName
}}
</router-link>
</
template
>
```
#### Custom collapsedButtonRender
```
vue
<
template
#
collapsedButtonRender=
"collapsed"
>
<HeartOutlined
v-if=
"collapsed"
/>
<SmileOutlined
v-else
/>
</
template
>
```
### PageContainer
| Property | Description | Type | Default Value |
...
...
examples/layouts/BasicLayout.vue
View file @
5b966325
...
...
@@ -66,6 +66,24 @@
</a>
</
template
>
<!-- custom menu-item -->
<
template
#
menuItemRender=
"{ item, icon }"
>
<a-menu-item
:key=
"item.path"
:disabled=
"item.meta?.disabled"
:danger=
"item.meta?.danger"
:icon=
"icon"
>
<router-link
:to=
"
{ path: item.path }">
<span
class=
"ant-pro-menu-item"
>
<a-badge
count=
"5"
dot
>
<span
class=
"ant-pro-menu-item-title"
>
{{
item
.
meta
.
title
}}
</span>
</a-badge>
</span>
</router-link>
</a-menu-item>
</
template
>
<!-- content begin -->
<router-view
/>
<!-- content end -->
...
...
@@ -98,7 +116,7 @@
<
script
lang=
"ts"
>
import
{
computed
,
defineComponent
,
reactive
,
ref
,
watchEffect
}
from
'vue'
;
import
{
useRouter
}
from
'vue-router'
;
import
{
Button
,
Input
,
Switch
,
Select
,
Avatar
,
Space
,
Badge
}
from
'ant-design-vue'
;
import
{
Button
,
Input
,
Switch
,
Select
,
Avatar
,
Space
,
Badge
,
Menu
}
from
'ant-design-vue'
;
import
{
getMenuData
,
clearMenuItem
,
FooterToolbar
}
from
'@ant-design-vue/pro-layout'
;
import
type
{
RouteContextProps
}
from
'@ant-design-vue/pro-layout'
;
...
...
@@ -118,6 +136,7 @@ export default defineComponent({
[
Badge
.
name
]:
Badge
,
[
Avatar
.
name
]:
Avatar
,
[
Menu
.
Item
.
name
]:
Menu
.
Item
,
},
setup
()
{
const
loading
=
ref
(
false
);
...
...
src/GlobalHeader/headerProps.ts
View file @
5b966325
import
type
{
PropType
}
from
'vue'
;
import
type
{
CustomRender
,
Theme
,
MenuDataItem
,
WithFalse
}
from
'../typings'
;
import
{
defaultSettingProps
}
from
'../defaultSettings'
;
import
{
PropTypes
}
from
'../utils'
import
{
PropTypes
}
from
'../utils'
;
import
{
siderMenuProps
}
from
'../SiderMenu/SiderMenu'
;
export
default
{
...
...
@@ -27,6 +27,8 @@ export default {
default
:
()
=>
undefined
,
},
menuHeaderRender
:
siderMenuProps
.
menuHeaderRender
,
menuItemRender
:
siderMenuProps
.
menuItemRender
,
subMenuItemRender
:
siderMenuProps
.
subMenuItemRender
,
rightContentRender
:
{
type
:
[
Object
,
Function
]
as
PropType
<
WithFalse
<
(
props
:
any
)
=>
CustomRender
>>
,
default
:
()
=>
undefined
,
...
...
src/SiderMenu/BaseMenu.tsx
View file @
5b966325
...
...
@@ -85,11 +85,11 @@ export const baseMenuProps = {
},
menuItemRender
:
{
type
:
[
Function
,
Boolean
]
as
PropType
<
CustomMenuRender
[
'menuItemRender'
]
>
,
default
:
()
=>
false
,
default
:
()
=>
undefined
,
},
subMenuItemRender
:
{
type
:
[
Function
,
Boolean
]
as
PropType
<
CustomMenuRender
[
'subMenuItemRender'
]
>
,
default
:
()
=>
false
,
default
:
()
=>
undefined
,
},
onClick
:
[
Function
,
Object
]
as
PropType
<
(...
args
:
any
)
=>
void
>
,
...
...
@@ -177,6 +177,7 @@ class MenuUtil {
<
MenuComponent
title=
{
defaultTitle
}
key=
{
item
.
path
}
popupClassName=
{
hasGroup
?
null
:
`${prefixCls}-menu-popup`
}
icon=
{
hasGroup
?
null
:
<
LazyIcon
icon=
{
item
.
meta
?.
icon
}
/>
}
>
{
this
.
getNavMenuItems
(
item
.
children
)
}
...
...
src/SiderMenu/index.less
View file @
5b966325
...
...
@@ -109,6 +109,11 @@
min-height: 100%;
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
.@{ant-prefix}-pro-menu-item {
> .@{ant-prefix}-badge {
color: unset;
}
}
span.@{ant-prefix}-pro-menu-item-title {
transition: none;
}
...
...
src/TopNavHeader/index.less
View file @
5b966325
...
...
@@ -71,7 +71,18 @@
.@{ant-prefix}-menu-item {
height: 100%;
.@{ant-prefix}-badge {
color: unset;
}
}
}
}
}
// replace sub.item
.@{ant-prefix}-pro-menu-popup {
.@{ant-prefix}-badge {
color: unset;
}
}
\ No newline at end of file
src/TopNavHeader/index.tsx
View file @
5b966325
...
...
@@ -93,6 +93,8 @@ export const TopNavHeader: FunctionalComponent<TopNavHeaderProps> = props => {
mode=
{
props
.
mode
}
collapsed=
{
props
.
collapsed
}
menuData=
{
menuData
}
menuItemRender=
{
props
.
menuItemRender
}
subMenuItemRender=
{
props
.
subMenuItemRender
}
openKeys=
{
context
.
openKeys
}
selectedKeys=
{
context
.
selectedKeys
}
class=
{
{
'top-nav-menu'
:
props
.
mode
===
'horizontal'
}
}
...
...
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