fix: 修复 getNode 双重请求导致观看数计数不准确

dnfs.js 中 8 处导航调用 getNode() 两次(一次 load_notes 一次 loadMap),
每次独立发起 HTTP 请求,导致后端 _bump_views 重复计数。
改为单次 getNode + 组合回调(.then(r => { load_notes(r); loadMap(r) })),
确保每次导航仅一次请求,views 严格 1:1 对应。
This commit is contained in:
qing committed 2026-08-11 10:18:52 +00:00
1 parent c699ff1794
commit d5047d27c7
1 file changed
+8 -16
+8 -16
View File
@@ -108,8 +108,7 @@ async function addNode(pid, title, content) {
input_note_title.value = ""; input_note_title.value = "";
input_note_content.value = ""; input_note_content.value = "";
cancelEdit(); /* 退出编辑模式并重置高度 */ cancelEdit(); /* 退出编辑模式并重置高度 */
getNode(stack[stack.length - 1]).then(load_notes); getNode(stack[stack.length - 1]).then(function(r) { load_notes(r); loadMap(r); })
getNode(stack[stack.length - 1]).then(loadMap)
//if (result.success) { //if (result.success) {
alert(`添加节点成功`, result); alert(`添加节点成功`, result);
@@ -167,8 +166,7 @@ async function deleteNode(id) {
} }
stack.pop(); stack.pop();
getNode(stack[stack.length - 1]).then(load_notes); getNode(stack[stack.length - 1]).then(function(r) { load_notes(r); loadMap(r); })
getNode(stack[stack.length - 1]).then(loadMap)
console.log(`删除节点成功`); console.log(`删除节点成功`);
return result return result
@@ -225,8 +223,7 @@ async function deleteChild(id) {
input_note_content.value = ""; input_note_content.value = "";
} }
var cur = (stack.length == 0) ? 0 : stack[stack.length - 1]; var cur = (stack.length == 0) ? 0 : stack[stack.length - 1];
getNode(cur).then(load_notes); getNode(cur).then(function(r) { load_notes(r); loadMap(r); });
getNode(cur).then(loadMap);
console.log(`删除节点成功`); console.log(`删除节点成功`);
return result; return result;
@@ -281,8 +278,7 @@ async function updateNode(id, pid, title, content) {
input_note_content.value = ""; input_note_content.value = "";
cancelEdit(); cancelEdit();
var cur = (stack.length == 0) ? 0 : stack[stack.length - 1]; var cur = (stack.length == 0) ? 0 : stack[stack.length - 1];
getNode(cur).then(load_notes); getNode(cur).then(function(r) { load_notes(r); loadMap(r); });
getNode(cur).then(loadMap);
alert('修改成功'); alert('修改成功');
return result; return result;
@@ -334,8 +330,7 @@ async function moveNode(id, pid, title, content) {
} }
var cur = (stack.length == 0) ? 0 : stack[stack.length - 1]; var cur = (stack.length == 0) ? 0 : stack[stack.length - 1];
getNode(cur).then(load_notes); getNode(cur).then(function(r) { load_notes(r); loadMap(r); });
getNode(cur).then(loadMap);
alert('移动成功'); alert('移动成功');
return result; return result;
@@ -994,8 +989,7 @@ function renderCards(list) {
if (!confirmLeaveIfDirty()) return; /* 未放弃输入则不跳转,stack 保持原样 */ if (!confirmLeaveIfDirty()) return; /* 未放弃输入则不跳转,stack 保持原样 */
var id = Number(item.id) var id = Number(item.id)
stack.push(id) stack.push(id)
getNode(id).then(load_notes) getNode(id).then(function(r) { load_notes(r); loadMap(r); })
getNode(id).then(loadMap)
}); });
ttl.appendChild(ttl1); ttl.appendChild(ttl1);
card.appendChild(ttl); card.appendChild(ttl);
@@ -1152,8 +1146,7 @@ function loadMap(children_json) {
stack.pop(); stack.pop();
/* 栈空(回到根)时取 0:原判断 stack.length >= 0 恒真,空栈取 stack[-1] 得 undefined */ /* 栈空(回到根)时取 0:原判断 stack.length >= 0 恒真,空栈取 stack[-1] 得 undefined */
var id = (stack.length > 0) ? stack[stack.length - 1] : 0; var id = (stack.length > 0) ? stack[stack.length - 1] : 0;
getNode(id).then(load_notes); getNode(id).then(function(r) { load_notes(r); loadMap(r); });
getNode(id).then(loadMap);
}); });
minimap.appendChild(back); minimap.appendChild(back);
} }
@@ -1271,8 +1264,7 @@ function renderUserPanel() {
userpanel.appendChild(logout_tag); userpanel.appendChild(logout_tag);
} }
getNode(0).then(load_notes); getNode(0).then(function(r) { load_notes(r); loadMap(r); })
getNode(0).then(loadMap)
loadUserPanel(); loadUserPanel();
/* ===== 搜索框事件绑定:实时过滤当前层卡片;ESC 清空;回车不提交 ===== */ /* ===== 搜索框事件绑定:实时过滤当前层卡片;ESC 清空;回车不提交 ===== */