From 327d23ebac239118fc169e2494d3bf32e2d1d79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 9 Jan 2023 11:37:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20JSON=20=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=97=A0=E6=B3=95=E5=A4=84=E7=90=86=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chart/hooks/useSync.hook.ts | 6 +++--- src/views/preview/utils/storage.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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() }