mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-23 18:18:12 +00:00
feat: 新增simulatorurl,可以设置cdn使用simulator
This commit is contained in:
parent
0ee8892190
commit
1f45b05028
@ -120,6 +120,12 @@ export default {
|
|||||||
init: async function init(editor) {
|
init: async function init(editor) {
|
||||||
const assets = await editor.utils.get('./assets.json');
|
const assets = await editor.utils.get('./assets.json');
|
||||||
editor.set('assets', assets);
|
editor.set('assets', assets);
|
||||||
|
const simulatorUrl = [
|
||||||
|
'https://dev.g.alicdn.com/ali-lowcode/ali-lowcode-engine/0.9.50/react-simulator-renderer.css',
|
||||||
|
'https://dev.g.alicdn.com/ali-lowcode/ali-lowcode-engine/0.9.50/react-simulator-renderer.js',
|
||||||
|
];
|
||||||
|
editor.set('simulatorUrl', simulatorUrl);
|
||||||
|
// editor.set('renderEnv', 'rax');
|
||||||
|
|
||||||
const schema = await editor.utils.get('./schema.json');
|
const schema = await editor.utils.get('./schema.json');
|
||||||
editor.set('schema', schema);
|
editor.set('schema', schema);
|
||||||
|
|||||||
@ -225,7 +225,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
const vendors = [
|
const vendors = [
|
||||||
// required & use once
|
// required & use once
|
||||||
assetBundle(
|
assetBundle(
|
||||||
this.get('environment') || this.renderEnv === 'rax' ? defaultRaxEnvironment : defaultEnvironment,
|
this.get('environment') || (this.renderEnv === 'rax' ? defaultRaxEnvironment : defaultEnvironment),
|
||||||
AssetLevel.Environment,
|
AssetLevel.Environment,
|
||||||
),
|
),
|
||||||
// required & use once
|
// required & use once
|
||||||
@ -236,7 +236,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
assetBundle(this.theme, AssetLevel.Theme),
|
assetBundle(this.theme, AssetLevel.Theme),
|
||||||
// required & use once
|
// required & use once
|
||||||
assetBundle(
|
assetBundle(
|
||||||
this.get('simulatorUrl') || this.renderEnv === 'rax' ? defaultRaxSimulatorUrl : defaultSimulatorUrl,
|
this.get('simulatorUrl') || (this.renderEnv === 'rax' ? defaultRaxSimulatorUrl : defaultSimulatorUrl),
|
||||||
AssetLevel.Runtime,
|
AssetLevel.Runtime,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { Editor } from '@ali/lowcode-editor-core';
|
import { Editor } from '@ali/lowcode-editor-core';
|
||||||
import { DesignerView, Designer } from '@ali/lowcode-designer';
|
import { DesignerView, Designer } from '@ali/lowcode-designer';
|
||||||
|
import { Asset } from '@ali/lowcode-utils';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
|
||||||
export interface PluginProps {
|
export interface PluginProps {
|
||||||
@ -13,6 +14,7 @@ interface DesignerPluginState {
|
|||||||
extraEnvironment?: any[] | null;
|
extraEnvironment?: any[] | null;
|
||||||
renderEnv?: string;
|
renderEnv?: string;
|
||||||
device?: string;
|
device?: string;
|
||||||
|
simulatorUrl: Asset | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> {
|
export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> {
|
||||||
@ -24,6 +26,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
extraEnvironment: null,
|
extraEnvironment: null,
|
||||||
renderEnv: 'default',
|
renderEnv: 'default',
|
||||||
device: 'default',
|
device: 'default',
|
||||||
|
simulatorUrl: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
private _mounted = true;
|
private _mounted = true;
|
||||||
@ -39,6 +42,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
const assets = await editor.onceGot('assets');
|
const assets = await editor.onceGot('assets');
|
||||||
const renderEnv = await editor.get('renderEnv');
|
const renderEnv = await editor.get('renderEnv');
|
||||||
const device = await editor.get('device');
|
const device = await editor.get('device');
|
||||||
|
const simulatorUrl = await editor.get('simulatorUrl');
|
||||||
if (!this._mounted) {
|
if (!this._mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -49,6 +53,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
extraEnvironment,
|
extraEnvironment,
|
||||||
renderEnv,
|
renderEnv,
|
||||||
device,
|
device,
|
||||||
|
simulatorUrl,
|
||||||
};
|
};
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -71,8 +76,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
|
|
||||||
render(): React.ReactNode {
|
render(): React.ReactNode {
|
||||||
const { editor } = this.props;
|
const { editor } = this.props;
|
||||||
const { componentMetadatas, library, extraEnvironment, renderEnv, device } = this.state;
|
const { componentMetadatas, library, extraEnvironment, renderEnv, device, simulatorUrl } = this.state;
|
||||||
|
|
||||||
if (!library || !componentMetadatas) {
|
if (!library || !componentMetadatas) {
|
||||||
// TODO: use a Loading
|
// TODO: use a Loading
|
||||||
return null;
|
return null;
|
||||||
@ -90,6 +94,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
extraEnvironment,
|
extraEnvironment,
|
||||||
renderEnv,
|
renderEnv,
|
||||||
device,
|
device,
|
||||||
|
simulatorUrl,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -55,5 +55,5 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://registry.npm.alibaba-inc.com"
|
"registry": "https://registry.npm.alibaba-inc.com"
|
||||||
},
|
},
|
||||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@1.0.4-0/build/index.html"
|
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@1.0.5-0/build/index.html"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user