mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-03 03:56:41 +08:00
fix: add group bug
This commit is contained in:
parent
5aed4dec98
commit
fbf91838c0
@ -16,23 +16,16 @@ export function addGroup(store: TWidgetStore, group: TdWidgetData[] | TdWidgetDa
|
|||||||
const historyStore = useHistoryStore()
|
const historyStore = useHistoryStore()
|
||||||
const canvasStore = useCanvasStore()
|
const canvasStore = useCanvasStore()
|
||||||
let parent: TdWidgetData | null = null
|
let parent: TdWidgetData | null = null
|
||||||
if (Array.isArray(group)) {
|
const tmpGroup: TdWidgetData[] = !Array.isArray(group) ? [group] : group
|
||||||
group.forEach((item) => {
|
tmpGroup.forEach((item) => {
|
||||||
item.uuid = nanoid() // 重设id
|
item.uuid = nanoid() // 重设id
|
||||||
item.type === 'w-group' && (parent = item) // 找出父组件
|
item.type === 'w-group' && (parent = item) // 找出父组件
|
||||||
})
|
})
|
||||||
group.forEach((item) => {
|
tmpGroup.forEach((item) => {
|
||||||
!item.isContainer && parent && (item.parent = parent.uuid) // 重设父id
|
!item.isContainer && parent && (item.parent = parent.uuid) // 重设父id
|
||||||
item.text && (item.text = decodeURIComponent(item.text))
|
item.text && (item.text = decodeURIComponent(item.text))
|
||||||
store.dWidgets.push(item)
|
store.dWidgets.push(item)
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
group.uuid = nanoid() // 重设id
|
|
||||||
group.type === 'w-group' && (parent = group) // 找出父组件
|
|
||||||
!group.isContainer && parent && (group.parent = parent.uuid) // 重设父id
|
|
||||||
group.text && (group.text = decodeURIComponent(group.text))
|
|
||||||
store.dWidgets.push(group)
|
|
||||||
}
|
|
||||||
// 选中组件
|
// 选中组件
|
||||||
const len = store.dWidgets.length
|
const len = store.dWidgets.length
|
||||||
store.dActiveElement = store.dWidgets[len - 1]
|
store.dActiveElement = store.dWidgets[len - 1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user