mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 22:21:54 +00:00
fix: 移除 renderer 内 components 的响应式逻辑
refactor: 优化判断点击节点是否在视口内的逻辑 fix: 修复 parseMetadata 后丢失 npm 信息
This commit is contained in:
parent
c6927ed75e
commit
c02f0ec837
@ -25,6 +25,7 @@
|
|||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
|
background-color: white;
|
||||||
> * {
|
> * {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export class ComponentMeta {
|
|||||||
return this._npm;
|
return this._npm;
|
||||||
}
|
}
|
||||||
|
|
||||||
set npm(_npm) {
|
set npm(_npm: any) {
|
||||||
this.setNpm(_npm);
|
this.setNpm(_npm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ export class ComponentMeta {
|
|||||||
|
|
||||||
private parseMetadata(metadata: ComponentMetadata) {
|
private parseMetadata(metadata: ComponentMetadata) {
|
||||||
const { componentName, npm } = metadata;
|
const { componentName, npm } = metadata;
|
||||||
this._npm = npm;
|
this._npm = npm || this._npm;
|
||||||
this._componentName = componentName;
|
this._componentName = componentName;
|
||||||
|
|
||||||
// 额外转换逻辑
|
// 额外转换逻辑
|
||||||
|
|||||||
@ -4,9 +4,20 @@ export function isElementNode(domNode: Element) {
|
|||||||
return domNode.nodeType === Node.ELEMENT_NODE;
|
return domNode.nodeType === Node.ELEMENT_NODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断节点是否在 viewport 内,判断依据:只要节点有一部分在 viewport 内,都算 true,其余情况 false
|
||||||
|
* @param domNode 待检测的节点
|
||||||
|
* @param viewport 画布 viewport
|
||||||
|
* @returns 是否在 viewport 内
|
||||||
|
*/
|
||||||
export function isDOMNodeVisible(domNode: Element, viewport: Viewport) {
|
export function isDOMNodeVisible(domNode: Element, viewport: Viewport) {
|
||||||
const domNodeRect = domNode.getBoundingClientRect();
|
const domNodeRect = domNode.getBoundingClientRect();
|
||||||
const { width, height } = viewport.contentBounds;
|
const { width, height } = viewport.contentBounds;
|
||||||
const { left, right, top, bottom } = domNodeRect;
|
const { left, right, top, bottom, width: nodeWidth, height: nodeHeight } = domNodeRect;
|
||||||
return left >= 0 && top >= 0 && bottom <= height && right <= width;
|
return (
|
||||||
|
left >= -nodeWidth &&
|
||||||
|
top >= -nodeHeight &&
|
||||||
|
bottom <= height + nodeHeight &&
|
||||||
|
right <= width + nodeWidth
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@ -142,6 +142,7 @@ class Renderer extends Component<{
|
|||||||
const messages = container.context?.utils?.i18n?.messages || {};
|
const messages = container.context?.utils?.i18n?.messages || {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// @ts-ignore
|
||||||
<LowCodeRenderer
|
<LowCodeRenderer
|
||||||
locale={locale}
|
locale={locale}
|
||||||
messages={messages}
|
messages={messages}
|
||||||
|
|||||||
@ -46,13 +46,6 @@ export class DocumentInstance {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// private _libraryMap: { [key: string]: string } = {};
|
|
||||||
// private buildComponents() {
|
|
||||||
// this._components = {
|
|
||||||
// ...builtinComponents,
|
|
||||||
// ...buildComponents(this._libraryMap, this._componentsMap),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
@obx.ref private _components: any = {};
|
@obx.ref private _components: any = {};
|
||||||
|
|
||||||
@computed get components(): object {
|
@computed get components(): object {
|
||||||
@ -310,16 +303,15 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
private _libraryMap: { [key: string]: string } = {};
|
private _libraryMap: { [key: string]: string } = {};
|
||||||
|
|
||||||
private buildComponents() {
|
private buildComponents() {
|
||||||
// TODO: remove this.createComponent
|
|
||||||
this._components = buildComponents(this._libraryMap, this._componentsMap, this.createComponent.bind(this));
|
this._components = buildComponents(this._libraryMap, this._componentsMap, this.createComponent.bind(this));
|
||||||
this._components = {
|
this._components = {
|
||||||
...builtinComponents,
|
...builtinComponents,
|
||||||
...this._components,
|
...this._components,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@obx.ref private _components: any = {};
|
private _components: any = {};
|
||||||
|
|
||||||
@computed get components(): object {
|
get components(): object {
|
||||||
// 根据 device 选择不同组件,进行响应式
|
// 根据 device 选择不同组件,进行响应式
|
||||||
// 更好的做法是,根据 device 选择加载不同的组件资源,甚至是 simulatorUrl
|
// 更好的做法是,根据 device 选择加载不同的组件资源,甚至是 simulatorUrl
|
||||||
return this._components;
|
return this._components;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user