mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 02:38:16 +00:00
fix: 修复 setDevice 的时机,从 currentDocument -> simualtor
fix: 根据 canDropIn 来支持选择 Page 节点时是否可添加组件
This commit is contained in:
parent
cb9bce87c9
commit
0f14884bf1
@ -910,6 +910,12 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
if (dropElement) {
|
if (dropElement) {
|
||||||
return { container: dropElement, ref };
|
return { container: dropElement, ref };
|
||||||
}
|
}
|
||||||
|
const rootCanDropIn = this.componentMeta?.prototype?.options?.canDropIn;
|
||||||
|
if (rootCanDropIn === undefined
|
||||||
|
|| rootCanDropIn === true
|
||||||
|
|| (typeof rootCanDropIn === 'function' && rootCanDropIn(node))) {
|
||||||
|
return { container: this, ref };
|
||||||
|
}
|
||||||
// 假如最后找不到合适位置,返回 undefined 阻止继续插入节点
|
// 假如最后找不到合适位置,返回 undefined 阻止继续插入节点
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -248,6 +248,7 @@ export class Project {
|
|||||||
private mountSimulator(simulator: ISimulatorHost) {
|
private mountSimulator(simulator: ISimulatorHost) {
|
||||||
// TODO: 多设备 simulator 支持
|
// TODO: 多设备 simulator 支持
|
||||||
this._simulator = simulator;
|
this._simulator = simulator;
|
||||||
|
this.designer.editor.set('simulator', simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
setRendererReady(renderer: any) {
|
setRendererReady(renderer: any) {
|
||||||
|
|||||||
@ -194,8 +194,8 @@ export class Viewport {
|
|||||||
async setDevice(device = 'pc') {
|
async setDevice(device = 'pc') {
|
||||||
if (this.getDevice() !== device) {
|
if (this.getDevice() !== device) {
|
||||||
this.device = device;
|
this.device = device;
|
||||||
const currentDocument = await editor.onceGot('currentDocument');
|
const simulator = await editor.onceGot('simulator');
|
||||||
currentDocument?.simulator?.set('device', device === 'mobile' ? 'mobile' : 'default');
|
simulator?.set('device', device === 'mobile' ? 'mobile' : 'default');
|
||||||
// Flags.setSimulator(device);
|
// Flags.setSimulator(device);
|
||||||
// this.applyMediaCSS();
|
// this.applyMediaCSS();
|
||||||
this.emitter.emit('devicechange', device);
|
this.emitter.emit('devicechange', device);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user