弱网核销功能

This commit is contained in:
2026-07-12 12:00:55 +08:00
parent de01d36cdb
commit 06b1cb22e0
24 changed files with 1434 additions and 42 deletions
+11 -2
View File
@@ -124,10 +124,19 @@ async function rawRequest<T>(
if (authToken) headers.Authorization = `Bearer ${authToken}`;
const res = await fetch(`${apiBase}${path}`, { ...options, headers });
const json = await res.json();
let json: { code: number; message?: string; data?: T };
try {
json = await res.json();
} catch {
const err = new Error(res.ok ? '接口返回异常' : `网络异常(HTTP ${res.status}`) as Error & {
status?: number;
};
err.status = res.status;
throw err;
}
if (json.code !== 0) {
const err = new Error(json.message || '请求失败') as Error & { status?: number };
err.status = json.code;
err.status = res.status >= 500 ? res.status : json.code;
throw err;
}
return json.data as T;