From c7364286b77e282d2e3ed524023cdc12b701c724 Mon Sep 17 00:00:00 2001 From: qing <1776177662@qq.com> Date: Sun, 2 Aug 2026 12:19:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(static):=20getNode=E4=BB=85401=E8=B7=B3?= =?UTF-8?q?=E7=99=BB=E5=BD=95=EF=BC=8C=E5=85=B6=E4=BB=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8E=9F=E5=9B=A0=E5=B9=B6=E4=B8=8A=E6=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/public/js/dnfs.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/static/public/js/dnfs.js b/static/public/js/dnfs.js index f7e4280..099e644 100644 --- a/static/public/js/dnfs.js +++ b/static/public/js/dnfs.js @@ -6,8 +6,8 @@ */ async function getNode(id) { try { - obj = { "pid": id } - jsonBody = JSON.stringify(obj) + const obj = { "pid": id } + const jsonBody = JSON.stringify(obj) console.log(jsonBody) const res = await fetch('/get_notes', { method: 'POST', @@ -19,7 +19,7 @@ async function getNode(id) { }); const responseText = await res.text(); - // WAF 拦截:弹提示并中止,不能落入 catch(其会误跳登录页) + // WAF 拦截:弹提示并中止,不能落入 catch(其会向上抛出) if (window.WafTip && WafTip.isBlocked(res, responseText)) { alert(WafTip.MESSAGE); return; @@ -34,7 +34,7 @@ async function getNode(id) { } if (res.status === 401) { - // 凭证失效(过期或网关重启),跳转重新登录 + // 凭证失效(过期或网关重启),仅此一种情况跳转重新登录 location.href = '/login.html'; return; } @@ -53,10 +53,12 @@ async function getNode(id) { //} } catch (err) { - // 获取节点失败(非 JSON 响应 / HTTP 错误 / 网络异常),统一跳转登录页 + // 非 401 失败(网络异常 / 5xx / 非 JSON 响应):提示真实原因并向上抛出, + // 调用方 .then(load_notes/loadMap) 不再执行,当前页面内容保持不变; + // 不再把任意错误误判为凭证失效而跳登录页 console.error('获取节点请求异常:', err); - location.href = '/login.html'; - } finally { + alert(err.message || '获取节点失败,请检查网络后重试'); + throw err; } }