修改播放逻辑

This commit is contained in:
2025-08-18 10:16:43 +08:00
parent b72ac736f1
commit 6dc7419fd2
2 changed files with 14 additions and 5 deletions

View File

@@ -39,17 +39,26 @@ pub fn run() {
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
let mut candidates: Vec<std::path::PathBuf> = Vec::new(); let mut candidates: Vec<std::path::PathBuf> = Vec::new();
// Add current working directory // Add current working directory (where the executable is launched from)
if let Ok(cwd) = std::env::current_dir() { if let Ok(cwd) = std::env::current_dir() {
log::info!("🔍 Searching in current working directory: {}", cwd.display()); log::info!("🔍 Searching in launch directory: {}", cwd.display());
candidates.push(cwd.join("video.mp4")); candidates.push(cwd.join("video.mp4"));
candidates.push(cwd.join("public").join("video.mp4")); candidates.push(cwd.join("public").join("video.mp4"));
} }
// Add executable directory and its ancestors // Also check the directory from which the executable is located
if let Ok(exe_path) = std::env::current_exe() {
if let Some(exe_dir) = exe_path.parent() {
log::info!("🔍 Searching in executable directory: {}", exe_dir.display());
candidates.insert(0, exe_dir.join("video.mp4"));
candidates.insert(1, exe_dir.join("public").join("video.mp4"));
}
}
// Add ancestor directories (but skip the immediate parent since we already added it)
if let Ok(exe_path) = std::env::current_exe() { if let Ok(exe_path) = std::env::current_exe() {
log::info!("📁 Executable path: {}", exe_path.display()); log::info!("📁 Executable path: {}", exe_path.display());
let mut ancestor_opt = exe_path.parent(); let mut ancestor_opt = exe_path.parent().and_then(|p| p.parent());
let mut steps = 0; let mut steps = 0;
while let Some(dir) = ancestor_opt { while let Some(dir) = ancestor_opt {
log::info!("🔍 Searching in ancestor directory: {}", dir.display()); log::info!("🔍 Searching in ancestor directory: {}", dir.display());

View File

@@ -44,7 +44,7 @@
"minWidth": 375, "minWidth": 375,
"minHeight": 812, "minHeight": 812,
"resizable": true, "resizable": true,
"fullscreen": false "fullscreen": true
} }
], ],
"security": { "security": {