fix online status && license revoke

This commit is contained in:
rangang
2026-07-30 13:55:54 +08:00
parent e12134e40d
commit 66b7b73e75
7 changed files with 58 additions and 190 deletions
+15 -3
View File
@@ -20,9 +20,21 @@ async function callServer(payload, options = {}) {
headers: { "content-type": "application/json" },
body: JSON.stringify({ ...payload, adminToken })
});
if (!response.ok) throw new Error(`server 请求失败: HTTP ${response.status}`);
const result = await response.json();
let result = null;
try {
result = await response.json();
} catch {
result = null;
}
if (!response.ok) {
const message = result && typeof result.errMsg === "string" && result.errMsg
? result.errMsg
: `server 请求失败: HTTP ${response.status}`;
throw new Error(message);
}
if (!result || typeof result !== "object") {
throw new Error("server 返回格式无效");
}
if (!result.success) throw new Error(result.errMsg || "server 返回失败");
return result;
}