From e3816524da0f0332b84d93b0e4ad5b426c709c63 Mon Sep 17 00:00:00 2001 From: mtruning <1262327911@qq.com> Date: Sun, 6 Mar 2022 20:31:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=A2=84=E8=A7=88?= =?UTF-8?q?=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/HeaderRightBtn/index.vue | 11 +++++++---- src/views/preview/index.vue | 2 +- .../Create/components/CreateModal/index.vue | 14 ++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/views/chart/HeaderRightBtn/index.vue b/src/views/chart/HeaderRightBtn/index.vue index b5694ec7..ea1f9197 100644 --- a/src/views/chart/HeaderRightBtn/index.vue +++ b/src/views/chart/HeaderRightBtn/index.vue @@ -31,21 +31,24 @@ const previewHandle = () => { const { id } = routerParamsInfo.params // id 标识 const previewId = typeof id === 'string' ? id : id[0] - const storageInfo = chartEditStore.getStorageInfo const localStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || [] if (localStorageInfo?.length) { - // 重复替换 const repeateIndex = localStorageInfo.findIndex((e: { id: string }) => e.id === previewId) + // 重复替换 if (repeateIndex !== -1) { localStorageInfo.splice(repeateIndex, 1, { id: previewId, ...storageInfo }) + setLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST, localStorageInfo) + } else { + localStorageInfo.push({ + id: previewId, ...storageInfo + }) + setLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST, localStorageInfo) } - setLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST, localStorageInfo) } else { setLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }]) } - // 跳转 routerTurnByPath(path, [previewId], undefined, true) } diff --git a/src/views/preview/index.vue b/src/views/preview/index.vue index dd273477..d0d6386f 100644 --- a/src/views/preview/index.vue +++ b/src/views/preview/index.vue @@ -55,7 +55,7 @@ const previewRefStyle = computed(() => { if (!localStorageInfo) { window['$message'].warning('获取数据失败') } - +console.log(localStorageInfo); nextTick(() => { const { calcRate, windowResize, unWindowResize } = usePreviewScale(width.value as number, height.value as number, previewRef.value) diff --git a/src/views/project/layout/components/Create/components/CreateModal/index.vue b/src/views/project/layout/components/Create/components/CreateModal/index.vue index ca5bbce0..5b03130f 100644 --- a/src/views/project/layout/components/Create/components/CreateModal/index.vue +++ b/src/views/project/layout/components/Create/components/CreateModal/index.vue @@ -20,7 +20,7 @@ :key="item.key" @click="btnHandle" > - + - + @@ -38,7 +38,7 @@ import { watch, reactive } from 'vue' import { icon } from '@/plugins' import { PageEnum, ChartEnum } from '@/enums/pageEnum' -import { routerTurnByName, renderLang } from '@/utils' +import { fetchPathByName, routerTurnByPath, renderLang, getUUID } from '@/utils' const { FishIcon, CloseIcon } = icon.ionicons5 const { StoreIcon, ObjectStorageIcon } = icon.carbon @@ -84,13 +84,15 @@ const closeHandle = () => { // 处理按钮点击 const btnHandle = (key: string) => { closeHandle() - routerTurnByName(ChartEnum.CHART_HOME_NAME, undefined, true) + const id = getUUID() + const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href') + routerTurnByPath(path, [id], undefined, true) }