fix: 修正任务等待文案、空状态和停止状态

This commit is contained in:
2026-10-25 07:37:09 +08:00
parent 19d9b32c2c
commit 555b9f06cb
2 changed files with 18 additions and 6 deletions
@@ -68,10 +68,20 @@ async function refresh() {
}
function statusLabel(job: DownloadJob) {
if (job.stopping) return "正在停止";
if (job.status === "cancelled" && (job.message === "已取消" || job.message === "已中断")) return job.message;
return statusText[job.status] || job.status;
}
function waitingToRead(job: DownloadJob) {
return Boolean(job.wholeCity) && job.status === "queued";
}
function formatCreatedAt(value?: string | null) {
if (!value) return "—";
return value.replace("T", " ");
}
function scanning(job: DownloadJob) {
return Boolean(job.wholeCity) && job.listingDone === false;
}
@@ -107,6 +117,7 @@ function closeDetail() {
function countText(job: DownloadJob) {
const written = `已写入 ${job.writtenRows} 行`;
if (waitingToRead(job)) return `${job.id} · 等待读取 · ${written}`;
const progress = scanning(job)
? `已完成 ${job.completed} · 已读取 ${job.discovered || 0} 个栅格`
: `${job.completed}/${job.total} 个栅格`;
@@ -205,7 +216,7 @@ async function removeJob(job: DownloadJob, files: boolean) {
{{ statusLabel(opened) }}
</n-tag>
<template v-if="opened.status === 'running'">
<n-button v-if="opened.message !== '正在停止'" size="small" @click="pause(opened)">
<n-button v-if="!opened.stopping" size="small" @click="pause(opened)">
<template #icon><n-icon><PauseOutline /></n-icon></template>
暂停
</n-button>
@@ -274,13 +285,14 @@ async function removeJob(job: DownloadJob, files: boolean) {
<div class="form-row"><label>并发</label><span>{{ opened.concurrency || 1 }}</span></div>
<div class="form-row">
<label>进度</label>
<span v-if="scanning(opened)">已完成 {{ opened.completed }},已读取 {{ opened.discovered || 0 }}</span>
<span v-if="waitingToRead(opened)">等待读取</span>
<span v-else-if="scanning(opened)">已完成 {{ opened.completed }},已读取 {{ opened.discovered || 0 }}</span>
<span v-else>{{ opened.completed }}/{{ opened.total }}</span>
</div>
<div class="form-row"><label>失败</label><span>{{ opened.failed }}</span></div>
<div class="form-row"><label>已写入</label><span>{{ opened.writtenRows }} 行</span></div>
<div class="form-row"><label>文件大小</label><span>{{ formatSize(opened.fileBytes) }}</span></div>
<div class="form-row"><label>开始时间</label><span>{{ opened.createdAt.replace("T", " ") }}</span></div>
<div class="form-row"><label>开始时间</label><span>{{ formatCreatedAt(opened.createdAt) }}</span></div>
<div v-if="opened.duplicateCount" class="form-row"><label>重复</label><span>已去掉 {{ opened.duplicateCount }} 个</span></div>
<div class="form-row form-top">
<label>保存位置</label>
@@ -317,7 +329,7 @@ async function removeJob(job: DownloadJob, files: boolean) {
{{ statusLabel(job) }}
</n-tag>
<template v-if="job.status === 'running'">
<n-button v-if="job.message !== '正在停止'" size="small" @click="pause(job)">
<n-button v-if="!job.stopping" size="small" @click="pause(job)">
<template #icon><n-icon><PauseOutline /></n-icon></template>
暂停
</n-button>
@@ -368,7 +380,7 @@ async function removeJob(job: DownloadJob, files: boolean) {
<li v-for="item in job.failures.slice(0, 3)" :key="item.id">{{ item.id }}:{{ item.message }}</li>
</ul>
</article>
<n-empty v-if="visible.length === 0" class="empty" :description="tab === 'active' ? '没有正在下载的任务' : '还没有完成的任务'" />
<n-empty v-if="visible.length === 0" class="empty" :description="tab === 'active' ? '没有未完成的任务' : '还没有完成的任务'" />
</div>
</section>
</template>
+1 -1
View File
@@ -35,7 +35,7 @@ export interface DownloadJob {
duplicateCount?: number;
csvPath: string;
failures: { id: string; message: string }[];
createdAt: string;
createdAt?: string | null;
stopping?: boolean;
}