fix online status && license revoke
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user