Merge branch 'fix/lihao-bugs' into 'release/0.9.6'

Fix/lihao bugs



See merge request !939843
This commit is contained in:
高凯 2020-08-19 11:16:36 +08:00
commit 3fc1ff8be6
3 changed files with 11 additions and 8 deletions

View File

@ -208,13 +208,13 @@ export class ComponentMeta {
return result as any;
}
isRootComponent() {
return this.componentName === 'Page' || this.componentName === 'Block' || this.componentName === 'Component';
isRootComponent(includeBlock: boolean = true) {
return this.componentName === 'Page' || this.componentName === 'Component' || (includeBlock && this.componentName === 'Block');
}
@computed get availableActions() {
let { disableBehaviors, actions } = this._transformedMetadata?.configure.component || {};
const disabled = ensureAList(disableBehaviors) || (this.isRootComponent() ? ['copy', 'remove'] : null);
const disabled = ensureAList(disableBehaviors) || (this.isRootComponent(false) ? ['copy', 'remove'] : null);
actions = builtinComponentActions.concat(this.designer.getGlobalComponentActions() || [], actions || []);
if (disabled) {

View File

@ -105,8 +105,6 @@ export class DocumentModel {
if (!schema) {
this._blank = true;
} else {
this.id = project.getSchema()?.id || this.id;
}
this.rootNode = this.createNode<RootNode>(

View File

@ -1,6 +1,6 @@
import { designer } from './editor';
import { RootSchema } from '@ali/lowcode-types';
import { DocumentModel } from '@ali/lowcode-designer';
import { designer } from './editor';
import NodeCacheVisitor from './rootNodeVisitor';
const { project } = designer;
@ -86,7 +86,12 @@ const pages = Object.assign(project, {
page.active();
},
getCurrentPage() {
return project.currentDocument;
if (!project.currentDocument) {
return null;
}
const currentPage = { ...project.currentDocument, id: project.getSchema().id };
Object.setPrototypeOf(currentPage, Object.getPrototypeOf(project.currentDocument || {}));
return currentPage;
},
onPagesChange() {
// noop
@ -101,7 +106,7 @@ const pages = Object.assign(project, {
Object.defineProperty(pages, 'currentPage', {
get() {
return project.currentDocument;
return pages.getCurrentPage();
}
})