MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / load

Method load

packages/designer/src/project/project.ts:209–241  ·  view source on GitHub ↗
(schema?: IPublicTypeProjectSchema, autoOpen?: boolean | string)

Source from the content-addressed store, hash-verified

207 */
208 @action
209 load(schema?: IPublicTypeProjectSchema, autoOpen?: boolean | string) {
210 this.unload();
211 // load new document
212 this.data = {
213 version: '1.0.0',
214 componentsMap: [],
215 componentsTree: [],
216 i18n: {},
217 ...schema,
218 };
219 this.config = schema?.config || this.config;
220 this.i18n = schema?.i18n || this.i18n;
221
222 if (autoOpen) {
223 if (autoOpen === true) {
224 // auto open first document or open a blank page
225 // this.open(this.data.componentsTree[0]);
226 const documentInstances = this.data.componentsTree.map((data) => this.createDocument(data));
227 // TODO: 暂时先读 config tabBar 里的值,后面看整个 layout 结构是否能作为引擎规范
228 if (this.config?.layout?.props?.tabBar?.items?.length > 0) {
229 // slice(1) 这个贼不雅,默认任务 fileName 是类'/fileName'的形式
230 documentInstances
231 .find((i) => i.fileName === this.config.layout.props.tabBar.items[0].path?.slice(1))
232 ?.open();
233 } else {
234 documentInstances[0].open();
235 }
236 } else {
237 // auto open should be string of fileName
238 this.open(autoOpen);
239 }
240 }
241 }
242
243 /**
244 * 卸载当前项目数据

Callers 1

constructorMethod · 0.95

Calls 6

unloadMethod · 0.95
createDocumentMethod · 0.95
openMethod · 0.95
mapMethod · 0.65
openMethod · 0.65
findMethod · 0.65

Tested by

no test coverage detected