feat: sync utils/constants (#506)

This commit is contained in:
twinkle77 2022-05-19 14:23:15 +08:00 committed by GitHub
parent 8255b79458
commit 2871b5ba4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

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

View File

@ -208,6 +208,15 @@ export interface EngineOptions {
// 是否开启在 render 阶段开启 filter reducer默认值false
enableFilterReducerInRenderStage?: boolean;
};
/**
* react-renderer appHelper https://lowcode-engine.cn/docV2/nhilce#appHelper
*/
appHelper?: {
/** 全局公共函数 */
utils?: Record<string, any>;
/** 全局常量 */
constants?: Record<string, any>;
};
requestHandlersMap: RequestHandlersMap;
}

View File

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