Skip to content

Commit 4de5dda

Browse files
committed
feat(组件面板): 在组件序列中显示已选组件数量
在LeftProps.vue中,更新了组件序列的显示,增加了已选组件的数量统计。同时在StageStore.ts中,优化了添加元素到组件的逻辑,确保只有非组元素才会被添加到目标组中,并更新了相关ID的处理。
1 parent 21d9f65 commit 4de5dda

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/components/ui/left/LeftProps.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="props-left-panel">
33
<div class="title">
4-
<span>组件序列({{ Array.from(stageStore.treeNodesMap.keys()).length }})</span>
4+
<span>组件序列({{ stageStore.selectedElements.length }} / {{ Array.from(stageStore.treeNodesMap.keys()).length }})</span>
55
</div>
66
<div class="tree">
77
<Elements-tree></Elements-tree>

src/modules/stage/StageStore.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,10 +2746,20 @@ export default class StageStore implements IStageStore {
27462746
const actionParams: ElementsActionParam[] = [];
27472747
const result: IElement[] = [];
27482748
const models = ElementUtils.convertElementsJson(elementsJson);
2749+
const groupModelIds: Set<string> = new Set();
2750+
models.forEach(model => {
2751+
if (model.type === CreatorTypes.group) {
2752+
groupModelIds.add(model.id);
2753+
}
2754+
});
2755+
let newSubIds: string[] = [];
27492756
for (const model of models) {
27502757
await ElementUtils.convertElementModel(model);
27512758
model.name = `${CreatorHelper.getCreatorByType(model.type).name} ${this._increaseElementSerialNumber(model.type)}`;
2752-
model.groupId = targetGroupId;
2759+
if (!groupModelIds.has(model.groupId)) {
2760+
model.groupId = targetGroupId;
2761+
newSubIds.push(model.id);
2762+
}
27532763
const element = this.insertAfterElementByModel(model, targetElement);
27542764
actionParams.push({
27552765
type: ElementActionTypes.Added,
@@ -2767,11 +2777,10 @@ export default class StageStore implements IStageStore {
27672777
}
27682778
await actionUndoCallback(actionParams);
27692779
if (targetGroup) {
2770-
const elementIds = result.map(element => element.id);
27712780
if (targetIndexOfGroupSubs > -1) {
2772-
targetSubIds.splice(targetIndexOfGroupSubs + 1, 0, ...elementIds);
2781+
targetSubIds.splice(targetIndexOfGroupSubs + 1, 0, ...newSubIds);
27732782
} else {
2774-
targetSubIds.push(...elementIds);
2783+
targetSubIds.push(...newSubIds);
27752784
}
27762785
this.updateElementModel(targetGroupId, { subIds: targetSubIds });
27772786
targetGroup.refreshBySubs();

0 commit comments

Comments
 (0)