1
0
mirror of synced 2026-04-05 07:48:35 +08:00

feat(cli,data-source,editor,playground,runtime): 支持自定义数据源

This commit is contained in:
roymondchen
2023-08-21 16:57:18 +08:00
parent 60e14fe53e
commit 573f1a2c17
28 changed files with 528 additions and 269 deletions

View File

@@ -19,11 +19,13 @@ import React from 'react';
import ReactDOM from 'react-dom';
import Core from '@tmagic/core';
import { DataSourceManager } from '@tmagic/data-source';
import type { MApp } from '@tmagic/schema';
import { AppContent } from '@tmagic/ui-react';
import { getUrlParam } from '@tmagic/utils';
import components from '../.tmagic/comp-entry';
import datasources from '../.tmagic/datasource-entry';
import plugins from '../.tmagic/plugin-entry';
import App from './App';
@@ -51,6 +53,10 @@ const getLocalConfig = (): MApp[] => {
window.magicDSL = [];
Object.entries(datasources).forEach(([type, ds]: [string, any]) => {
DataSourceManager.registe(type, ds);
});
const app = new Core({
ua: window.navigator.userAgent,
config: ((getUrlParam('localPreview') ? getLocalConfig() : window.magicDSL) || [])[0] || {},
@@ -60,6 +66,7 @@ const app = new Core({
app.setDesignWidth(app.env.isWeb ? window.document.documentElement.getBoundingClientRect().width : 375);
Object.keys(components).forEach((type: string) => app.registerComponent(type, components[type]));
Object.values(plugins).forEach((plugin: any) => {
plugin.install(app);
});