fix: 任务卡片去掉重复的进度数字
This commit is contained in:
@@ -95,9 +95,20 @@ function noteText(job: DownloadJob) {
|
||||
text = "保存编号进度时文件被拒绝访问,已下载的内容还在,点继续即可";
|
||||
}
|
||||
if (!text || text === statusLabel(job)) return "";
|
||||
if (text === "正在读取并下载" || text === "准备中") return "";
|
||||
if (/^已完成 \d+(,已读取 \d+)?(,失败 \d+)?$/.test(text)) return "";
|
||||
if (/^已完成 \d+\/\d+,失败 \d+$/.test(text)) return "";
|
||||
return text;
|
||||
}
|
||||
|
||||
function cardFacts(job: DownloadJob) {
|
||||
if (waitingToRead(job)) return [job.id, "等待读取编号", `已写入 ${job.writtenRows} 行`];
|
||||
const progress = scanning(job)
|
||||
? [`已下载 ${job.completed}`, `已读取 ${job.discovered || 0} 个栅格`]
|
||||
: [`${job.completed}/${job.total} 个栅格`];
|
||||
return [job.id, ...progress, `已写入 ${job.writtenRows} 行`];
|
||||
}
|
||||
|
||||
function waitingToRead(job: DownloadJob) {
|
||||
return Boolean(job.wholeCity) && job.status === "queued";
|
||||
}
|
||||
@@ -183,15 +194,6 @@ async function changeConcurrency(job: DownloadJob, value: number | null) {
|
||||
}
|
||||
}
|
||||
|
||||
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} 个栅格`;
|
||||
return `${job.id} · ${progress} · ${written}`;
|
||||
}
|
||||
|
||||
async function saveLimit(value: number | null) {
|
||||
if (!value) return;
|
||||
try {
|
||||
@@ -481,7 +483,9 @@ async function removeJob(job: DownloadJob, files: boolean) {
|
||||
</span>
|
||||
<div>
|
||||
<h3>{{ job.name }}</h3>
|
||||
<div class="sub">{{ countText(job) }}</div>
|
||||
<div class="task-meta">
|
||||
<span v-for="fact in cardFacts(job)" :key="fact">{{ fact }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="task-actions" @click.stop>
|
||||
@@ -519,9 +523,9 @@ async function removeJob(job: DownloadJob, files: boolean) {
|
||||
<n-tag size="small" :type="job.status === 'running' ? 'info' : job.status === 'done' ? 'success' : job.status === 'paused' ? 'warning' : 'default'">
|
||||
{{ statusLabel(job) }}
|
||||
</n-tag>
|
||||
<span v-if="noteText(job)" class="sub">{{ noteText(job) }}</span>
|
||||
<span v-if="noteText(job)" class="task-notice">{{ noteText(job) }}</span>
|
||||
</span>
|
||||
<span class="sub">失败 {{ job.failed }} · {{ formatSize(job.fileBytes) }}</span>
|
||||
<span class="task-size">失败 {{ job.failed }} · {{ formatSize(job.fileBytes) }}</span>
|
||||
</div>
|
||||
<ul v-if="job.failures?.length" class="fail-list">
|
||||
<li v-for="item in job.failures.slice(0, 3)" :key="item.id">{{ item.id }}:{{ item.message }}</li>
|
||||
|
||||
Reference in New Issue
Block a user