Skip to content

Commit

Permalink
fix: 修复在进入下载页面等待下载完成后切换到已完成下载页面没有刷新列表问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Dedicatus546 committed Dec 29, 2024
1 parent 6a5a705 commit 58ccece
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/app-comic-detail-download-button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useDialog from "@/compositions/use-dialog";
import useIpcRendererInvoke from "@/compositions/use-ipc-renderer-invoke";
import useSnackbar from "@/compositions/use-snack-bar";
import logger from "@/logger";
import { emitter } from "@/mitt";
import useDownloadStore from "@/stores/use-download-store";
import useUserStore from "@/stores/use-user-store";
import { resolveDownloadFileName } from "@/utils";
Expand Down Expand Up @@ -197,6 +198,7 @@ const download = async (series?: { id: number; name: string }) => {
fileName,
seriesName: series ? series.name : "",
});
emitter.emit("RefreshCompleteDownloadList");
snackbar.success("下载成功");
} catch (e) {
snackbar.error("下载出错,请打开日志查看详细错误");
Expand Down
14 changes: 14 additions & 0 deletions src/components/app-download-complete-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { getDownloadComicListIpc } from "@/apis";
import EMPTY_STATE_IMG from "@/assets/empty-state/3.jpg";
import useIpcRendererInvoke from "@/compositions/use-ipc-renderer-invoke";
import { emitter } from "@/mitt";
const pagination = reactive({
page: 1,
Expand All @@ -19,6 +20,19 @@ const onPageChange = (page: number) => {
pagination.page = page;
invoke();
};
const onRefreshCompleteDownloadList = () => {
pagination.page = 1;
invoke();
};
onMounted(() => {
emitter.on("RefreshCompleteDownloadList", onRefreshCompleteDownloadList);
});
onUnmounted(() => {
emitter.off("RefreshCompleteDownloadList", onRefreshCompleteDownloadList);
});
</script>

<template>
Expand Down
5 changes: 5 additions & 0 deletions src/mitt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import mitt from "mitt";

export const emitter = mitt<{
RefreshCompleteDownloadList: void;
}>();

0 comments on commit 58ccece

Please sign in to comment.