You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
7 years ago
|
export function noop () {
|
||
|
}
|
||
|
|
||
|
export function getKeyFromChildrenIndex (child, menuEventKey, index) {
|
||
|
const prefix = menuEventKey || ''
|
||
|
return child.key || `${prefix}item_${index}`
|
||
|
}
|
||
|
|
||
|
export function loopMenuItem (children, cb) {
|
||
7 years ago
|
let index = -1
|
||
|
children.forEach((c) => {
|
||
|
index++
|
||
|
if (c && c.type && c.type.isMenuItemGroup) {
|
||
|
c.$slots.default.forEach((c2) => {
|
||
|
index++
|
||
7 years ago
|
c.componentOptions && cb(c2, index)
|
||
7 years ago
|
})
|
||
|
} else {
|
||
7 years ago
|
c.componentOptions && cb(c, index)
|
||
7 years ago
|
}
|
||
|
})
|
||
7 years ago
|
}
|
||
|
|
||
|
export function loopMenuItemRecusively (children, keys, ret) {
|
||
|
if (!children || ret.find) {
|
||
|
return
|
||
|
}
|
||
7 years ago
|
children.forEach((c) => {
|
||
7 years ago
|
if (ret.find) {
|
||
|
return
|
||
|
}
|
||
7 years ago
|
if (c.data && c.data.slot && c.data.slot !== 'default') {
|
||
|
return
|
||
|
}
|
||
|
if (c && c.componentOptions) {
|
||
|
const options = c.componentOptions.Ctor.options
|
||
|
if (!options || !(options.isSubMenu || options.isMenuItem || options.isMenuItemGroup)) {
|
||
7 years ago
|
return
|
||
|
}
|
||
|
if (keys.indexOf(c.key) !== -1) {
|
||
|
ret.find = true
|
||
7 years ago
|
} else if (c.componentOptions.children) {
|
||
|
loopMenuItemRecusively(c.componentOptions.children, keys, ret)
|
||
7 years ago
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|