Home > LIB_Cbb > openProjectInEditor
LIB_Cbb.openProjectInEditor() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
在编辑器打开复用模块工程
签名
typescript
function openProjectInEditor(cbbUuid: string, libraryUuid: string): Promise<boolean>;1
参数名
参数 | 类型 | 描述 |
|---|---|---|
cbbUuid | string | 复用模块 UUID |
libraryUuid | string | 库 UUID,可以使用 LIB_LibrariesList 内的接口获取 |
返回值
Promise<boolean>
备注
本操作将会在 EDA 前端打开模块工程,如若原先已打开其它工程且有未保存的变更,执行本操作将直接丢失所有未保存的数据
示例
javascript
// 1. 记录当前工程,便于演示结束后恢复
const projectInfo = await eda.dmt_Project.getCurrentProjectInfo();
// 2. 复制一个系统库模块到个人库作为打开对象
const systemLib = await eda.lib_LibrariesList.getSystemLibraryUuid();
const personalLib = await eda.lib_LibrariesList.getPersonalLibraryUuid();
const results = await eda.lib_Cbb.search('', systemLib, undefined, 1);
const source = results[0];
const cbbUuid = await eda.lib_Cbb.copy(source.uuid, systemLib, personalLib, [], `嘉立创示例_打开工程_${Date.now()}`);
// 3. 在编辑器打开模块工程
const opened = await eda.lib_Cbb.openProjectInEditor(cbbUuid, personalLib);
// 4. 恢复原来打开的工程
await new Promise(r => setTimeout(r, 1000));
await eda.dmt_Project.openProject(projectInfo.uuid);
console.log('source:', source.name, source.uuid);
console.log('opened:', opened);
console.log('restored:', projectInfo.uuid);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20