fix: 修复前端界面边界条件问题

- rowKey 使用 ?? 替代 ||,避免合法值 0 被当作 falsy
- parseJson 增加非字符串类型防御检查
- toTree 增加递归深度限制防止循环引用栈溢出
- saveBatchNodes 增加空名称数组检查
- localStorage.setItem 捕获 QuotaExceededError
- 路径参数缺失时显式抛出错误而非静默替换
This commit is contained in:
2026-07-30 17:08:03 +08:00
parent b1146787ab
commit 589ecd06f0
5 changed files with 25 additions and 14 deletions

View File

@@ -64,7 +64,11 @@ export async function apiRequest<T = unknown>(
signal?: AbortSignal,
): Promise<T> {
const pathValues = (input.path || {}) as Record<string, unknown>;
let route = operation.path.replace(/\{([^}]+)\}/g, (_, name: string) => encodeURIComponent(String(pathValues[name] ?? '')));
let route = operation.path.replace(/\{([^}]+)\}/g, (_, name: string) => {
const value = pathValues[name];
if (value === undefined || value === null) throw new Error(`缺少必填路径参数:${name}`);
return encodeURIComponent(String(value));
});
const url = new URL(route, window.location.origin);
appendQuery(url, ((input.query || {}) as Record<string, unknown>));
route = `${url.pathname}${url.search}`;