perf: 编辑JSON兼容后端优化

This commit is contained in:
潘潘
2022-11-15 16:26:52 +08:00
parent dec1130ace
commit 5cc20e9b19
3 changed files with 39 additions and 22 deletions
+11 -2
View File
@@ -38,10 +38,14 @@ 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, fetchRouteParamsLocation } from '@/utils'
import { StorageEnum } from '@/enums/storageEnum'
import { icon } from '@/plugins'
import { useSync } from '@/views/chart/hooks/useSync.hook'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { ProjectInfoEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
const chartEditStore = useChartEditStore()
const { dataSyncUpdate } = useSync()
const { ChevronBackOutlineIcon, DownloadIcon } = icon.ionicons5
const showOpenFilePicker: Function = (window as any).showOpenFilePicker
const content = ref('')
@@ -93,6 +97,11 @@ async function updateSync() {
const detail = JSON.parse(content.value)
delete detail.id
// 保持id不变
// 带后端版本额外处理请求
if (dataSyncUpdate) {
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, fetchRouteParamsLocation())
await dataSyncUpdate(false) // JSON界面保存不上传缩略图
}
window.opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
} catch (e) {
window['$message'].error('内容格式有误')