Compare commits

...
2 Commits
Author SHA1 Message Date
qing d5047d27c7 fix: 修复 getNode 双重请求导致观看数计数不准确
dnfs.js 中 8 处导航调用 getNode() 两次(一次 load_notes 一次 loadMap),
每次独立发起 HTTP 请求,导致后端 _bump_views 重复计数。
改为单次 getNode + 组合回调(.then(r => { load_notes(r); loadMap(r) })),
确保每次导航仅一次请求,views 严格 1:1 对应。
2026-08-11 10:18:52 +00:00
qing c699ff1794 update: 将 patch_001 并入 create_sqlite3.sql
新建库一步到位含 Notes views 观看人数列及 pid/owner 索引;
patch_001 保留用于存量库迁移。
2026-08-11 10:11:07 +00:00
2 changed files with 15 additions and 17 deletions

No files matched your search

+7 -1
View File
@@ -15,11 +15,17 @@ CREATE TABLE IF NOT EXISTS Notes (
pid INTEGER NOT NULL, pid INTEGER NOT NULL,
owner VARCHAR(128) DEFAULT 'Unknow', owner VARCHAR(128) DEFAULT 'Unknow',
title VARCHAR(128) NOT NULL, title VARCHAR(128) NOT NULL,
content TEXT NOT NULL content TEXT NOT NULL,
views INTEGER NOT NULL DEFAULT 0
); );
-- 旧版增量 -- 旧版增量
-- ALTER TABLE Notes ADD COLUMN owner VARCHAR(128) DEFAULT 'Unknow'; -- ALTER TABLE Notes ADD COLUMN owner VARCHAR(128) DEFAULT 'Unknow';
-- ALTER TABLE Notes ADD COLUMN views INTEGER NOT NULL DEFAULT 0; -- patch_001 观看人数列
-- Notes 索引:get_notes 按 pid 查子节点、所有权校验按 owner(patch_001 并入)
CREATE INDEX IF NOT EXISTS idx_notes_pid ON Notes(pid);
CREATE INDEX IF NOT EXISTS idx_notes_owner ON Notes(owner);
-- ── 日志表(db 内置日志模块)───────────────────────────────────────── -- ── 日志表(db 内置日志模块)─────────────────────────────────────────
+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 清空;回车不提交 ===== */