(schema?: ProjectSchema, autoOpen?: boolean | string)
| 100 | */ |
| 101 | @action |
| 102 | load(schema?: ProjectSchema, autoOpen?: boolean | string) { |
| 103 | this.unload() |
| 104 | |
| 105 | this.data = { |
| 106 | ...this.data, |
| 107 | ...schema, |
| 108 | } |
| 109 | this._config = schema?.config ?? this.config |
| 110 | |
| 111 | // perf: 在 open 的时候才创建 document |
| 112 | // if (schema?.documents) { |
| 113 | // for (const document of schema.documents) { |
| 114 | // this.createDocument(document) |
| 115 | // } |
| 116 | // } |
| 117 | |
| 118 | if (autoOpen) { |
| 119 | if (autoOpen === true) { |
| 120 | // auto open first document or open a blank page |
| 121 | const documentInstances = this.data.componentsTree.map(data => this.createDocument(data)) |
| 122 | documentInstances[0].open() |
| 123 | } else { |
| 124 | // auto open should be string of fileName |
| 125 | this.open(autoOpen) |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | @action |
| 131 | unload() { |
no test coverage detected