Merge branch 'v/0.8.0' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into v/0.8.0

This commit is contained in:
jianfang.rjf 2020-04-02 16:05:47 +08:00
commit eae840f4c4
7 changed files with 55 additions and 12 deletions

View File

@ -8,7 +8,7 @@ import Preview from './plugins/provider';
app.registerRenderer(Renderer);
// 注册布局组件,可注册多个
app.registerLayout('BasicLayout', BasicLayout);
app.registerLayout(BasicLayout, { componentName: 'BasicLayout' });
// 注册页面 Loading
app.registerLoading(FusionLoading);

View File

@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.9.1](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-material-parser@0.9.0...@ali/lowcode-material-parser@0.9.1) (2020-04-01)
### Bug Fixes
* fix bug of missing ajv ([a37d655](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a37d655))
<a name="0.9.0"></a>
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-material-parser@0.8.4...@ali/lowcode-material-parser@0.9.0) (2020-03-31)

View File

@ -1,6 +1,6 @@
{
"name": "@ali/lowcode-material-parser",
"version": "0.9.0",
"version": "0.9.1",
"description": "material parser for Ali lowCode engine",
"main": "lib/index.js",
"files": [
@ -13,8 +13,6 @@
"@types/js-yaml": "^3.12.2",
"@types/lodash": "^4.14.149",
"@types/semver": "^7.1.0",
"ajv": "^6.10.2",
"better-ajv-errors": "^0.6.4",
"globby": "^10.0.1",
"jest": "^24.8.0",
"jest-watch-typeahead": "^0.3.1",
@ -48,6 +46,7 @@
"@babel/parser": "^7.8.4",
"@babel/traverse": "^7.8.4",
"@babel/types": "^7.8.3",
"ajv": "^6.12.0",
"ast-types": "^0.13.3",
"cross-spawn-promise": "^0.10.2",
"debug": "^4.1.1",

View File

@ -1,6 +1,6 @@
{
"name": "@ali/lowcode-runtime",
"version": "0.8.7",
"version": "0.8.9",
"description": "Runtime for Ali lowCode engine",
"files": [
"es",

View File

@ -1,6 +1,11 @@
import { ReactType } from 'react';
import Provider from './provider';
export interface ILayoutOptions {
componentName?: string;
props?: any;
}
export default class Container {
private renderer: ReactType | null = null;
private layouts: { [key: string]: ReactType } = {};
@ -11,7 +16,11 @@ export default class Container {
this.renderer = renderer;
}
registerLayout(componentName: string, Layout: ReactType): any {
registerLayout(Layout: ReactType, options: ILayoutOptions): any {
if (!options) {
return;
}
const { componentName } = options;
if (!componentName || !Layout) {
return;
}

View File

@ -1,5 +1,5 @@
import { ReactType } from 'react';
import Container from './container';
import Container, { ILayoutOptions } from './container';
import run from './run';
class App {
@ -17,8 +17,8 @@ class App {
this.container.registerRenderer(renderer);
}
registerLayout(componentName: string, Layout: ReactType): any {
this.container.registerLayout(componentName, Layout);
registerLayout(Layout: ReactType, options: ILayoutOptions): any {
this.container.registerLayout(Layout, options);
}
registerLoading(component: ReactType) {

View File

@ -27,7 +27,7 @@ interface IHistoryConfig {
basement?: string;
}
interface IAppData {
export interface IAppData {
history?: HistoryMode;
layout?: ILayoutConfig;
routes?: IRouterConfig;
@ -36,6 +36,7 @@ interface IAppData {
componentsMap?: IComponentMap[];
utils?: IUtils;
constants?: IConstants;
i18n?: I18n;
}
export interface ComponentProps {
@ -92,6 +93,13 @@ export interface ComponentModel {
loopArgs?: string[];
}
export interface I18n {
'zh-CN': { [key: string]: string };
'en-US': { [key: string]: string };
}
type Locale = 'zh-CN' | 'en-US';
// export interface IProvider {
// init?(): void;
// getAppData?(appkey: string): Promise<IAppData | undefined>;
@ -109,6 +117,7 @@ export default class Provider {
private componentsMap: IComponentMap[] = [];
private history: HistoryMode = 'hash';
private containerId = '';
private i18n: I18n | null = null;
private lazyElementsMap: { [key: string]: any } = {};
constructor() {
@ -118,15 +127,16 @@ export default class Provider {
async(): Promise<IAppConfig> {
return new Promise(async (resolve, reject) => {
try {
const appData = await this.getAppData();
const appData: IAppData = await this.getAppData();
if (!appData) {
return;
}
const { history, layout, routes, containerId, components, componentsMap, utils, constants } = appData;
const { history, layout, routes, containerId, components, componentsMap, utils, constants, i18n } = appData;
this.setHistory(history);
this.setLayoutConfig(layout);
this.setRouterConfig(routes);
this.setContainerId(containerId);
this.setI18n(i18n);
this.registerComponents(components);
this.registerComponentsMap(componentsMap);
this.registerUtils(utils);
@ -220,6 +230,13 @@ export default class Provider {
this.containerId = id;
}
setI18n(i18n: I18n) {
if (!i18n) {
return;
}
this.i18n = i18n;
}
setlazyElement(pageId: string, cache: any) {
if (!pageId || !cache) {
return;
@ -281,6 +298,13 @@ export default class Provider {
return this.containerId;
}
getI18n(locale?: Locale) {
if (!this.i18n) {
return;
}
return locale ? this.i18n[locale] : this.i18n;
}
getlazyElement(pageId: string) {
if (!pageId) {
return;