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
fbf91838c0
commit
00d2831df7
@ -225,7 +225,7 @@ const selectItem = async (item: TGetCompListResult) => {
|
|||||||
group.text && (group.text = decodeURIComponent(group.text))
|
group.text && (group.text = decodeURIComponent(group.text))
|
||||||
group.left = pW / 2 - group.fontSize * (group.text.length / 2)
|
group.left = pW / 2 - group.fontSize * (group.text.length / 2)
|
||||||
group.top = pH / 2 - group.fontSize / 2
|
group.top = pH / 2 - group.fontSize / 2
|
||||||
widgetStore.addGroup(group)
|
widgetStore.addWidget(group)
|
||||||
// store.dispatch('addWidget', group)
|
// store.dispatch('addWidget', group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,15 @@ import { customAlphabet } from 'nanoid/non-secure'
|
|||||||
const nanoid = customAlphabet('1234567890abcdef', 12)
|
const nanoid = customAlphabet('1234567890abcdef', 12)
|
||||||
|
|
||||||
|
|
||||||
export function addGroup(store: TWidgetStore, group: TdWidgetData[] | TdWidgetData) {
|
export function addGroup(store: TWidgetStore, group: TdWidgetData[]) {
|
||||||
const historyStore = useHistoryStore()
|
const historyStore = useHistoryStore()
|
||||||
const canvasStore = useCanvasStore()
|
const canvasStore = useCanvasStore()
|
||||||
let parent: TdWidgetData | null = null
|
let parent: TdWidgetData | null = null
|
||||||
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) // 找出父组件
|
||||||
})
|
})
|
||||||
tmpGroup.forEach((item) => {
|
group.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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user