fix: proxy to object problem

This commit is contained in:
IchliebedichZhu 2024-03-29 14:55:26 +00:00
parent 946d9bcf7a
commit 6fb3526a1a
2 changed files with 6 additions and 2 deletions

View File

@ -51,6 +51,7 @@ import TabPanel from '@palxp/color-picker/comps/TabPanel.vue'
import { usePageStore, useWidgetStore } from '@/pinia'
import { TPageState, } from '@/pinia/design/page'
import { storeToRefs } from 'pinia'
import { proxyToObject } from '@/utils/utils'
type TState = {
activeNames: string[]
@ -120,7 +121,7 @@ function onChangeMode(value: string) {
function change() {
state.mode = state.modes[0]
state.tag = true
state.innerElement = JSON.parse(JSON.stringify(dActiveElement.value))
state.innerElement = proxyToObject(dActiveElement.value || {})
state.innerElement.backgroundImage && (state.mode = state.modes[1])
}
function changeValue() {

View File

@ -99,7 +99,10 @@ export const proxyToObject = <P extends Record<string, any>>(proxy: P, seen = ne
seen.set(proxy, obj);
for (let key in proxy) {
if (proxy.hasOwnProperty(key)) {
obj[key] = proxyToObject(proxy[key], seen);
const value = proxyToObject(proxy[key], seen);
if (value !== '[Circular Reference]') {
obj[key] = value;
}
}
}
}