mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 14:04:28 +00:00
fix: 处理 function component 无法选中的问题,本质上是没有 ref
fix: 处理 filter 组件在每次重绘时 fieldId 变更的 bug
This commit is contained in:
parent
16b427ba87
commit
fa94aab3cb
@ -461,9 +461,9 @@ export class DocumentModel {
|
|||||||
* 从项目中移除
|
* 从项目中移除
|
||||||
*/
|
*/
|
||||||
remove() {
|
remove() {
|
||||||
|
this.designer.postEvent('document.remove', { id: this.id });
|
||||||
this.purge();
|
this.purge();
|
||||||
this.project.removeDocument(this);
|
this.project.removeDocument(this);
|
||||||
this.designer.postEvent('document.remove', { id: this.id });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
purge() {
|
purge() {
|
||||||
|
|||||||
@ -69,8 +69,6 @@ export default class Bundle {
|
|||||||
|
|
||||||
// invoke prototype mocker while the prototype does not exist
|
// invoke prototype mocker while the prototype does not exist
|
||||||
Object.keys(this.viewsMap).forEach((viewName) => {
|
Object.keys(this.viewsMap).forEach((viewName) => {
|
||||||
const test = this;
|
|
||||||
// console.log(test, viewName);
|
|
||||||
if (!this.prototypeList.find((proto) => proto.getComponentName() === viewName)) {
|
if (!this.prototypeList.find((proto) => proto.getComponentName() === viewName)) {
|
||||||
const mockedPrototype = trunk.mockComponentPrototype(this.viewsMap[viewName]);
|
const mockedPrototype = trunk.mockComponentPrototype(this.viewsMap[viewName]);
|
||||||
if (mockedPrototype) {
|
if (mockedPrototype) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ComponentType, ReactElement } from 'react';
|
import { ComponentType, ReactElement, Component, FunctionComponent } from 'react';
|
||||||
import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem, isI18nData } from '@ali/lowcode-types';
|
import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem, isI18nData } from '@ali/lowcode-types';
|
||||||
import {
|
import {
|
||||||
ComponentMeta,
|
ComponentMeta,
|
||||||
@ -220,14 +220,14 @@ class Prototype {
|
|||||||
readonly isPrototype = true;
|
readonly isPrototype = true;
|
||||||
readonly meta: ComponentMeta;
|
readonly meta: ComponentMeta;
|
||||||
readonly options: OldPrototypeConfig | ComponentMetadata;
|
readonly options: OldPrototypeConfig | ComponentMetadata;
|
||||||
view: ComponentType;
|
|
||||||
// componentName: string;
|
|
||||||
get componentName() {
|
get componentName() {
|
||||||
return this.getId();
|
return this.getId();
|
||||||
}
|
}
|
||||||
get packageName() {
|
get packageName() {
|
||||||
return this.meta.npm?.package;
|
return this.meta.npm?.package;
|
||||||
}
|
}
|
||||||
|
// 兼容原 vision 用法
|
||||||
|
view: ComponentType | undefined;
|
||||||
|
|
||||||
constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta, extraConfigs: any = null, lookup: boolean = false) {
|
constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta, extraConfigs: any = null, lookup: boolean = false) {
|
||||||
if (lookup) {
|
if (lookup) {
|
||||||
@ -327,19 +327,30 @@ class Prototype {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setView(view: ComponentType<any>) {
|
setView(view: ComponentType<any>) {
|
||||||
this.view = view;
|
let wrappedView = view;
|
||||||
|
if (!view?.prototype?.isReactComponent) {
|
||||||
|
const ViewComponentClass = class extends Component {
|
||||||
|
render() {
|
||||||
|
return (view as FunctionComponent)(this.props);
|
||||||
|
}
|
||||||
|
} as any;
|
||||||
|
ViewComponentClass.displayName = view.displayName;
|
||||||
|
wrappedView = ViewComponentClass;
|
||||||
|
}
|
||||||
|
this.view = wrappedView;
|
||||||
const metadata = this.meta.getMetadata();
|
const metadata = this.meta.getMetadata();
|
||||||
if (!metadata.experimental) {
|
if (!metadata.experimental) {
|
||||||
metadata.experimental = {
|
metadata.experimental = {
|
||||||
view,
|
view: wrappedView,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
metadata.experimental.view = view;
|
metadata.experimental.view = wrappedView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getView() {
|
getView() {
|
||||||
return (
|
return (
|
||||||
|
this.view ||
|
||||||
this.meta.getMetadata().experimental?.view ||
|
this.meta.getMetadata().experimental?.view ||
|
||||||
designer.currentDocument?.simulator?.getComponent(this.getComponentName())
|
designer.currentDocument?.simulator?.getComponent(this.getComponentName())
|
||||||
);
|
);
|
||||||
|
|||||||
@ -106,7 +106,8 @@ designer.addPropsReducer((props, node) => {
|
|||||||
fieldIds.push(fieldId);
|
fieldIds.push(fieldId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (fieldIds.indexOf(props.fieldId) >= 0) {
|
// 全局的关闭 uniqueIdChecker 信号,在 ve-utils 中实现
|
||||||
|
if (fieldIds.indexOf(props.fieldId) >= 0 && !window.__disable_unique_id_checker__) {
|
||||||
newProps.fieldId = undefined;
|
newProps.fieldId = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,6 @@ export class TreeMaster {
|
|||||||
return this.treeMap.get(id)!;
|
return this.treeMap.get(id)!;
|
||||||
}
|
}
|
||||||
const tree = new Tree(doc);
|
const tree = new Tree(doc);
|
||||||
// TODO: listen purge event to remove
|
|
||||||
this.treeMap.set(id, tree);
|
this.treeMap.set(id, tree);
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user