From 5b14e3a70fe0db21485c327724a709adfc07468c Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Mon, 7 Mar 2022 12:51:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=BB=84=E4=BB=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/customComponents.ts | 3 ++- src/views/preview/utils/index.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/customComponents.ts b/src/plugins/customComponents.ts index b7b4aef2..986b226b 100644 --- a/src/plugins/customComponents.ts +++ b/src/plugins/customComponents.ts @@ -10,8 +10,9 @@ import { CreateComponentType } from '@/packages/index.d' * @param app */ export const setupPreviewPackages = (app: App) => { + if(!document.location.hash.includes('preview')) return const localStorageInfo = getLocalStorageInfo() - if(!document.location.hash.includes('preview') || !localStorageInfo) return + if(!localStorageInfo) return localStorageInfo.componentList.forEach(async (e: CreateComponentType) => { if (!app.component(e.key)) { const chart = fetchChartComponent(e.chartConfig) diff --git a/src/views/preview/utils/index.ts b/src/views/preview/utils/index.ts index 3d468bc2..7c1248d0 100644 --- a/src/views/preview/utils/index.ts +++ b/src/views/preview/utils/index.ts @@ -15,6 +15,8 @@ export const getLocalStorageInfo = () => { StorageEnum.GO_CHART_STORAGE_LIST ) + if(!storageList) return + for (let i = 0; i < storageList.length; i++) { if (id.toString() === storageList[i]['id']) { return storageList[i]