mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-20 23:52:28 +00:00
fix: 修复画布切换设备类型时,修改配置在画布中不生效
This commit is contained in:
parent
f77b1dc0fa
commit
a10b2423ea
@ -5,7 +5,6 @@ import { EngineOptions } from '@ali/lowcode-editor-core';
|
|||||||
import adapter from '../adapter';
|
import adapter from '../adapter';
|
||||||
import * as types from '../types/index';
|
import * as types from '../types/index';
|
||||||
|
|
||||||
|
|
||||||
export interface IComponentHocInfo {
|
export interface IComponentHocInfo {
|
||||||
schema: any;
|
schema: any;
|
||||||
baseRenderer: types.IBaseRendererInstance;
|
baseRenderer: types.IBaseRendererInstance;
|
||||||
@ -17,7 +16,7 @@ type DesignMode = Pick<EngineOptions, 'designMode'>['designMode'];
|
|||||||
|
|
||||||
export type IComponentHoc = {
|
export type IComponentHoc = {
|
||||||
designMode: DesignMode | DesignMode[];
|
designMode: DesignMode | DesignMode[];
|
||||||
hoc: IComponentConstruct,
|
hoc: IComponentConstruct;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IComponentConstruct = (Comp: types.IBaseRenderer, info: IComponentHocInfo) => types.Constructor;
|
export type IComponentConstruct = (Comp: types.IBaseRenderer, info: IComponentHocInfo) => types.Constructor;
|
||||||
@ -44,7 +43,7 @@ enum RerenderType {
|
|||||||
|
|
||||||
// 缓存 Leaf 层组件,防止重新渲染问题
|
// 缓存 Leaf 层组件,防止重新渲染问题
|
||||||
class LeafCache {
|
class LeafCache {
|
||||||
constructor(public documentId: string) {
|
constructor(public documentId: string, public device: 'mobile' | 'web') {
|
||||||
}
|
}
|
||||||
/** 组件缓存 */
|
/** 组件缓存 */
|
||||||
component = new Map();
|
component = new Map();
|
||||||
@ -126,6 +125,7 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
const engine = baseRenderer.context.engine;
|
const engine = baseRenderer.context.engine;
|
||||||
const host: BuiltinSimulatorHost = baseRenderer.props.__host;
|
const host: BuiltinSimulatorHost = baseRenderer.props.__host;
|
||||||
const curDocumentId = baseRenderer.props?.documentId;
|
const curDocumentId = baseRenderer.props?.documentId;
|
||||||
|
const curDevice = baseRenderer.props?.device;
|
||||||
const getNode = baseRenderer.props?.getNode;
|
const getNode = baseRenderer.props?.getNode;
|
||||||
const container: BuiltinSimulatorHost = baseRenderer.props.__container;
|
const container: BuiltinSimulatorHost = baseRenderer.props.__container;
|
||||||
const setSchemaChangedSymbol = baseRenderer.props?.setSchemaChangedSymbol;
|
const setSchemaChangedSymbol = baseRenderer.props?.setSchemaChangedSymbol;
|
||||||
@ -134,11 +134,11 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
|
|
||||||
const componentCacheId = schema.id;
|
const componentCacheId = schema.id;
|
||||||
|
|
||||||
if (!cache || (curDocumentId && curDocumentId !== cache.documentId)) {
|
if (!cache || (curDocumentId && curDocumentId !== cache.documentId) || (curDevice && curDevice !== cache.device)) {
|
||||||
cache?.event.forEach(event => {
|
cache?.event.forEach(event => {
|
||||||
event.dispose?.forEach((disposeFn: any) => disposeFn && disposeFn());
|
event.dispose?.forEach((disposeFn: any) => disposeFn && disposeFn());
|
||||||
});
|
});
|
||||||
cache = new LeafCache(curDocumentId);
|
cache = new LeafCache(curDocumentId, curDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isReactComponent(Comp)) {
|
if (!isReactComponent(Comp)) {
|
||||||
@ -262,9 +262,9 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderUnitInfo: {
|
renderUnitInfo: {
|
||||||
minimalUnitId?: string,
|
minimalUnitId?: string;
|
||||||
minimalUnitName?: string;
|
minimalUnitName?: string;
|
||||||
singleRender?: boolean,
|
singleRender?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
shouldRenderSingleNode(): boolean {
|
shouldRenderSingleNode(): boolean {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user