fix: proxy to object problem

This commit is contained in:
IchliebedichZhu 2024-03-29 15:25:02 +00:00
parent 6fb3526a1a
commit ed41383d8d
2 changed files with 7 additions and 4 deletions

View File

@ -331,7 +331,7 @@ async function handleSelection(e: MouseEvent) {
// this.$store.commit('setMoveable', false)
if (showRotatable.value !== false) {
widgetStore.selectWidget({
uuid: uuid || " -1",
uuid: uuid ?? " -1",
})
// store.dispatch('selectWidget', {
// uuid: uuid,

View File

@ -1,5 +1,6 @@
import { useControlStore, useHistoryStore, usePageStore } from "@/pinia"
import { TWidgetStore } from ".."
import { proxyToObject } from "@/utils/utils"
export type TSelectWidgetData = {
uuid: string
@ -14,10 +15,9 @@ export function selectWidget(store: TWidgetStore, { uuid }: TSelectWidgetData) {
const alt = controlStore.dAltDown
const selectWidgets = store.dSelectWidgets
const widget = store.dWidgets.find((item) => item.uuid === uuid)
if (!widget) return
if (alt) {
if (!widget) return
if (uuid !== '-1' && widget.parent === '-1') {
// && !widget.isContainer
if (selectWidgets.length === 0) {
@ -45,16 +45,19 @@ export function selectWidget(store: TWidgetStore, { uuid }: TSelectWidgetData) {
return
}
store.dSelectWidgets = []
console.log("uuid", uuid);
if (uuid === '-1') {
store.dActiveElement = pageStore.dPage
const pageHistory = historyStore.dPageHistory
if (pageHistory.length === 0) {
pageHistory.push(JSON.stringify(pageStore.dPage))
pageHistory.push(JSON.stringify(proxyToObject(pageStore.dPage)))
}
setTimeout(() => {
store.dSelectWidgets = []
}, 10)
} else {
if (!widget) return
// store.state.dActiveElement = {}
setTimeout(() => {
store.dActiveElement = widget