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; this._blank = true;
} }
// 兼容 vision
this.id = project.getSchema()?.id || this.id;
this.rootNode = this.createNode<RootNode>( this.rootNode = this.createNode<RootNode>(
schema || { schema || {
componentName: 'Page', componentName: 'Page',
@ -145,7 +148,7 @@ export class DocumentModel {
* id * id
*/ */
nextId() { 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(); page.active();
}, },
getCurrentPage() { getCurrentPage() {
if (!project.currentDocument) { return project.currentDocument;
return null;
}
const currentPage = { ...project.currentDocument, id: project.getSchema().id };
Object.setPrototypeOf(currentPage, Object.getPrototypeOf(project.currentDocument || {}));
return currentPage;
}, },
onPagesChange() { onPagesChange() {
// noop // noop
@ -106,7 +101,7 @@ const pages = Object.assign(project, {
Object.defineProperty(pages, 'currentPage', { Object.defineProperty(pages, 'currentPage', {
get() { get() {
return pages.getCurrentPage(); return project.currentDocument;
} }
}) })