Skip to content

Commit

Permalink
feat: 优化章节进度条的显示
Browse files Browse the repository at this point in the history
  • Loading branch information
lanyeeee committed Nov 21, 2024
1 parent 9dc7743 commit e6a3d92
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/DownloadingList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import {onMounted, ref} from "vue";
import {computed, onMounted, ref} from "vue";
import {commands, Config, events} from "../bindings.ts";
import {open} from "@tauri-apps/plugin-dialog";
import {NProgress, useNotification} from "naive-ui";
Expand Down Expand Up @@ -30,6 +30,14 @@ const overallProgress = ref<ProgressData>({
});
const settingsDialogShowing = ref<boolean>(false);
const sortedProgresses = computed(() => {
const progressesArray = Array.from(progresses.value.entries());
progressesArray.sort((a, b) => {
return b[1].total - a[1].total;
});
return progressesArray;
});
onMounted(async () => {
await events.downloadChapterPendingEvent.listen(({payload}) => {
let progressData: ProgressData = {
Expand Down Expand Up @@ -142,14 +150,14 @@ async function selectDownloadDir() {
</n-progress>
<span>{{ overallProgress.downloadedCount }}/{{ overallProgress.total }}</span>
</div>
<div class="grid grid-cols-[2fr_1fr_3fr]"
v-for="[chapterId, {albumTitle,chapterTitle, percentage, downloadedCount, total}] in progresses"
<div class="grid grid-cols-[1fr_1fr_2fr]"
v-for="[chapterId, {albumTitle, chapterTitle, percentage, downloadedCount, total}] in sortedProgresses"
:key="chapterId">
<span class="mb-1! text-ellipsis whitespace-nowrap overflow-hidden">{{ albumTitle }}</span>
<span class="mb-1! text-ellipsis whitespace-nowrap overflow-hidden">{{ chapterTitle }}</span>
<n-progress class="" :percentage="percentage">
<div v-if="total===0">等待中</div>
<div v-else>{{ downloadedCount }}/{{ total }}</div>
<span v-if="total===0">等待中</span>
<n-progress v-else :percentage="percentage">
{{ downloadedCount }}/{{ total }}
</n-progress>
</div>
</div>
Expand Down

0 comments on commit e6a3d92

Please sign in to comment.