fix: 修复获取 currentPage 的逻辑

This commit is contained in:
力皓 2020-08-19 16:40:28 +08:00
parent 4642f2dd99
commit d8221dbfe7
2 changed files with 6 additions and 8 deletions

View File

@ -107,6 +107,9 @@ export class DocumentModel {
this._blank = true;
}
// 兼容 vision
this.id = project.getSchema()?.id || this.id;
this.rootNode = this.createNode<RootNode>(
schema || {
componentName: 'Page',
@ -145,7 +148,7 @@ export class DocumentModel {
* id
*/
nextId() {
return this.id + (++this.seqId).toString(36).toLocaleLowerCase();
return (this.id.slice(-10) + (++this.seqId).toString(36)).toLocaleLowerCase();
}
/**

View File

@ -86,12 +86,7 @@ const pages = Object.assign(project, {
page.active();
},
getCurrentPage() {
if (!project.currentDocument) {
return null;
}
const currentPage = { ...project.currentDocument, id: project.getSchema().id };
Object.setPrototypeOf(currentPage, Object.getPrototypeOf(project.currentDocument || {}));
return currentPage;
return project.currentDocument;
},
onPagesChange() {
// noop
@ -106,7 +101,7 @@ const pages = Object.assign(project, {
Object.defineProperty(pages, 'currentPage', {
get() {
return pages.getCurrentPage();
return project.currentDocument;
}
})