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) // this.$store.commit('setMoveable', false)
if (showRotatable.value !== false) { if (showRotatable.value !== false) {
widgetStore.selectWidget({ widgetStore.selectWidget({
uuid: uuid || " -1", uuid: uuid ?? " -1",
}) })
// store.dispatch('selectWidget', { // store.dispatch('selectWidget', {
// uuid: uuid, // uuid: uuid,

View File

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