修复中控自更新触发与错误提示;实例页改为表格,带鱼屏宽度锁 1800。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,14 +6,39 @@
|
||||
}
|
||||
|
||||
async function fetchJson(url, opts) {
|
||||
const r = await fetch(url, Object || {});
|
||||
let data = {};
|
||||
const base = opts || {};
|
||||
const headers = Object.assign({ Accept: "application/json" }, base.headers || {});
|
||||
try {
|
||||
data = await r.json();
|
||||
const r = await fetch(
|
||||
url,
|
||||
Object.assign({}, base, {
|
||||
credentials: "same-origin",
|
||||
headers: headers,
|
||||
})
|
||||
);
|
||||
const text = await r.text();
|
||||
let data = {};
|
||||
try {
|
||||
data = text ? JSON.parse(text) : {};
|
||||
} catch (e) {
|
||||
data = {
|
||||
ok: false,
|
||||
msg: "非 JSON 响应 HTTP " + r.status + (text ? ": " + String(text).slice(0, 120) : ""),
|
||||
};
|
||||
}
|
||||
if (!data || typeof data !== "object") data = {};
|
||||
if (data.ok == null && !r.ok) {
|
||||
data.ok = false;
|
||||
data.msg = data.msg || "请求失败 HTTP " + r.status;
|
||||
}
|
||||
return { httpOk: r.ok, status: r.status, data: data };
|
||||
} catch (e) {
|
||||
data = {};
|
||||
return {
|
||||
httpOk: false,
|
||||
status: 0,
|
||||
data: { ok: false, msg: (e && e.message) || "网络错误" },
|
||||
};
|
||||
}
|
||||
return { httpOk: r.ok, status: r.status, data: data };
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
@@ -71,7 +96,7 @@
|
||||
}
|
||||
setStatus(statusEl, "更新中… (" + (i + 1) + "/" + maxTries + ")", "pending");
|
||||
}
|
||||
setStatus(statusEl, "超时未确认上线,请稍后刷新版本或查服务器日志", "err");
|
||||
setStatus(statusEl, "超时未确认上线,请稍后刷新版本或查看 logs/hub_update.log", "err");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -115,7 +140,10 @@
|
||||
});
|
||||
const data = res.data || {};
|
||||
if (!data.ok) {
|
||||
setStatus(statusEl, data.msg || "更新失败", "err");
|
||||
const detail =
|
||||
data.msg ||
|
||||
(res.status ? "更新失败 HTTP " + res.status : "更新失败(无响应)");
|
||||
setStatus(statusEl, detail, "err");
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
@@ -178,7 +206,11 @@
|
||||
});
|
||||
const data = res.data || {};
|
||||
if (!data.ok) {
|
||||
setStatus(statusEl, data.msg || "更新失败", "err");
|
||||
setStatus(
|
||||
statusEl,
|
||||
data.msg || (res.status ? "更新失败 HTTP " + res.status : "更新失败"),
|
||||
"err"
|
||||
);
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user