Skip to content

Commit

Permalink
fix: basePropsGroup use deepclone prevent clone array itself (#975)
Browse files Browse the repository at this point in the history
* fix: basePropsGroup use deepclone prevent clone array itself

basePropsGroup 使用深拷贝方式复制自身

* fix: filter duplicated property
  • Loading branch information
chilingling authored Dec 31, 2024
1 parent 702357b commit 88986b6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/plugins/materials/src/composable/useMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import meta from '../../meta'
import { getBlockCompileRes, getBlockByName, updateBlockCompileCache } from './block-compile'

const { camelize, capitalize } = utils
const { camelize, capitalize, deepClone } = utils
const { MATERIAL_TYPE } = constants

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

if (group) {
const targetInsertContent = basePropGroup.content.filter(
(item) => !group.content.some((prop) => prop.property === item.property)
)

if (insertPosition === 'start') {
group.content.splice(0, 0, ...basePropGroup.content)
group.content.splice(0, 0, ...deepClone(targetInsertContent))
} else {
group.content.push(...basePropGroup.content)
group.content.push(...deepClone(targetInsertContent))
}
} else {
schemaProperties.push(basePropGroup)
schemaProperties.push(deepClone(basePropGroup))
}
}
}
Expand Down

0 comments on commit 88986b6

Please sign in to comment.