Skip to content

Commit

Permalink
fix: 不可操作的菜单项disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gargameljyh committed Nov 28, 2023
1 parent a50ac01 commit 4dc4a2d
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions packages/canvas/src/components/container/CanvasMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
<li
v-for="(item, index) in menus"
:key="index"
:class="item.items ? 'li-item' : ''"
:class="{
'li-item': item.items,
'li-item-disabled': actionDisabled(item)
}"
@click="doOperation(item)"
@mouseover="current = item"
@mouseover="onShowChildrenMenu(item)"
>
<div>
<span>{{ item.name }}</span>
Expand Down Expand Up @@ -98,7 +101,8 @@ export default {
items: [
{ name: '文字提示', code: 'wrap', value: 'TinyTooltip' },
{ name: '弹出框', code: 'wrap', value: 'TinyPopover' }
]
],
code: 'addParent'
},
{ name: '删除', code: 'del' },
{ name: '复制', code: 'copy' },
Expand All @@ -107,6 +111,15 @@ export default {
const boxVisibility = ref(false)
const actionDisabled = (actionItem) => {
const actions = ['del', 'copy', 'addParent']
return actions.includes(actionItem.code) && !getCurrent().schema?.id
}
const onShowChildrenMenu = (menuItem) => {
current.value = !actionDisabled(menuItem) ? menuItem : null
}
// 计算上下文菜单位置,右键时显示,否则关闭
const operations = {
Expand Down Expand Up @@ -163,7 +176,7 @@ export default {
}
if (item?.code) {
operations[item.code](item)
operations[item.code]?.(item)
closeMenu()
}
}
Expand All @@ -175,7 +188,9 @@ export default {
boxVisibility,
close,
current,
menuDom
menuDom,
actionDisabled,
onShowChildrenMenu
}
}
}
Expand All @@ -198,6 +213,10 @@ export default {
.li-item {
border-bottom: 1px solid var(--ti-lowcode-canvas-menu-border-color);
}
.li-item-disabled {
cursor: not-allowed;
color: var(--ti-lowcode-canvas-menu-item-disabled-color);
}
li {
& > div {
display: flex;
Expand Down

0 comments on commit 4dc4a2d

Please sign in to comment.