Add batch default flow and downloads

This commit is contained in:
admin
2026-06-10 17:50:42 +08:00
parent 6db15ebc3f
commit ec5b25d2d0
8 changed files with 187 additions and 6 deletions

View File

@@ -49,6 +49,7 @@ function renderMethods() {
box.innerHTML = "";
const methods = state.capabilities?.methods || {};
Object.entries(methods).forEach(([key, info]) => {
const checked = key === "Baidu_API" || key === "DCP";
const label = document.createElement("label");
label.className = `check-item ${info.available ? "" : "disabled"}`;
label.innerHTML = `
@@ -56,7 +57,7 @@ function renderMethods() {
<strong>${info.label}</strong>
<span class="method-meta">${info.available ? "ready" : `${info.module_ok ? "模型" : info.module}`}</span>
</span>
<input type="checkbox" value="${key}" ${info.available || key === "Baidu_API" || key === "DCP" ? "" : "disabled"} ${key === "DCP" ? "checked" : ""} />
<input type="checkbox" value="${key}" ${info.available || checked ? "" : "disabled"} ${checked ? "checked" : ""} />
`;
box.appendChild(label);
});
@@ -71,7 +72,7 @@ function renderPostprocessors() {
label.className = "check-item";
label.innerHTML = `
<span><strong>${info.label}</strong></span>
<input type="checkbox" value="${key}" ${key === "manual_sv" ? "checked" : ""} />
<input type="checkbox" value="${key}" ${key === "auto_sv" ? "checked" : ""} />
`;
box.appendChild(label);
});
@@ -130,6 +131,8 @@ function updatePostSourceOptions(results) {
});
if ([...select.options].some((option) => option.value === previous)) {
select.value = previous;
} else if (results.dehaze.some((item) => item.method === "Baidu_API" && item.exists)) {
select.value = "Baidu_API";
} else if (results.dehaze.some((item) => item.method === "DCP" && item.exists)) {
select.value = "DCP";
}
@@ -217,6 +220,10 @@ async function runSelectedModels() {
await startJob("/api/run", payload);
}
async function runDefaultBatch() {
await startJob("/api/run-default", { skip_existing: true });
}
async function runPostprocess() {
if (!state.selectedImage) return;
const processors = selectedValues("postList");
@@ -230,9 +237,21 @@ async function runPostprocess() {
await startJob("/api/postprocess", payload);
}
function downloadCurrent() {
if (!state.selectedImage) return;
window.location.href = `/api/download?scope=current&image=${encodeURIComponent(state.selectedImage)}`;
}
function downloadAll() {
window.location.href = "/api/download?scope=all";
}
function bindControls() {
$("runBtn").addEventListener("click", runSelectedModels);
$("runDefaultBatchBtn").addEventListener("click", runDefaultBatch);
$("postBtn").addEventListener("click", runPostprocess);
$("downloadCurrentBtn").addEventListener("click", downloadCurrent);
$("downloadAllBtn").addEventListener("click", downloadAll);
$("refreshBtn").addEventListener("click", refreshResults);
$("sGain").addEventListener("input", () => {
$("sGainValue").textContent = `${Math.round(Number($("sGain").value) * 100)}%`;