Merge pull request #120 from palxiao/feature-vue3

Feature vue3
This commit is contained in:
ShawnPhang 2024-03-30 21:10:09 +08:00 committed by GitHub
commit ff0763cd07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View File

@ -225,7 +225,7 @@ const selectItem = async (item: TGetCompListResult) => {
group.text && (group.text = decodeURIComponent(group.text))
group.left = pW / 2 - group.fontSize * (group.text.length / 2)
group.top = pH / 2 - group.fontSize / 2
widgetStore.addGroup(group)
widgetStore.addWidget(group)
// store.dispatch('addWidget', group)
}
}

View File

@ -12,16 +12,15 @@ import { customAlphabet } from 'nanoid/non-secure'
const nanoid = customAlphabet('1234567890abcdef', 12)
export function addGroup(store: TWidgetStore, group: TdWidgetData[] | TdWidgetData) {
export function addGroup(store: TWidgetStore, group: TdWidgetData[]) {
const historyStore = useHistoryStore()
const canvasStore = useCanvasStore()
let parent: TdWidgetData | null = null
const tmpGroup: TdWidgetData[] = !Array.isArray(group) ? [group] : group
tmpGroup.forEach((item) => {
group.forEach((item) => {
item.uuid = nanoid() // 重设id
item.type === 'w-group' && (parent = item) // 找出父组件
})
tmpGroup.forEach((item) => {
group.forEach((item) => {
!item.isContainer && parent && (item.parent = parent.uuid) // 重设父id
item.text && (item.text = decodeURIComponent(item.text))
store.dWidgets.push(item)