mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
Merge branch 'fix/component-not-found' into 'release/0.9.3'
fix组件缺失占位 See merge request !927746
This commit is contained in:
commit
270e27cc38
@ -302,6 +302,11 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
|
||||
const nodeInst = this.getNodeInstanceFromElement(downEvent.target as Element);
|
||||
const node = nodeInst?.node || this.document.rootNode;
|
||||
if (!node?.isValidComponent()) {
|
||||
// 对于未注册组件直接返回
|
||||
return;
|
||||
}
|
||||
|
||||
const isMulti = downEvent.metaKey || downEvent.ctrlKey;
|
||||
const isLeftButton = downEvent.which === 1 || downEvent.button === 0;
|
||||
const checkSelect = (e: MouseEvent) => {
|
||||
|
||||
@ -653,6 +653,16 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
slotNode.internalSetParent(this as ParentalNode, true);
|
||||
this._slots.push(slotNode);
|
||||
}
|
||||
/**
|
||||
* 当前node对应组件是否已注册可用
|
||||
*/
|
||||
isValidComponent() {
|
||||
const allComponents = this.document?.designer?.componentsMap;
|
||||
if (allComponents && allComponents[this.componentName]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个节点
|
||||
@ -702,6 +712,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
getComponentName() {
|
||||
return this.componentName;
|
||||
}
|
||||
|
||||
insertBefore(node: Node, ref?: Node, useMutator = true) {
|
||||
this.children?.insert(node, ref ? ref.index : null, useMutator);
|
||||
}
|
||||
|
||||
@ -36,8 +36,18 @@ class FaultComponent extends PureComponent {
|
||||
|
||||
class NotFoundComponent extends PureComponent {
|
||||
render() {
|
||||
console.error('component not found', this.props);
|
||||
return <Div {...this.props} />;
|
||||
console.error('component not found:', this.props);
|
||||
const { _componentName: componentName } = this.props;
|
||||
return <Div
|
||||
{...this.props}
|
||||
style={{
|
||||
backgroundColor: '#3E91C9',
|
||||
padding: '15px',
|
||||
fontSize: '18px',
|
||||
textAlign: 'center',
|
||||
color: 'white',
|
||||
}}
|
||||
>组件 {componentName} 无视图,请打开控制台排查</Div>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user