diff --git a/src/hooks/useCombineElement.ts b/src/hooks/useCombineElement.ts index 857fe8e9..3c3617b0 100644 --- a/src/hooks/useCombineElement.ts +++ b/src/hooks/useCombineElement.ts @@ -13,6 +13,19 @@ export default () => { const { addHistorySnapshot } = useHistorySnapshot() + /** + * 判断当前选中的元素是否可以组合 + */ + const canCombine = computed(() => { + if (activeElementList.value.length < 2) return false + + const firstGroupId = activeElementList.value[0].groupId + if (!firstGroupId) return true + + const inSameGroup = activeElementList.value.every(el => (el.groupId && el.groupId) === firstGroupId) + return !inSameGroup + }) + /** * 组合当前选中的元素:给当前选中的元素赋予一个相同的分组ID */ @@ -70,6 +83,7 @@ export default () => { } return { + canCombine, combineElements, uncombineElements, } diff --git a/src/views/Editor/Toolbar/MultiPositionPanel.vue b/src/views/Editor/Toolbar/MultiPositionPanel.vue index 49b743df..b47e18f0 100644 --- a/src/views/Editor/Toolbar/MultiPositionPanel.vue +++ b/src/views/Editor/Toolbar/MultiPositionPanel.vue @@ -37,9 +37,7 @@