import { invoke, isTauri } from "@tauri-apps/api/core"; import { open } from "@tauri-apps/plugin-dialog"; /** * @returns {Promise} */ export async function pickVideoFile() { if (!isTauri()) { throw new Error("请在 Tauri 桌面端选择视频文件"); } const selected = await open({ multiple: false, filters: [ { name: "视频", extensions: ["mp4", "mov", "webm", "mkv", "m4v", "avi"], }, ], }); if (selected == null) return null; if (Array.isArray(selected)) return selected[0] || null; return String(selected); } /** * @param {string} sourcePath * @returns {Promise} 应用内保存路径 */ export async function importAvatarVideo(sourcePath) { return invoke("import_avatar_video", { sourcePath }); }