refactor: split large modules and harden live-room fudai flow

This commit is contained in:
Your Name committed 2026-06-01 18:39:44 +08:00
1 parent 1845561405
commit 36e374ef67
86 files changed
+7422 -8404

No files matched your search

+17 -2
View File
@@ -75,10 +75,25 @@ async function apiPost(path, body) {
},
body: JSON.stringify(body || {}),
});
const data = await res.json();
let data = null;
const ct = (res.headers.get("content-type") || "").toLowerCase();
if (ct.includes("application/json")) {
try {
data = await res.json();
} catch (e) {
data = null;
}
} else {
try {
const text = await res.text();
data = text ? { error: text } : {};
} catch (e) {
data = {};
}
}
if (!res.ok) {
notifyApiFail();
const errorMsg = data.error || data.message || res.statusText;
const errorMsg = (data && (data.error || data.message)) || res.statusText;
const error = new Error(errorMsg);
error.status = res.status;
error.data = data;