From 5f31df685159a8aa9e23d4564599c75a5044cdf4 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 10 Jul 2025 10:49:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Rust=20=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 修复内容: - 添加缺失的 execute_python_command 函数 - 移除未使用的导入 (tauri::Manager, tauri::State) - 统一 Python 命令执行逻辑 ✅ 编译状态: - Rust 编译成功 ✓ - 前端构建成功 ✓ - 所有警告已清除 ✓ 现在 AI 视频生成功能可以正常编译和运行了! --- src-tauri/src/commands.rs | 22 +++++++++++++++++++++- src-tauri/src/lib.rs | 2 -- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 34a7da3..0fc8fc2 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -20,7 +20,6 @@ pub struct BatchAIVideoRequest { pub timeout: Option, } use std::process::Command; -use tauri::State; #[derive(Debug, Serialize, Deserialize)] pub struct VideoProcessRequest { @@ -65,6 +64,27 @@ pub struct AudioTrack { pub volume: f64, } +// Helper function to execute Python commands +async fn execute_python_command(args: &[String]) -> Result { + let mut cmd = Command::new("python3"); + + for arg in args { + cmd.arg(arg); + } + + let output = cmd + .output() + .map_err(|e| format!("Failed to execute Python script: {}", e))?; + + if output.status.success() { + let result = String::from_utf8_lossy(&output.stdout); + Ok(result.to_string()) + } else { + let error = String::from_utf8_lossy(&output.stderr); + Err(format!("Python script error: {}", error)) + } +} + #[tauri::command] pub async fn greet(name: &str) -> Result { Ok(format!("Hello, {}! Welcome to MixVideo V2!", name)) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index ba0b38f..db8d0e2 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,5 +1,3 @@ -use tauri::Manager; - mod commands; #[cfg_attr(mobile, tauri::mobile_entry_point)]