add: 显示单次任务记录

This commit is contained in:
2026-06-20 12:10:32 +08:00
parent 161f266829
commit cd051900b5
9 changed files with 265 additions and 67 deletions
+4 -4
View File
@@ -31,7 +31,7 @@ export function isNoAuth() {
}
// POST JSON to an RC endpoint. Returns the parsed JSON response, or throws.
export async function post(path, body = {}) {
export async function post(path, body = {}, options = {}) {
const headers = { "Content-Type": "application/json" };
if (authHeader) headers["Authorization"] = authHeader;
const res = await fetch(RC_BASE + "/" + path.replace(/^\//, ""), {
@@ -39,7 +39,7 @@ export async function post(path, body = {}) {
headers,
body: JSON.stringify(body),
});
return parseResponse(res, path);
return parseResponse(res, path, options);
}
// POST JSON and request an async job. Returns { jobid, executeId }.
@@ -82,7 +82,7 @@ export function downloadURL(remoteFs, remotePath, fileName) {
return url;
}
async function parseResponse(res, path) {
async function parseResponse(res, path, { allowError = false } = {}) {
let body = null;
const ct = res.headers.get("Content-Type") || "";
if (ct.includes("application/json")) {
@@ -98,7 +98,7 @@ async function parseResponse(res, path) {
err.body = body;
throw err;
}
if (body && body.error) {
if (body && body.error && !allowError) {
throw new Error(`${path}: ${body.error}`);
}
return body;