获取标签树与直接关联的卡片
const r = await mn.api('/study-sets/' + topicid + '/hashtags?withNotes=1');
// 卡片 id 在扁平的 nodes 上,嵌套的 tree 里没有
const node = r.nodes.find(n => n.hashtag === '#VocabPending');
mn.log(node.directCardCount, node.directNoteIds, node.derived);{
"bridgeApiVersion": "0.61",
"storedHashtagCount": 2,
"hashtags": [
"#FormulaPending",
"#practice/question"
],
"title": "理工公式对照材料 · 样例",
"tree": [
{
"depth": 1,
"segments": [
"FormulaPending"
],
"directCardCount": 1,
"ancestors": [],
"hashtag": "#FormulaPending",
"cardCount": 1,
"path": "FormulaPending",
"derived": false,
"name": "FormulaPending"
},
{
"depth": 1,
"segments": [
"practice"
],
"directCardCount": 0,
"ancestors": [],
"children": [
{
"depth": 2,
"segments": [
"practice",
"question"
],
"directCardCount": 9,
"ancestors": [
"#practice"
],
"hashtag": "#practice/question",
"cardCount": 9,
"path": "practice/question",
"derived": false,
"name": "question"
}
],
"hashtag": "#practice",
"cardCount": 9,
"path": "practice",
"derived": true,
"name": "practice"
}
],
"nodes": [
{
"depth": 1,
"segments": [
"FormulaPending"
],
"directCardCount": 1,
"ancestors": [],
"hashtag": "#FormulaPending",
"cardCount": 1,
"path": "FormulaPending",
"derived": false,
"name": "FormulaPending"
},
{
"depth": 1,
"segments": [
"practice"
],
"directCardCount": 0,
"ancestors": [],
"hashtag": "#practice",
"cardCount": 9,
"path": "practice",
"derived": true,
"name": "practice"
},
{
"depth": 2,
"segments": [
"practice",
"question"
],
"directCardCount": 9,
"ancestors": [
"#practice"
],
"hashtag": "#practice/question",
"cardCount": 9,
"path": "practice/question",
"derived": false,
"name": "question"
}
],
"studySetId": "77012CA0-48E8-4D29-B5F5-1EEA927AE086",
"taggedCardCount": 9
}学习集与卡组
获取标签树
读整个学习集的标签:实际存储的标签、扁平展开的层级、嵌套的层级树。
nodes 是扁平数组,tree 是嵌套数组,卡片 id 只挂在扁平的 nodes 上。
directCardCount 只统计明确存了该条完整路径的卡,cardCount 还包含所有下层路径
覆盖到的卡。derived 的含义见字段说明。
传入 withNotes=1 时,卡片 id 的返回规则见参数说明;数量超出 noteIdLimit 时仅标记截断,不自动省略。
GET
/
study-sets
/
{topicid}
/
hashtags
获取标签树与直接关联的卡片
const r = await mn.api('/study-sets/' + topicid + '/hashtags?withNotes=1');
// 卡片 id 在扁平的 nodes 上,嵌套的 tree 里没有
const node = r.nodes.find(n => n.hashtag === '#VocabPending');
mn.log(node.directCardCount, node.directNoteIds, node.derived);{
"bridgeApiVersion": "0.61",
"storedHashtagCount": 2,
"hashtags": [
"#FormulaPending",
"#practice/question"
],
"title": "理工公式对照材料 · 样例",
"tree": [
{
"depth": 1,
"segments": [
"FormulaPending"
],
"directCardCount": 1,
"ancestors": [],
"hashtag": "#FormulaPending",
"cardCount": 1,
"path": "FormulaPending",
"derived": false,
"name": "FormulaPending"
},
{
"depth": 1,
"segments": [
"practice"
],
"directCardCount": 0,
"ancestors": [],
"children": [
{
"depth": 2,
"segments": [
"practice",
"question"
],
"directCardCount": 9,
"ancestors": [
"#practice"
],
"hashtag": "#practice/question",
"cardCount": 9,
"path": "practice/question",
"derived": false,
"name": "question"
}
],
"hashtag": "#practice",
"cardCount": 9,
"path": "practice",
"derived": true,
"name": "practice"
}
],
"nodes": [
{
"depth": 1,
"segments": [
"FormulaPending"
],
"directCardCount": 1,
"ancestors": [],
"hashtag": "#FormulaPending",
"cardCount": 1,
"path": "FormulaPending",
"derived": false,
"name": "FormulaPending"
},
{
"depth": 1,
"segments": [
"practice"
],
"directCardCount": 0,
"ancestors": [],
"hashtag": "#practice",
"cardCount": 9,
"path": "practice",
"derived": true,
"name": "practice"
},
{
"depth": 2,
"segments": [
"practice",
"question"
],
"directCardCount": 9,
"ancestors": [
"#practice"
],
"hashtag": "#practice/question",
"cardCount": 9,
"path": "practice/question",
"derived": false,
"name": "question"
}
],
"studySetId": "77012CA0-48E8-4D29-B5F5-1EEA927AE086",
"taggedCardCount": 9
}路径参数
学习集的 topicid。取自 GET /ui-state 的 state.topicid、GET /library/study-sets,或 GET /writing/context 响应里的 window.topicid。
查询参数
带 withNotes=1 时,一并返回每个标签下直接存有该条完整路径的卡片 id。
可用选项:
1 响应
200 - application/json
标签树。卡片 id 只在扁平的 nodes 上。
整个学习集的标签。nodes 是扁平的,tree 是嵌套的;卡片 id 只出现在扁平的 nodes 上。