From 68ec85c6c70e3949b8772b4fbe8f09db6d88a304 Mon Sep 17 00:00:00 2001 From: shufeng2012 <277665039@qq.com> Date: Thu, 23 Jul 2026 19:59:46 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=8A=82=E7=82=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/public/js/dnfs.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/static/public/js/dnfs.js b/static/public/js/dnfs.js index 9e466e9..6563f07 100644 --- a/static/public/js/dnfs.js +++ b/static/public/js/dnfs.js @@ -106,9 +106,37 @@ async function deleteNode(token, id) { obj = {"id": String(id)}; jsonBody = JSON.stringify(obj); console.log(jsonBody); - const res = fetch('/delete_notes', { - + + const res = await fetch('/delete_note', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}`, + 'Target-Url': 'http://127.0.0.1:8006' + }, + body: jsonBody }); + + const responseText = await res.text(); + let result; + + try { + result = JSON.parse(responseText); + } catch { + console.error(`删除笔记接口返回非 JSON 内容(HTTP ${res.status}):`, responseText); + throw new Error('服务器响应格式异常,请稍后重试'); + } + + if (!res.ok) { + throw new Error(result.message || `删除节点失败(HTTP ${res.status})`); + } + + stack.pop(); + getNode(token, stack[stack.length - 1]).then(load_notes); + + console.log(`删除节点成功`); + return result + } catch (err) { alert(err.message || '接口请求失败,请检查后端服务是否启动'); console.error('删除节点请求异常:', err);