feat: 合成 MP4 时带上独立音频并支持按剧重新下载
This commit is contained in:
@@ -20,6 +20,9 @@ const props = defineProps<{
|
||||
|
||||
const tab = ref<"active" | "done">("active");
|
||||
const holding = ref(false);
|
||||
const remuxing = ref(false);
|
||||
const remuxingId = ref("");
|
||||
const remuxNote = ref("");
|
||||
|
||||
const resumeAll = computed(
|
||||
() => props.active.length > 0 && props.active.every((job) => job.status === "paused" || job.status === "failed"),
|
||||
@@ -45,6 +48,62 @@ async function act(id: string, action: string) {
|
||||
await fetch(`/api/downloads/${id}/${action}`, { method: "POST" });
|
||||
}
|
||||
|
||||
async function remuxSaved() {
|
||||
if (remuxing.value || remuxingId.value) return;
|
||||
remuxing.value = true;
|
||||
remuxNote.value = "";
|
||||
try {
|
||||
const response = await fetch("/api/downloads/remux", { method: "POST" });
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
remuxNote.value = data.detail || "重新合成失败";
|
||||
return;
|
||||
}
|
||||
const errors = Array.isArray(data.errors) ? data.errors.slice(0, 8) : [];
|
||||
remuxNote.value = [data.message || "重新合成完成", ...errors].filter(Boolean).join("\n");
|
||||
} catch {
|
||||
remuxNote.value = "重新合成失败";
|
||||
} finally {
|
||||
remuxing.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function remuxOne(id: string) {
|
||||
if (remuxing.value || remuxingId.value) return;
|
||||
remuxingId.value = id;
|
||||
remuxNote.value = "";
|
||||
try {
|
||||
const response = await fetch(`/api/downloads/${id}/remux`, { method: "POST" });
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
remuxNote.value = data.detail || "重新合成失败";
|
||||
return;
|
||||
}
|
||||
const errors = Array.isArray(data.errors) ? data.errors.slice(0, 8) : [];
|
||||
remuxNote.value = [data.message || "重新合成完成", ...errors].filter(Boolean).join("\n");
|
||||
} catch {
|
||||
remuxNote.value = "重新合成失败";
|
||||
} finally {
|
||||
remuxingId.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
async function redownload(id: string) {
|
||||
if (remuxing.value || remuxingId.value) return;
|
||||
remuxNote.value = "";
|
||||
try {
|
||||
const response = await fetch(`/api/downloads/${id}/redownload`, { method: "POST" });
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
remuxNote.value = data.detail || "重新下载失败";
|
||||
return;
|
||||
}
|
||||
tab.value = "active";
|
||||
} catch {
|
||||
remuxNote.value = "重新下载失败";
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(id: string) {
|
||||
await fetch(`/api/downloads/${id}`, { method: "DELETE" });
|
||||
}
|
||||
@@ -54,6 +113,7 @@ async function remove(id: string) {
|
||||
<div class="progress-page">
|
||||
<n-tabs v-model:value="tab" type="line" size="small">
|
||||
<template #suffix>
|
||||
<n-button class="remux-button" size="small" secondary :loading="remuxing" :disabled="!!remuxingId" @click="remuxSaved">全部重新合成</n-button>
|
||||
<n-button
|
||||
v-if="tab === 'active'"
|
||||
class="bulk-hold"
|
||||
@@ -132,6 +192,14 @@ async function remove(id: string) {
|
||||
<n-text depth="3">{{ job.completed_at }}</n-text>
|
||||
</div>
|
||||
<div class="job-actions">
|
||||
<n-button size="tiny" secondary :disabled="remuxing || remuxingId === job.id" @click="redownload(job.id)">重新下载</n-button>
|
||||
<n-button
|
||||
size="tiny"
|
||||
secondary
|
||||
:loading="remuxingId === job.id"
|
||||
:disabled="remuxing"
|
||||
@click="remuxOne(job.id)"
|
||||
>重新合成</n-button>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button quaternary circle aria-label="打开目录" @click="act(job.id, 'open')">
|
||||
@@ -153,6 +221,7 @@ async function remove(id: string) {
|
||||
</div>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
<div v-if="remuxNote" class="remux-note">{{ remuxNote }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -179,6 +248,17 @@ async function remove(id: string) {
|
||||
}
|
||||
.job-scroll { flex: 1; min-height: 0; overflow: auto; }
|
||||
.bulk-hold { margin-left: 12px; }
|
||||
.remux-button { margin-right: 8px; }
|
||||
.remux-note {
|
||||
flex: none;
|
||||
max-height: 120px;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: rgba(255, 255, 255, 0.72);
|
||||
padding: 8px 0 0;
|
||||
}
|
||||
.progress-empty { padding: 28px 0; color: rgba(255, 255, 255, 0.45); }
|
||||
.job {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user