fix: 文件夹按钮改为在资源管理器中定位文件
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||||
import { NButton, NEmpty, NIcon, NInputNumber, NProgress, NTag, NTooltip, useMessage } from "naive-ui";
|
import { NButton, NEmpty, NIcon, NInputNumber, NProgress, NTag, NTooltip, useMessage } from "naive-ui";
|
||||||
import { ChevronBackOutline, FolderOpenOutline, HelpCircleOutline, PauseOutline, PlayOutline, StopCircleOutline } from "@vicons/ionicons5";
|
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";
|
import { cancelJob, loadDownloadSettings, loadJobs, pauseJob, resumeJob, saveDownloadSettings, type DownloadJob } from "./api";
|
||||||
|
|
||||||
const props = defineProps<{ focusId: string }>();
|
const props = defineProps<{ focusId: string }>();
|
||||||
@@ -157,10 +157,8 @@ async function openFile(job: DownloadJob) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function openDir(job: DownloadJob) {
|
async function openDir(job: DownloadJob) {
|
||||||
const index = Math.max(job.csvPath.lastIndexOf("\\"), job.csvPath.lastIndexOf("/"));
|
const revealed = await revealLocal(job.csvPath).catch(() => false);
|
||||||
const folder = index > 0 ? job.csvPath.slice(0, index) : job.csvPath;
|
if (!revealed) message.info(job.csvPath);
|
||||||
const opened = await openLocal(folder).catch(() => false);
|
|
||||||
if (!opened) message.info(folder);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ export async function openLocal(path: string) {
|
|||||||
return true;
|
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() {
|
export async function chooseDirectory() {
|
||||||
if (!("__TAURI_INTERNALS__" in window)) return null;
|
if (!("__TAURI_INTERNALS__" in window)) return null;
|
||||||
const { open } = await import("@tauri-apps/plugin-dialog");
|
const { open } = await import("@tauri-apps/plugin-dialog");
|
||||||
|
|||||||
Reference in New Issue
Block a user