mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
perf: 优化 JSON 序列化无法处理函数的问题
This commit is contained in:
@@ -38,7 +38,7 @@ import { MonacoEditor } from '@/components/Pages/MonacoEditor'
|
||||
import { SavePageEnum } from '@/enums/editPageEnum'
|
||||
import { getSessionStorageInfo } from '../preview/utils'
|
||||
import type { ChartEditStorageType } from '../preview/index.d'
|
||||
import { setSessionStorage } from '@/utils'
|
||||
import { setSessionStorage, JSONStringify, JSONParse } from '@/utils'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
import { icon } from '@/plugins'
|
||||
|
||||
@@ -48,7 +48,7 @@ const content = ref('')
|
||||
// 从sessionStorage 获取数据
|
||||
async function getDataBySession() {
|
||||
const localStorageInfo: ChartEditStorageType = await getSessionStorageInfo() as unknown as ChartEditStorageType
|
||||
content.value = JSON.stringify(localStorageInfo, undefined, 2)
|
||||
content.value = JSONStringify(localStorageInfo)
|
||||
}
|
||||
setTimeout(getDataBySession)
|
||||
|
||||
@@ -72,7 +72,7 @@ async function importJSON() {
|
||||
// 同步 [画布页失去焦点时同步数据到JSON页,JSON页Ctrl+S 时同步数据到画布页]
|
||||
window.opener.addEventListener(SavePageEnum.CHART, (e: any) => {
|
||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [e.detail])
|
||||
content.value = JSON.stringify(e.detail, undefined, 2)
|
||||
content.value = JSONStringify(e.detail)
|
||||
})
|
||||
|
||||
// 窗口失焦 + 保存 => 同步数据
|
||||
@@ -90,7 +90,7 @@ async function updateSync() {
|
||||
return window['$message'].error('源窗口已关闭,视图同步失败')
|
||||
}
|
||||
try {
|
||||
const detail = JSON.parse(content.value)
|
||||
const detail = JSONParse(content.value)
|
||||
delete detail.id
|
||||
// 保持id不变
|
||||
window.opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
|
||||
|
||||
Reference in New Issue
Block a user