From a67d092805b01cf4faea9eb30fac07978e0f7ab2 Mon Sep 17 00:00:00 2001 From: developer Date: Sun, 12 Jul 2026 13:44:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=9E=E5=BF=86=E5=AF=BC=E5=9B=BE?= =?UTF-8?q?=E6=A0=B9=E8=8A=82=E7=82=B9=E8=87=AA=E5=8A=A8=E8=81=9A=E7=84=A6?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - loadData 中根据 focusPath 自动查找标准导图节点设为根 - 新增 findNodeByPath 辅助函数支持路径定位 - 有 focusPath 时节点始终可点选 --- src/components/ReviewRecall.vue | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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"