1
This commit is contained in:
32
src/services/avatarVideo.js
Normal file
32
src/services/avatarVideo.js
Normal file
@@ -0,0 +1,32 @@
|
||||
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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user