fix: 修复 Rust 编译错误

🔧 修复内容:
- 添加缺失的 execute_python_command 函数
- 移除未使用的导入 (tauri::Manager, tauri::State)
- 统一 Python 命令执行逻辑

 编译状态:
- Rust 编译成功 ✓
- 前端构建成功 ✓
- 所有警告已清除 ✓

现在 AI 视频生成功能可以正常编译和运行了!
This commit is contained in:
root 2025-07-10 10:49:15 +08:00
parent 96e166725b
commit 5f31df6851
2 changed files with 21 additions and 3 deletions

View File

@ -20,7 +20,6 @@ pub struct BatchAIVideoRequest {
pub timeout: Option<u32>, pub timeout: Option<u32>,
} }
use std::process::Command; use std::process::Command;
use tauri::State;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct VideoProcessRequest { pub struct VideoProcessRequest {
@ -65,6 +64,27 @@ pub struct AudioTrack {
pub volume: f64, pub volume: f64,
} }
// Helper function to execute Python commands
async fn execute_python_command(args: &[String]) -> Result<String, String> {
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] #[tauri::command]
pub async fn greet(name: &str) -> Result<String, String> { pub async fn greet(name: &str) -> Result<String, String> {
Ok(format!("Hello, {}! Welcome to MixVideo V2!", name)) Ok(format!("Hello, {}! Welcome to MixVideo V2!", name))

View File

@ -1,5 +1,3 @@
use tauri::Manager;
mod commands; mod commands;
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]