From 840c2c3c7d267f999e229f7720cbbdc1bf5e2436 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Wed, 2 Apr 2025 17:17:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(data-source):=20=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E6=9C=BA=E6=AF=94=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=97=A9=E5=9B=9E=E5=87=BA=E7=8E=B0=E6=AD=BB=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/data-source/src/DataSourceManager.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/data-source/src/DataSourceManager.ts b/packages/data-source/src/DataSourceManager.ts index e5f0aa8e..939ebb2e 100644 --- a/packages/data-source/src/DataSourceManager.ts +++ b/packages/data-source/src/DataSourceManager.ts @@ -32,11 +32,12 @@ import { compiledNodeField, compliedConditions, compliedIteratorItem, createIter class DataSourceManager extends EventEmitter { private static dataSourceClassMap = new Map(); private static ObservedDataClass: ObservedDataClass = SimpleObservedData; - private static waitInitSchemaList = new Map(); + private static waitInitSchemaList = new Map>(); public static register(type: string, dataSource: T) { DataSourceManager.dataSourceClassMap.set(type, dataSource); - DataSourceManager.waitInitSchemaList?.forEach((list, app) => { + DataSourceManager.waitInitSchemaList?.forEach((listMap, app) => { + const list = listMap[type] || []; for (let config = list.shift(); config; config = list.shift()) { app.addDataSource(config); } @@ -61,7 +62,7 @@ class DataSourceManager extends EventEmitter { constructor({ app, useMock, initialData }: DataSourceManagerOptions) { super(); - DataSourceManager.waitInitSchemaList.set(this, []); + DataSourceManager.waitInitSchemaList.set(this, {}); this.app = app; this.useMock = useMock; @@ -144,7 +145,19 @@ class DataSourceManager extends EventEmitter { const DataSourceClass = DataSourceManager.dataSourceClassMap.get(config.type); if (!DataSourceClass) { - DataSourceManager.waitInitSchemaList.get(this)?.push(config); + let listMap = DataSourceManager.waitInitSchemaList.get(this); + + if (!listMap) { + listMap = {}; + DataSourceManager.waitInitSchemaList.set(this, listMap); + } + + if (listMap[config.type]) { + listMap[config.type].push(config); + } else { + listMap[config.type] = [config]; + } + return; }