feat: extend deviceClassName

This commit is contained in:
wanying.jwy 2020-08-30 16:43:16 +08:00
parent bccce8c8a9
commit 0e96074c85
3 changed files with 16 additions and 19 deletions

View File

@ -29,23 +29,7 @@
box-shadow: 0 2px 10px 0 rgba(31,56,88,.15); box-shadow: 0 2px 10px 0 rgba(31,56,88,.15);
} }
// &-device-mobile { &-device-iphonex { // 增加默认的小程序的壳
// left: 50%;
// width: 378px;
// transform: translateX(-50%);
// background: url(https://img.alicdn.com/tfs/TB1b4DHilFR4u4jSZFPXXanzFXa-750-1574.png) no-repeat top;
// background-size: 378px 812px;
// top: 8px;
// .@{scope}-canvas-viewport {
// width: auto;
// top: 90px;
// left: 0px;
// right: 0px;
// max-height: 688px;
// }
// }
&-device-miniapp { // 增加默认的小程序的壳
left: 50%; left: 50%;
width: 378px; width: 378px;
transform: translateX(-50%); transform: translateX(-50%);

View File

@ -14,6 +14,7 @@ interface DesignerPluginState {
renderEnv?: string; renderEnv?: string;
device?: string; device?: string;
designMode?: string; designMode?: string;
deviceClassName?: string;
} }
export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> { export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> {
@ -26,6 +27,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
renderEnv: 'default', renderEnv: 'default',
device: 'default', device: 'default',
designMode: 'live', designMode: 'live',
deviceClassName: '',
}; };
private _mounted = true; private _mounted = true;
@ -42,6 +44,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
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 designMode = await editor.get('designMode'); const designMode = await editor.get('designMode');
const deviceClassName = await editor.get('deviceClassName');
if (!this._mounted) { if (!this._mounted) {
return; return;
} }
@ -53,6 +56,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
renderEnv, renderEnv,
device, device,
designMode, designMode,
deviceClassName,
}; };
this.setState(state); this.setState(state);
} catch (e) { } catch (e) {
@ -75,7 +79,15 @@ 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, designMode } = this.state; const {
componentMetadatas,
library,
extraEnvironment,
renderEnv,
device,
designMode,
deviceClassName,
} = this.state;
if (!library || !componentMetadatas) { if (!library || !componentMetadatas) {
// TODO: use a Loading // TODO: use a Loading
@ -95,6 +107,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
renderEnv, renderEnv,
device, device,
designMode, designMode,
deviceClassName,
}} }}
/> />
); );

View File

@ -54,5 +54,5 @@
"publishConfig": { "publishConfig": {
"registry": "http://registry.npm.alibaba-inc.com" "registry": "http://registry.npm.alibaba-inc.com"
}, },
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.8.18/build/index.html" "homepage": "https:/unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.8.18/build/index.html"
} }