diff --git a/src/components/ReviewRecall.vue b/src/components/ReviewRecall.vue index 9e6f3c0..33cb8a1 100644 --- a/src/components/ReviewRecall.vue +++ b/src/components/ReviewRecall.vue @@ -121,9 +121,30 @@ const loadData = async () => { if (!recallTree.value) { recallTree.value = buildEmptyRecallTree(); } + // 若从 URL 带了 focusPath,自动设置回忆导图根节点 + if (focusPath.value && standard.value?.content) { + try { + const tree = JSON.parse(standard.value.content) as MindMapTreeNode; + const match = findNodeByPath(tree, focusPath.value); + if (match) { + recallTree.value = { title: match.title, children: [] }; + } + } catch { /* ignore */ } + } } }; +const findNodeByPath = (node: MindMapTreeNode, path: string): MindMapTreeNode | null => { + const parts = path.split(" / "); + let current: MindMapTreeNode | null = node; + for (let i = 0; i < parts.length && current; i++) { + if (current.title === parts[i] && i === parts.length - 1) return current; + const child = (current.children || []).find((c) => c.title === parts[i]); + current = child || null; + } + return null; +}; + // 重新生成(防抖 + 用户编辑时弹窗选模式) const handleRegenerate = async () => { // 防抖:正在生成中跳过 @@ -521,7 +542,7 @@ onMounted(() => { v-if="standardTree" :tree="compareTree || standardTree" :color-by-compare="!!compareTree" - :selectable="!editingStandard && !focusPath && !hasCompared" + :selectable="!editingStandard && !hasCompared" height="60vh" @node-select="handleNodeSelect" @node-click="goToNodeSource"