feat(admin): 批量上传改为手动点击开始

This commit is contained in:
Zhou Weidong authored and trae-solo-agent committed 2026-10-22 09:31:35 +08:00
1 parent 2e89f8460c
commit f174ba46ae
5 files changed
+135 -32

No files matched your search

@@ -1,5 +1,5 @@
<!-- Author: fruit.com.cn -->
<!-- 剧集批量上传弹窗:多选、队列、总进度、续传与批量建集入口 -->
<!-- 剧集批量上传弹窗:先入队待上传,点「开始上传」后再执行 -->
<script setup lang="ts">
import { computed, onBeforeUnmount, ref, watch } from 'vue'
@@ -60,6 +60,10 @@ watch(
const canCreateEpisodes = computed(() => queue.doneItems.value.length > 0)
const startButtonLabel = computed(() =>
queue.isUploading.value ? t('episodeBatch.uploadingAction') : t('episodeBatch.startUpload')
)
function extensionOf(fileName: string): string {
const parts = String(fileName || '').split('.')
return (parts.pop() || '').toLowerCase()
@@ -92,14 +96,19 @@ function onPickFiles(event: Event): void {
}
rejectedNames.value = rejected
if (!accepted.length) return
// 只入队,不发起上传;等用户点「开始上传」
queue.enqueue(accepted)
queue.start()
}
function openFilePicker(): void {
fileInputRef.value?.click()
}
function onStartUpload(): void {
if (!queue.canStart.value) return
queue.start()
}
function onBeforeUnload(event: BeforeUnloadEvent): void {
if (!queue.hasActiveUpload.value) return
event.preventDefault()
@@ -158,7 +167,6 @@ async function onResumeFiles(event: Event): Promise<void> {
}
if (matched.length) {
ElMessage.success(t('episodeBatch.resumeMatched', { count: matched.length }))
queue.start()
}
}
@@ -229,10 +237,13 @@ function onEpisodesCreated(): void {
<AppIcon :icon="AppIcons.upload" />
{{ t('episodeBatch.selectFiles') }}
</el-button>
<el-button :disabled="!queue.items.value.length" @click="queue.pause()">
<el-button
:disabled="!queue.started.value || !queue.items.value.length"
@click="queue.pause()"
>
{{ t('episodeBatch.pause') }}
</el-button>
<el-button :disabled="!queue.items.value.length" @click="queue.start()">
<el-button :disabled="!queue.canStart.value" @click="queue.start()">
{{ t('episodeBatch.resume') }}
</el-button>
<el-button
@@ -254,11 +265,22 @@ function onEpisodesCreated(): void {
<el-progress :percentage="queue.overallPercent.value" :stroke-width="12" />
</div>
<p v-if="queue.showResultSummary.value" class="batch-upload-summary">
{{
t('episodeBatch.resultSummary', {
done: queue.doneItems.value.length,
failed: queue.failedCount.value
})
}}
</p>
<div class="batch-upload-list">
<UploadTaskRow
v-for="item in queue.items.value"
v-for="(item, index) in queue.items.value"
:key="item.id"
:item="item"
:index="index + 1"
:allow-remove="!queue.started.value && item.status === 'waiting'"
@retry="queue.retry"
@remove="queue.remove"
/>
@@ -267,7 +289,15 @@ function onEpisodesCreated(): void {
<template #footer>
<el-button @click="visible = false">{{ t('common.cancel') }}</el-button>
<el-button type="primary" :disabled="!canCreateEpisodes" @click="openCreateDialog">
<el-button
type="primary"
:disabled="!queue.canStart.value"
:loading="queue.isUploading.value"
@click="onStartUpload"
>
{{ startButtonLabel }}
</el-button>
<el-button type="success" :disabled="!canCreateEpisodes" @click="openCreateDialog">
{{ t('episodeBatch.createEpisodes') }}
</el-button>
</template>
@@ -317,6 +347,15 @@ function onEpisodesCreated(): void {
margin-bottom: 12px;
}
.batch-upload-summary {
margin: 0 0 12px;
padding: 8px 12px;
border-radius: 6px;
background: color-mix(in srgb, var(--el-color-success) 10%, transparent);
color: var(--el-text-color-primary);
font-size: 13px;
}
.batch-upload-list {
max-height: 360px;
overflow: auto;