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)}%`;

View File

@@ -35,7 +35,10 @@
<input id="dcpTx" type="number" min="0.01" max="1" step="0.01" value="0.20" />
</label>
</div>
<button id="runBtn" class="primary-btn">运行选中模型</button>
<div class="button-stack">
<button id="runBtn" class="primary-btn">运行选中模型</button>
<button id="runDefaultBatchBtn" class="secondary-btn">批量默认流程</button>
</div>
</section>
<section class="panel-section">
@@ -65,6 +68,14 @@
</label>
<button id="postBtn" class="secondary-btn">生成后处理</button>
</section>
<section class="panel-section">
<h2>下载</h2>
<div class="button-stack">
<button id="downloadCurrentBtn" class="text-btn">下载当前图片</button>
<button id="downloadAllBtn" class="text-btn">批量下载全部</button>
</div>
</section>
</aside>
<section class="workspace">

View File

@@ -210,6 +210,19 @@ h1 {
color: var(--ink);
}
.button-stack {
display: grid;
gap: 8px;
margin-top: 12px;
}
.button-stack .primary-btn,
.button-stack .secondary-btn,
.button-stack .text-btn {
width: 100%;
margin-top: 0;
}
.slider-row {
display: grid;
grid-template-columns: 20px 1fr 52px;