diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index e18a8b64..387c9870 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -1,6 +1,6 @@ import { onUnmounted } from 'vue'; import html2canvas from 'html2canvas' -import { getUUID, httpErrorHandle, fetchRouteParamsLocation, base64toFile } from '@/utils' +import { getUUID, httpErrorHandle, fetchRouteParamsLocation, base64toFile, JSONStringify, JSONParse } from '@/utils' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { EditCanvasTypeEnum, ChartEditStoreEnum, ProjectInfoEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' @@ -245,7 +245,7 @@ export const useSync = () => { if (res.data) { updateStoreInfo(res.data) // 更新全局数据 - await updateComponent(JSON.parse(res.data.content)) + await updateComponent(JSONParse(res.data.content)) return }else { chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, fetchRouteParamsLocation()) @@ -305,7 +305,7 @@ export const useSync = () => { // 保存数据 let params = new FormData() params.append('projectId', projectId) - params.append('content', JSON.stringify(chartEditStore.getStorageInfo || {})) + params.append('content', JSONStringify(chartEditStore.getStorageInfo || {})) const res= await saveProjectApi(params) if (res && res.code === ResultEnum.SUCCESS) { diff --git a/src/views/preview/utils/storage.ts b/src/views/preview/utils/storage.ts index 94831009..045fac5b 100644 --- a/src/views/preview/utils/storage.ts +++ b/src/views/preview/utils/storage.ts @@ -1,4 +1,4 @@ -import { getSessionStorage, fetchRouteParamsLocation, httpErrorHandle } from '@/utils' +import { getSessionStorage, fetchRouteParamsLocation, httpErrorHandle, JSONParse } from '@/utils' import { ResultEnum } from '@/enums/httpEnum' import { StorageEnum } from '@/enums/storageEnum' import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' @@ -23,7 +23,7 @@ export const getSessionStorageInfo = async () => { // 跳转未发布页 return { isRelease: false } } - return { ...JSON.parse(content), id } + return { ...JSONParse(content), id } } else { httpErrorHandle() }