Skip to content

Commit 88986b6

Browse files
authored
fix: basePropsGroup use deepclone prevent clone array itself (opentiny#975)
* fix: basePropsGroup use deepclone prevent clone array itself basePropsGroup 使用深拷贝方式复制自身 * fix: filter duplicated property
1 parent 702357b commit 88986b6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/plugins/materials/src/composable/useMaterial.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
import meta from '../../meta'
2626
import { getBlockCompileRes, getBlockByName, updateBlockCompileCache } from './block-compile'
2727

28-
const { camelize, capitalize } = utils
28+
const { camelize, capitalize, deepClone } = utils
2929
const { MATERIAL_TYPE } = constants
3030

3131
// 这里存放所有TinyVue组件、原生HTML、内置组件的缓存,包含了物料插件面板里所有显示的组件,也包含了没显示的一些联动组件
@@ -113,13 +113,17 @@ const patchBaseProps = (schemaProperties) => {
113113
})
114114

115115
if (group) {
116+
const targetInsertContent = basePropGroup.content.filter(
117+
(item) => !group.content.some((prop) => prop.property === item.property)
118+
)
119+
116120
if (insertPosition === 'start') {
117-
group.content.splice(0, 0, ...basePropGroup.content)
121+
group.content.splice(0, 0, ...deepClone(targetInsertContent))
118122
} else {
119-
group.content.push(...basePropGroup.content)
123+
group.content.push(...deepClone(targetInsertContent))
120124
}
121125
} else {
122-
schemaProperties.push(basePropGroup)
126+
schemaProperties.push(deepClone(basePropGroup))
123127
}
124128
}
125129
}

0 commit comments

Comments
 (0)