diff --git a/desktop/src/features/download/DownloadManagerView.vue b/desktop/src/features/download/DownloadManagerView.vue index eeb22cf..75cf6e0 100644 --- a/desktop/src/features/download/DownloadManagerView.vue +++ b/desktop/src/features/download/DownloadManagerView.vue @@ -2,7 +2,7 @@ import { computed, onMounted, onUnmounted, ref } from "vue"; import { NButton, NEmpty, NIcon, NInputNumber, NProgress, NTag, NTooltip, useMessage } from "naive-ui"; import { ChevronBackOutline, FolderOpenOutline, HelpCircleOutline, PauseOutline, PlayOutline, StopCircleOutline } from "@vicons/ionicons5"; -import { ApiError, openLocal } from "../../shared/http"; +import { ApiError, openLocal, revealLocal } from "../../shared/http"; import { cancelJob, loadDownloadSettings, loadJobs, pauseJob, resumeJob, saveDownloadSettings, type DownloadJob } from "./api"; const props = defineProps<{ focusId: string }>(); @@ -157,10 +157,8 @@ async function openFile(job: DownloadJob) { } async function openDir(job: DownloadJob) { - const index = Math.max(job.csvPath.lastIndexOf("\\"), job.csvPath.lastIndexOf("/")); - const folder = index > 0 ? job.csvPath.slice(0, index) : job.csvPath; - const opened = await openLocal(folder).catch(() => false); - if (!opened) message.info(folder); + const revealed = await revealLocal(job.csvPath).catch(() => false); + if (!revealed) message.info(job.csvPath); } diff --git a/desktop/src/shared/http.ts b/desktop/src/shared/http.ts index d734f2d..f721bba 100644 --- a/desktop/src/shared/http.ts +++ b/desktop/src/shared/http.ts @@ -104,6 +104,13 @@ export async function openLocal(path: string) { return true; } +export async function revealLocal(path: string) { + if (!("__TAURI_INTERNALS__" in window)) return false; + const { revealItemInDir } = await import("@tauri-apps/plugin-opener"); + await revealItemInDir(path); + return true; +} + export async function chooseDirectory() { if (!("__TAURI_INTERNALS__" in window)) return null; const { open } = await import("@tauri-apps/plugin-dialog");