fix(web): 修复 demo 任务详情页旁路提问历史缺失导致的整页崩溃
mock 模式下 GET /api/tasks/<id>/side-questions 无路由,被读兜底当集合返回 [],data.items 为 undefined,旁路 hook 的 merge() 迭代抛 TypeError: t is not iterable,异常在 setState updater 中经 render 重抛、catch 接不住,整页被错误 边界接管。mock handler 显式返回空旁路历史,sideAPI.history 同时归一化返回值。
This commit is contained in:
1 parent
90f31577f2
commit
f2589ad47c
3 files changed
+19
-1
No files matched your search
@@ -2092,6 +2092,13 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
};
|
||||
if (path === "/intercept/judge" && m === "PUT") return { ok: true };
|
||||
|
||||
// ── 旁路提问(/btw):demo 无旁路会话 ──
|
||||
// 必须显式命中:路径以 s 结尾会被下面的读兜底判成集合返回 [],items 就成了 undefined。
|
||||
if (seg.at(-1) === "side-questions") {
|
||||
if (m === "GET") return { items: [], current: null, next_cursor: 0, snapshot: null };
|
||||
if (m === "POST") throw new Error("演示模式不支持旁路提问");
|
||||
}
|
||||
|
||||
// ── 写操作兜底:成功但不落库 ──
|
||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(m)) return { ok: true };
|
||||
|
||||
|
||||
Reference in new issue
Block a user