Pārlūkot izejas kodu

fix: 解决首页注册组件的bug

MTrun 3 gadi atpakaļ
vecāks
revīzija
9295b93116
2 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. 2 1
      src/plugins/customComponents.ts
  2. 2 0
      src/views/preview/utils/index.ts

+ 2 - 1
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)

+ 2 - 0
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]