fix: 修复低代码组件在设计器中使用时切换移动端视图不生效的问题

This commit is contained in:
龙彦 2022-01-07 14:57:34 +08:00
parent 93f7de0309
commit 0b9764d97b
2 changed files with 7 additions and 5 deletions

View File

@ -80,7 +80,8 @@ export class Routes extends Component<{ rendererContainer: SimulatorRendererCont
function ucfirst(s: string) {
return s.charAt(0).toUpperCase() + s.substring(1);
}
function getDeviceView(view: any, device: string, mode: string) {
export function getDeviceView(view: any, device: string, mode: string) {
if (!view || typeof view === 'string') {
return view;
}
@ -126,8 +127,8 @@ class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }
@observer
class Renderer extends Component<{
rendererContainer: SimulatorRendererContainer,
documentInstance: DocumentInstance,
rendererContainer: SimulatorRendererContainer;
documentInstance: DocumentInstance;
}> {
startTime: number | null = null;

View File

@ -1,7 +1,7 @@
import React, { createElement, ReactInstance } from 'react';
import { render as reactRender } from 'react-dom';
import { host } from './host';
import SimulatorRendererView from './renderer-view';
import SimulatorRendererView, { getDeviceView } from './renderer-view';
import { computed, observable as obx, untracked, makeObservable, configure } from 'mobx';
import { getClientRects } from './utils/get-client-rects';
import { reactFindDOMNodes, FIBER_KEY } from './utils/react-find-dom-nodes';
@ -466,7 +466,8 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
isEmpty: () => false,
};
viewProps._leaf = _leaf;
return createElement(Comp, viewProps, children);
const View = getDeviceView(Comp, renderer.device, renderer.designMode);
return createElement(View, viewProps, children);
},
});
}