From e6a99302d65444b0d8d5cd0a8c85b730f1cb12a4 Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Mon, 7 Mar 2022 12:33:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChartItemSetting/PositionSetting.vue | 2 +- .../ChartItemSetting/SizeSetting.vue | 2 +- src/main.ts | 5 ++- .../components/Charts/Bars/BarCommon/index.ts | 3 +- .../Charts/Bars/BarCrossrange/index.ts | 3 +- .../Charts/Lines/LineCommon/index.ts | 3 +- .../Charts/Lines/LineGradientSingle/index.ts | 3 +- .../Charts/Lines/LineGradients/index.ts | 3 +- .../components/Charts/Maps/MapChine/index.ts | 3 +- .../components/Charts/Mores/Funnel/index.ts | 3 +- .../components/Charts/Mores/Heatmap/index.ts | 3 +- .../components/Charts/Mores/Point/index.ts | 3 +- .../components/Charts/Mores/Radar/index.ts | 3 +- .../components/Charts/Mores/TreeMap/index.ts | 3 +- .../components/Charts/Mores/Variable/index.ts | 3 +- .../components/Charts/Pies/PieCommon/index.ts | 3 +- .../Decorates/Borders/borderCommon/index.ts | 3 +- .../Decorates/Mores/Number/index.ts | 3 +- .../components/Decorates/Mores/Time/index.ts | 3 +- .../Decorates/Mores/Weather/index.ts | 3 +- .../Decorates/Mores/WeatherTime/index.ts | 3 +- src/packages/index.d.ts | 5 +-- src/packages/index.ts | 25 +++++++------ src/plugins/customComponents.ts | 18 ++++++++++ src/plugins/index.ts | 2 +- src/utils/componets.ts | 15 +------- .../components/ItemBox/index.vue | 7 ++-- .../components/ChartSetting/index.vue | 6 +--- .../components/EditAlignLine/index.vue | 2 +- .../preview/components/RenderList/index.vue | 6 ---- src/views/preview/index.vue | 36 ++++++------------- src/views/preview/utils/index.ts | 10 +++--- 32 files changed, 102 insertions(+), 93 deletions(-) diff --git a/src/components/ChartItemSetting/PositionSetting.vue b/src/components/ChartItemSetting/PositionSetting.vue index 8d03f6b7..503433fa 100644 --- a/src/components/ChartItemSetting/PositionSetting.vue +++ b/src/components/ChartItemSetting/PositionSetting.vue @@ -30,7 +30,7 @@ import { SettingItemBox } from '@/components/ChartItemSetting/index' const props = defineProps({ chartAttr: { - type: Object as PropType, 'node'>>, + type: Object as PropType, 'node' | 'conNode'>>, required: true } }) diff --git a/src/components/ChartItemSetting/SizeSetting.vue b/src/components/ChartItemSetting/SizeSetting.vue index 6ff8b4b9..d7d8caec 100644 --- a/src/components/ChartItemSetting/SizeSetting.vue +++ b/src/components/ChartItemSetting/SizeSetting.vue @@ -30,7 +30,7 @@ import { SettingItemBox } from '@/components/ChartItemSetting/index' const props = defineProps({ chartAttr: { - type: Object as PropType, 'node'>>, + type: Object as PropType, 'node' | 'conNode'>>, required: true } }) diff --git a/src/main.ts b/src/main.ts index 940ffc14..d4079b05 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import App from './App.vue' import router, { setupRouter } from '@/router' import i18n from '@/i18n/index' import { setupStore } from '@/store' -import { setupNaive, setupDirectives, setupCustomComponents } from '@/plugins' +import { setupNaive, setupDirectives, setupCustomComponents, setupPreviewPackages } from '@/plugins' import { AppProvider } from '@/components/AppProvider/index' import { setHtmlTheme } from '@/utils' @@ -24,6 +24,9 @@ async function appInit() { // 注册全局自定义组件 setupCustomComponents(app) + // 预览页面注册() + setupPreviewPackages(app) + // 挂载状态管理 setupStore(app) diff --git a/src/packages/components/Charts/Bars/BarCommon/index.ts b/src/packages/components/Charts/Bars/BarCommon/index.ts index 9385ef7a..d0868f94 100644 --- a/src/packages/components/Charts/Bars/BarCommon/index.ts +++ b/src/packages/components/Charts/Bars/BarCommon/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const BarCommonConfig: ConfigType = { key: 'VBarCommon', + conKey: 'VCBarCommon', title: '柱状图', category: ChatCategoryEnum.BAR, categoryName: ChatCategoryEnumName.BAR, package: PackagesCategoryEnum.CHARTS, - node: BarCommon, + node: () => BarCommon, conNode: () => Configuration, image: image, } diff --git a/src/packages/components/Charts/Bars/BarCrossrange/index.ts b/src/packages/components/Charts/Bars/BarCrossrange/index.ts index 90dc86b0..3e41dce1 100644 --- a/src/packages/components/Charts/Bars/BarCrossrange/index.ts +++ b/src/packages/components/Charts/Bars/BarCrossrange/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const BarCrossrangefig: ConfigType = { key: 'VBarCrossrange', + conKey: 'VCBarCrossrange', title: '横向柱状图', category: ChatCategoryEnum.BAR, categoryName: ChatCategoryEnumName.BAR, package: PackagesCategoryEnum.CHARTS, - node: BarCrossrange, + node: () => BarCrossrange, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Lines/LineCommon/index.ts b/src/packages/components/Charts/Lines/LineCommon/index.ts index c1912eb5..95292f99 100644 --- a/src/packages/components/Charts/Lines/LineCommon/index.ts +++ b/src/packages/components/Charts/Lines/LineCommon/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const LineCommonConfig: ConfigType = { key: 'VLineCommon', + conKey: 'VCLineCommon', title: '折线图', category: ChatCategoryEnum.LINE, categoryName: ChatCategoryEnumName.LINE, package: PackagesCategoryEnum.CHARTS, - node: LineCommon, + node: () => LineCommon, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Lines/LineGradientSingle/index.ts b/src/packages/components/Charts/Lines/LineGradientSingle/index.ts index 986e82f0..61712e1a 100644 --- a/src/packages/components/Charts/Lines/LineGradientSingle/index.ts +++ b/src/packages/components/Charts/Lines/LineGradientSingle/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const LineGradientSingleConfig: ConfigType = { key: 'VLineGradientSingle', + conKey: 'VCLineGradientSingle', title: '折线面积图', category: ChatCategoryEnum.LINE, categoryName: ChatCategoryEnumName.LINE, package: PackagesCategoryEnum.CHARTS, - node: LineGradientSingle, + node: () => LineGradientSingle, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Lines/LineGradients/index.ts b/src/packages/components/Charts/Lines/LineGradients/index.ts index 43e68ec3..b6783798 100644 --- a/src/packages/components/Charts/Lines/LineGradients/index.ts +++ b/src/packages/components/Charts/Lines/LineGradients/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const LineGradientsConfig: ConfigType = { key: 'VLineGradients', + conKey: 'VCLineGradients', title: '折线面积图', category: ChatCategoryEnum.LINE, categoryName: ChatCategoryEnumName.LINE, package: PackagesCategoryEnum.CHARTS, - node: LineGradients, + node: () => LineGradients, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Maps/MapChine/index.ts b/src/packages/components/Charts/Maps/MapChine/index.ts index 71ac4122..9167548d 100644 --- a/src/packages/components/Charts/Maps/MapChine/index.ts +++ b/src/packages/components/Charts/Maps/MapChine/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const MapChineConfig: ConfigType = { key: 'VMapChine', + conKey: 'VCMapChine', title: '北京地图', category: ChatCategoryEnum.MAP, categoryName: ChatCategoryEnumName.MAP, package: PackagesCategoryEnum.CHARTS, - node: MapChine, + node: () => MapChine, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Mores/Funnel/index.ts b/src/packages/components/Charts/Mores/Funnel/index.ts index f47cc708..64301014 100644 --- a/src/packages/components/Charts/Mores/Funnel/index.ts +++ b/src/packages/components/Charts/Mores/Funnel/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const FunnelConfig: ConfigType = { key: 'VFunnel', + conKey: 'VCFunnel', title: '漏斗图', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.CHARTS, - node: Funnel, + node: () => Funnel, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Mores/Heatmap/index.ts b/src/packages/components/Charts/Mores/Heatmap/index.ts index f4660a62..7fe503dc 100644 --- a/src/packages/components/Charts/Mores/Heatmap/index.ts +++ b/src/packages/components/Charts/Mores/Heatmap/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const HeatmapConfig: ConfigType = { key: 'VHeatmap', + conKey: 'VCHeatmap', title: '热力图', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.CHARTS, - node: Heatmap, + node: () => Heatmap, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Mores/Point/index.ts b/src/packages/components/Charts/Mores/Point/index.ts index e76f81ff..7a07b82f 100644 --- a/src/packages/components/Charts/Mores/Point/index.ts +++ b/src/packages/components/Charts/Mores/Point/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const PointConfig: ConfigType = { key: 'VPoint', + conKey: 'VCPoint', title: '热力图', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.CHARTS, - node: Point, + node: () => Point, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Mores/Radar/index.ts b/src/packages/components/Charts/Mores/Radar/index.ts index 85a31a05..4430c930 100644 --- a/src/packages/components/Charts/Mores/Radar/index.ts +++ b/src/packages/components/Charts/Mores/Radar/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const RadarConfig: ConfigType = { key: 'VRadar', + conKey: 'VCRadar', title: '雷达', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.CHARTS, - node: Radar, + node: () => Radar, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Mores/TreeMap/index.ts b/src/packages/components/Charts/Mores/TreeMap/index.ts index ef24686c..9278edb8 100644 --- a/src/packages/components/Charts/Mores/TreeMap/index.ts +++ b/src/packages/components/Charts/Mores/TreeMap/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const TreeMapConfig: ConfigType = { key: 'VTreeMap', + conKey: 'VCTreeMap', title: '树形分布', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.CHARTS, - node: TreeMap, + node: () => TreeMap, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Mores/Variable/index.ts b/src/packages/components/Charts/Mores/Variable/index.ts index 5350ff77..b73c9521 100644 --- a/src/packages/components/Charts/Mores/Variable/index.ts +++ b/src/packages/components/Charts/Mores/Variable/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const VariableConfig: ConfigType = { key: 'VVariable', + conKey: 'VCVariable', title: '折线面积图', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.CHARTS, - node: Variable, + node: () => Variable, conNode: () => Configuration, image: image } diff --git a/src/packages/components/Charts/Pies/PieCommon/index.ts b/src/packages/components/Charts/Pies/PieCommon/index.ts index 697057a7..9e66c42b 100644 --- a/src/packages/components/Charts/Pies/PieCommon/index.ts +++ b/src/packages/components/Charts/Pies/PieCommon/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' export const PieCommonConfig: ConfigType = { key: 'VPieCommon', + conKey: 'VCPieCommon', title: '饼图', category: ChatCategoryEnum.PIE, categoryName: ChatCategoryEnumName.PIE, package: PackagesCategoryEnum.CHARTS, - node: PieCommon, + node: () => PieCommon, conNode: () => Configuration, image } diff --git a/src/packages/components/Decorates/Borders/borderCommon/index.ts b/src/packages/components/Decorates/Borders/borderCommon/index.ts index efde825a..8fc392eb 100644 --- a/src/packages/components/Decorates/Borders/borderCommon/index.ts +++ b/src/packages/components/Decorates/Borders/borderCommon/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d' export const BorderCommonConfig: ConfigType = { key: 'VBorderCommon', + conKey: 'VCBorderCommon', title: '边框', category: ChatCategoryEnum.BORDER, categoryName: ChatCategoryEnumName.BORDER, package: PackagesCategoryEnum.DECORATES, - node: BorderCommon, + node: () => BorderCommon, conNode: () => Configuration, image } diff --git a/src/packages/components/Decorates/Mores/Number/index.ts b/src/packages/components/Decorates/Mores/Number/index.ts index c6a02efe..38e7b1b8 100644 --- a/src/packages/components/Decorates/Mores/Number/index.ts +++ b/src/packages/components/Decorates/Mores/Number/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d' export const NumberConfig: ConfigType = { key: 'VNumber', + conKey: 'VCNumber', title: '数字翻牌', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.DECORATES, - node: Number, + node: () => Number, conNode: () => Configuration, image } diff --git a/src/packages/components/Decorates/Mores/Time/index.ts b/src/packages/components/Decorates/Mores/Time/index.ts index 8b7b72d6..9918b57d 100644 --- a/src/packages/components/Decorates/Mores/Time/index.ts +++ b/src/packages/components/Decorates/Mores/Time/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d' export const TimeConfig: ConfigType = { key: 'VTime', + conKey: 'VCTime', title: '时间', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.DECORATES, - node: Time, + node: () => Time, conNode: () => Configuration, image } diff --git a/src/packages/components/Decorates/Mores/Weather/index.ts b/src/packages/components/Decorates/Mores/Weather/index.ts index 3d49e095..036b7e54 100644 --- a/src/packages/components/Decorates/Mores/Weather/index.ts +++ b/src/packages/components/Decorates/Mores/Weather/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d' export const WeatherConfig: ConfigType = { key: 'VWeather', + conKey: 'VCWeather', title: '天气', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.DECORATES, - node: Weather, + node: () => Weather, conNode: () => Configuration, image } diff --git a/src/packages/components/Decorates/Mores/WeatherTime/index.ts b/src/packages/components/Decorates/Mores/WeatherTime/index.ts index 9e921e5e..3e28242b 100644 --- a/src/packages/components/Decorates/Mores/WeatherTime/index.ts +++ b/src/packages/components/Decorates/Mores/WeatherTime/index.ts @@ -6,11 +6,12 @@ import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d' export const WeatherTimeConfig: ConfigType = { key: 'VWeatherTime', + conKey: 'VCWeatherTime', title: '天气和时间', category: ChatCategoryEnum.MORE, categoryName: ChatCategoryEnumName.MORE, package: PackagesCategoryEnum.DECORATES, - node: WeatherTime, + node: () => WeatherTime, conNode: () => Configuration, image } diff --git a/src/packages/index.d.ts b/src/packages/index.d.ts index 809b44ca..5a6b1822 100644 --- a/src/packages/index.d.ts +++ b/src/packages/index.d.ts @@ -4,11 +4,12 @@ import { GlobalThemeJsonType } from '@/settings/chartThemes/index' // 组件配置 export type ConfigType = { key: string + conKey: string, title: string category: string categoryName: string package: string - node: Component + node: () => Component conNode: () => Component image: string | (() => Promise) } @@ -22,7 +23,7 @@ export interface PublicConfigType { } export interface CreateComponentType extends PublicConfigType { key: string - chartConfig: Omit + chartConfig: Omit option: GlobalThemeJsonType } diff --git a/src/packages/index.ts b/src/packages/index.ts index 26d0c00f..0203e83c 100644 --- a/src/packages/index.ts +++ b/src/packages/index.ts @@ -10,18 +10,25 @@ import { InformationList } from '@/packages/components/Informations/index' import { TableList } from '@/packages/components/Tables/index' // * 所有图表 -let packagesList: PackagesType = { +export let packagesList: PackagesType = { [PackagesCategoryEnum.CHARTS]: ChartList, [PackagesCategoryEnum.INFORMATION]: InformationList, [PackagesCategoryEnum.TABLES]: TableList, [PackagesCategoryEnum.DECORATES]: DecorateList } +export const packgeInstall = (app:App) => { + ChartList.forEach(e=>{ + console.log(e) + app.component(e.key, e.node) + }) +} + /** - * * 获取目标拖拽组件信息 + * * 获取目标拖拽组件配置信息 * @param dropData */ -const createComponent = async (dropData: ConfigType) => { + export const createComponent = async (dropData: ConfigType) => { const { category } = dropData const key = dropData.key.substring(1) const chart = await import(`./components/${dropData.package}/${category}/${key}/config.ts`) @@ -30,11 +37,9 @@ const createComponent = async (dropData: ConfigType) => { /** * * 获取组件信息 + * * import.meta.globEager 不好使,先从原来的位置拿把 */ -const fetchChartComponent = async (dropData: ConfigType | Omit) => { - const key = dropData.key.substring(1) - const { category } = dropData - return await import(`../packages/components/${dropData.package}/${category}/${key}/index.vue`) -} - -export { packagesList, createComponent, fetchChartComponent } + export const fetchChartComponent = (dropData: ConfigType | Omit) => { + const { key, package:packageName } = dropData + return packagesList[packageName as PackagesCategoryEnum].filter(e=> e.key === key)[0].node() +} \ No newline at end of file diff --git a/src/plugins/customComponents.ts b/src/plugins/customComponents.ts index a11ea0b2..b7b4aef2 100644 --- a/src/plugins/customComponents.ts +++ b/src/plugins/customComponents.ts @@ -1,6 +1,24 @@ import type { App } from 'vue' import { Skeleton } from '@/components/Skeleton' import { LoadingComponent } from '@/components/LoadingComponent' +import { getLocalStorageInfo } from '@/views/preview/utils/index' +import { fetchChartComponent } from '@/packages/index' +import { CreateComponentType } from '@/packages/index.d' + +/** + * * 预览页面动态注册 package 组件 + * @param app + */ +export const setupPreviewPackages = (app: App) => { + const localStorageInfo = getLocalStorageInfo() + if(!document.location.hash.includes('preview') || !localStorageInfo) return + localStorageInfo.componentList.forEach(async (e: CreateComponentType) => { + if (!app.component(e.key)) { + const chart = fetchChartComponent(e.chartConfig) + app.component(e.key, chart) + } + }) +} /** * 全局注册自定义组件 diff --git a/src/plugins/index.ts b/src/plugins/index.ts index c500f63a..36a3dae2 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -1,4 +1,4 @@ export { setupNaive } from '@/plugins/naive' export { setupDirectives } from '@/plugins/directives' -export { setupCustomComponents } from '@/plugins/customComponents' +export { setupCustomComponents, setupPreviewPackages } from '@/plugins/customComponents' export { icon } from '@/plugins/icon' diff --git a/src/utils/componets.ts b/src/utils/componets.ts index a395a7e4..5f729052 100644 --- a/src/utils/componets.ts +++ b/src/utils/componets.ts @@ -1,19 +1,6 @@ import { defineAsyncComponent, AsyncComponentLoader } from 'vue' import { AsyncLoading, AsyncSkeletonLoading } from '@/components/LoadingComponent' -import { ConfigType } from '@/packages/index.d' -import { fetchChartComponent } from '@/packages/index' -/** - * * 预览页面动态注册 package 组件 - * @param {ConfigType} dropData - */ -export const componentPackageInstall = async (dropData: Omit) => { - const key = dropData.key.substring(1) - console.log(window['$vue']); - if (!window['$vue'].component(key)) { - const chart = await fetchChartComponent(dropData) - window['$vue'].component(key, chart) - } -} + /** * * 动态注册组件 */ diff --git a/src/views/chart/ContentCharts/components/ItemBox/index.vue b/src/views/chart/ContentCharts/components/ItemBox/index.vue index 823e43e1..1086538f 100644 --- a/src/views/chart/ContentCharts/components/ItemBox/index.vue +++ b/src/views/chart/ContentCharts/components/ItemBox/index.vue @@ -20,7 +20,7 @@ diff --git a/src/views/chart/ContentConfigurations/components/ChartSetting/index.vue b/src/views/chart/ContentConfigurations/components/ChartSetting/index.vue index 13c04b84..b1f83104 100644 --- a/src/views/chart/ContentConfigurations/components/ChartSetting/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartSetting/index.vue @@ -16,7 +16,7 @@ - + @@ -24,15 +24,11 @@ \ No newline at end of file + diff --git a/src/views/preview/utils/index.ts b/src/views/preview/utils/index.ts index fa8781fe..3d468bc2 100644 --- a/src/views/preview/utils/index.ts +++ b/src/views/preview/utils/index.ts @@ -1,4 +1,4 @@ -import { getLocalStorage, fetchRouteParams } from '@/utils' +import { getLocalStorage } from '@/utils' import { StorageEnum } from '@/enums/storageEnum' import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' @@ -6,10 +6,10 @@ export interface ChartEditStorageType extends ChartEditStorage { id: string } -export const getLocalStorageInfo: () => ChartEditStorageType | undefined = () => { - const routeParamsRes = fetchRouteParams() - if (!routeParamsRes) return - const { id } = routeParamsRes +export const getLocalStorageInfo = () => { + const urlHash = document.location.hash + const toPathArray = urlHash.split('/') + const id = toPathArray && toPathArray[toPathArray.length - 1] const storageList: ChartEditStorageType[] = getLocalStorage( StorageEnum.GO_CHART_STORAGE_LIST