feat: sync utils/constants for react-simulator-renderer

This commit is contained in:
humphry.hy 2022-05-20 19:17:11 +08:00
parent bdd6a4789d
commit 91252fa1b0
3 changed files with 15 additions and 1 deletions

View File

@ -189,6 +189,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
this.componentsConsumer = new ResourceConsumer<Asset | undefined>(() => this.componentsAsset); this.componentsConsumer = new ResourceConsumer<Asset | undefined>(() => this.componentsAsset);
this.injectionConsumer = new ResourceConsumer(() => { this.injectionConsumer = new ResourceConsumer(() => {
return { return {
appHelper: engineConfig.get('appHelper'),
i18n: this.project.i18n, i18n: this.project.i18n,
}; };
}); });

View File

@ -81,6 +81,17 @@ export interface EngineOptions {
// 是否开启在 render 阶段开启 filter reducer默认值false // 是否开启在 render 阶段开启 filter reducer默认值false
enableFilterReducerInRenderStage?: boolean; enableFilterReducerInRenderStage?: boolean;
}; };
/**
* react-renderer appHelper https://lowcode-engine.cn/docV2/nhilce#appHelper
*/
appHelper?: {
/** 全局公共函数 */
utils?: Record<string, any>;
/** 全局常量 */
constants?: Record<string, any>;
};
[key: string]: any; [key: string]: any;
} }
@ -91,7 +102,7 @@ export class EngineConfig {
string, string,
Array<{ Array<{
once?: boolean; once?: boolean;
resolve:(data: any) => void; resolve: (data: any) => void;
}> }>
>(); >();

View File

@ -31,6 +31,7 @@ import { createMemoryHistory, MemoryHistory } from 'history';
import Slot from './builtin-components/slot'; import Slot from './builtin-components/slot';
import Leaf from './builtin-components/leaf'; import Leaf from './builtin-components/leaf';
import { withQueryParams, parseQuery } from './utils/url'; import { withQueryParams, parseQuery } from './utils/url';
import { merge } from 'lodash';
const loader = new AssetLoader(); const loader = new AssetLoader();
configure({ enforceActions: 'never' }); configure({ enforceActions: 'never' });
@ -322,6 +323,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
...this._appContext, ...this._appContext,
}; };
newCtx.utils.i18n.messages = data.i18n || {}; newCtx.utils.i18n.messages = data.i18n || {};
merge(newCtx, data.appHelper || {});
this._appContext = newCtx; this._appContext = newCtx;
}); });
} }