Skip to content

Commit

Permalink
feat: add openOnceKey control open root menu feat.
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Nov 20, 2021
1 parent b7eb4a7 commit dd1a688
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default {
| i18nRender | i18n | Function (key: string) => string \| `false` | `false` |
| handleMediaQuery | media matchs callback | (querys: []) => void | - |
| mediaQuery | media matchs | Array | - |

| openOnceKey | menu only open root key | `true` | - |


### PageHeaderWrapper
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
| i18nRender | 本地化渲染函数 (this.$t) | Function (key: string) => string \| `false` | `false` |
| handleMediaQuery | 媒体查询回调 | (querys: []) => void | - |
| mediaQuery | ProLayout 当前的媒体查询 | Array | - |

| openOnceKey | Menu菜单最多只打开一个 | `true` | - |


### PageHeaderWrapper
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ant-design-vue/pro-layout",
"version": "1.0.8",
"version": "1.0.9",
"main": "./lib/index.js",
"module": "./es/index.js",
"repository": {
Expand Down
4 changes: 3 additions & 1 deletion src/components/RouteMenu/BaseMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const RouteMenu = {
render (h, ctx) {
const { mode, theme, menus, i18nRender, openOnceKey } = this
const handleOpenChange = (openKeys) => {

// 在水平模式下时,不再执行后续
if (mode === 'horizontal') {
this.sOpenKeys = openKeys
Expand Down Expand Up @@ -156,6 +155,9 @@ const RouteMenu = {
item.path && openKeys.push(item.path)
})
}
if (!this.openOnceKey) {
this.sOpenKeys.forEach(item => openKeys.push(item))
}

this.collapsed ? (this.cachedOpenKeys = openKeys) : (this.sOpenKeys = openKeys)
}
Expand Down

0 comments on commit dd1a688

Please sign in to comment.