From b8f7e707c9e6c56c75014dfe6029930c2704d599 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Sat, 26 Jun 2021 15:27:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useCombineElement.ts | 14 +++++++++++++ .../Editor/Toolbar/MultiPositionPanel.vue | 20 +++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) 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 @@