Home > LIB_Classification > getAllClassificationTree
LIB_Classification.getAllClassificationTree() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
警告:此 API 现已弃用。
since EDA v3.2; dropped EDA v3.3
获取所有分类信息组成的树
签名
typescript
function getAllClassificationTree(
libraryUuid: string,
libraryType: ELIB_LibraryType,
): Promise<
Array<{ name: string; uuid: string; children?: undefined | { name: string; uuid: string }[] }>
>;1
2
3
4
5
6
2
3
4
5
6
参数名
参数 | 类型 | 描述 |
|---|---|---|
libraryUuid | string | 库 UUID |
libraryType | 库类型 |
返回值
Promise<Array<{ name: string; uuid: string; children?: undefined | { name: string; uuid: string }[] }>>
分类信息组成的树结构数据
示例
javascript
// 1. 获取个人库 UUID
const libraryUuid = await eda.lib_LibrariesList.getPersonalLibraryUuid();
// 2. 创建一个测试分类,让树里有可见数据(复用模块库,ELIB_LibraryType.CBB = '1')
const name = `嘉立创示例_树查询_${Date.now()}`;
const index = await eda.lib_Classification.createPrimary(libraryUuid, '1', name);
// 3. 读取完整分类树
const tree = await eda.lib_Classification.getAllClassificationTree(libraryUuid, '1');
// 4. 清理测试分类(查询类需要清理)
await eda.lib_Classification.deleteByUuid(libraryUuid, index.primaryClassificationUuid);
// 5. 输出树结构
console.log('total:', tree.length);
tree.forEach((node, i) => {
console.log(`[${i}] name:`, node.name, 'uuid:', node.uuid, 'children:', (node.children || []).length);
});1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18