From d5047d27c73b26679e67e640267d482ffaadd0d9 Mon Sep 17 00:00:00 2001 From: qing <1776177662@qq.com> Date: Tue, 11 Aug 2026 10:18:52 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20getNode=20=E5=8F=8C?= =?UTF-8?q?=E9=87=8D=E8=AF=B7=E6=B1=82=E5=AF=BC=E8=87=B4=E8=A7=82=E7=9C=8B?= =?UTF-8?q?=E6=95=B0=E8=AE=A1=E6=95=B0=E4=B8=8D=E5=87=86=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dnfs.js 中 8 处导航调用 getNode() 两次(一次 load_notes 一次 loadMap), 每次独立发起 HTTP 请求,导致后端 _bump_views 重复计数。 改为单次 getNode + 组合回调(.then(r => { load_notes(r); loadMap(r) })), 确保每次导航仅一次请求,views 严格 1:1 对应。 --- fsys/public/js/dnfs.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/fsys/public/js/dnfs.js b/fsys/public/js/dnfs.js index 49e4bf6..8d2330b 100644 --- a/fsys/public/js/dnfs.js +++ b/fsys/public/js/dnfs.js @@ -108,8 +108,7 @@ async function addNode(pid, title, content) { input_note_title.value = ""; input_note_content.value = ""; cancelEdit(); /* 退出编辑模式并重置高度 */ - getNode(stack[stack.length - 1]).then(load_notes); - getNode(stack[stack.length - 1]).then(loadMap) + getNode(stack[stack.length - 1]).then(function(r) { load_notes(r); loadMap(r); }) //if (result.success) { alert(`添加节点成功`, result); @@ -167,8 +166,7 @@ async function deleteNode(id) { } stack.pop(); - getNode(stack[stack.length - 1]).then(load_notes); - getNode(stack[stack.length - 1]).then(loadMap) + getNode(stack[stack.length - 1]).then(function(r) { load_notes(r); loadMap(r); }) console.log(`删除节点成功`); return result @@ -225,8 +223,7 @@ async function deleteChild(id) { input_note_content.value = ""; } var cur = (stack.length == 0) ? 0 : stack[stack.length - 1]; - getNode(cur).then(load_notes); - getNode(cur).then(loadMap); + getNode(cur).then(function(r) { load_notes(r); loadMap(r); }); console.log(`删除节点成功`); return result; @@ -281,8 +278,7 @@ async function updateNode(id, pid, title, content) { input_note_content.value = ""; cancelEdit(); var cur = (stack.length == 0) ? 0 : stack[stack.length - 1]; - getNode(cur).then(load_notes); - getNode(cur).then(loadMap); + getNode(cur).then(function(r) { load_notes(r); loadMap(r); }); alert('修改成功'); return result; @@ -334,8 +330,7 @@ async function moveNode(id, pid, title, content) { } var cur = (stack.length == 0) ? 0 : stack[stack.length - 1]; - getNode(cur).then(load_notes); - getNode(cur).then(loadMap); + getNode(cur).then(function(r) { load_notes(r); loadMap(r); }); alert('移动成功'); return result; @@ -994,8 +989,7 @@ function renderCards(list) { if (!confirmLeaveIfDirty()) return; /* 未放弃输入则不跳转,stack 保持原样 */ var id = Number(item.id) stack.push(id) - getNode(id).then(load_notes) - getNode(id).then(loadMap) + getNode(id).then(function(r) { load_notes(r); loadMap(r); }) }); ttl.appendChild(ttl1); card.appendChild(ttl); @@ -1152,8 +1146,7 @@ function loadMap(children_json) { stack.pop(); /* 栈空(回到根)时取 0:原判断 stack.length >= 0 恒真,空栈取 stack[-1] 得 undefined */ var id = (stack.length > 0) ? stack[stack.length - 1] : 0; - getNode(id).then(load_notes); - getNode(id).then(loadMap); + getNode(id).then(function(r) { load_notes(r); loadMap(r); }); }); minimap.appendChild(back); } @@ -1271,8 +1264,7 @@ function renderUserPanel() { userpanel.appendChild(logout_tag); } -getNode(0).then(load_notes); -getNode(0).then(loadMap) +getNode(0).then(function(r) { load_notes(r); loadMap(r); }) loadUserPanel(); /* ===== 搜索框事件绑定:实时过滤当前层卡片;ESC 清空;回车不提交 ===== */