1
0
mirror of synced 2026-03-24 20:18:35 +08:00

chore(core,data-source): 将app传入datasourceManager

This commit is contained in:
roymondchen
2023-08-25 17:39:37 +08:00
parent 8c93d9a5be
commit 7f48b4d9f5
6 changed files with 74 additions and 80 deletions

View File

@@ -17,11 +17,9 @@
*/
import { cloneDeep } from 'lodash-es';
import type { MApp } from '@tmagic/schema';
import { getDepNodeIds, getNodes, replaceChildNode } from '@tmagic/utils';
import DataSourceManager from './DataSourceManager';
import type { HttpDataSourceOptions } from './types';
/**
* 创建数据源管理器
@@ -29,19 +27,11 @@ import type { HttpDataSourceOptions } from './types';
* @param httpDataSourceOptions http 数据源配置
* @returns DataSourceManager
*/
export const createDataSourceManager = (
dsl: MApp,
platform: string,
httpDataSourceOptions?: Partial<HttpDataSourceOptions>,
) => {
export const createDataSourceManager = (app: any) => {
const { dsl, platform } = app;
if (!dsl?.dataSources) return;
const dataSourceManager = new DataSourceManager({
dataSourceConfigs: dsl.dataSources,
dataSourceDeps: dsl.dataSourceDeps,
dataSourceCondDeps: dsl.dataSourceCondDeps,
httpDataSourceOptions,
});
const dataSourceManager = new DataSourceManager({ app });
if (dsl.dataSources && dsl.dataSourceCondDeps && platform !== 'editor') {
getNodes(getDepNodeIds(dsl.dataSourceCondDeps), dsl.items).forEach((node) => {