33 lines
797 B
JavaScript
33 lines
797 B
JavaScript
import { invoke, isTauri } from "@tauri-apps/api/core";
|
|
import { open } from "@tauri-apps/plugin-dialog";
|
|
|
|
/**
|
|
* @returns {Promise<string | null>}
|
|
*/
|
|
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<string>} 应用内保存路径
|
|
*/
|
|
export async function importAvatarVideo(sourcePath) {
|
|
return invoke("import_avatar_video", { sourcePath });
|
|
}
|
|
|