From a7905b6a60208935742e69a416ce4018070be122 Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Wed, 19 Jan 2022 19:59:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=BE=E8=A1=A8=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 4 ++++ src/packages/index.ts | 21 ++++++++++++++++--- .../chart/components/ContentLayers/index.vue | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index d1ad1f6f..1dd6bc76 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,7 @@ import router, { setupRouter } from '@/router' import i18n from '@/i18n/index' import { setupStore } from '@/store' import { setupNaive, setupDirectives, setupCustomComponents } from '@/plugins' +import { packagesInstall } from '@/packages/index' import { AppProvider } from '@/components/AppProvider/index' import { setHtmlTheme } from '@/utils' @@ -39,6 +40,9 @@ async function appInit() { // Store 准备就绪后处理主题色 setHtmlTheme() + // 注册 pakage 组件 + app.use(packagesInstall) + // 语言注册 app.use(i18n) diff --git a/src/packages/index.ts b/src/packages/index.ts index 90e0f87a..a5c1e525 100644 --- a/src/packages/index.ts +++ b/src/packages/index.ts @@ -1,4 +1,9 @@ -import { PackagesCategoryEnum, PackagesType } from '@/packages/index.d' +import type { App } from 'vue' +import { + PackagesCategoryEnum, + PackagesType, + ConfigType +} from '@/packages/index.d' import { ChartList } from '@/packages/components/Chart/index' import { DecorateList } from '@/packages/components/Decorate/index' import { InformationList } from '@/packages/components/Information/index' @@ -9,7 +14,17 @@ let packagesList: PackagesType = { [PackagesCategoryEnum.CHARTS]: ChartList, [PackagesCategoryEnum.INFORMATION]: InformationList, [PackagesCategoryEnum.TABLES]: TableList, - [PackagesCategoryEnum.DECORATES]: DecorateList, + [PackagesCategoryEnum.DECORATES]: DecorateList } -export { packagesList } +// 注册 +const packagesInstall = (app: App): void => { + for (const item in packagesList) { + const chartList: ConfigType[] = (packagesList as any)[item] + chartList.forEach((chart: ConfigType) => { + app.component(chart.key, chart.node) + }) + } +} + +export { packagesList, packagesInstall } diff --git a/src/views/chart/components/ContentLayers/index.vue b/src/views/chart/components/ContentLayers/index.vue index 78ba196c..6b24ec8f 100644 --- a/src/views/chart/components/ContentLayers/index.vue +++ b/src/views/chart/components/ContentLayers/index.vue @@ -11,6 +11,7 @@ +