op 1
This commit is contained in:
@@ -10,6 +10,7 @@ use std::os::windows::process::CommandExt;
|
||||
use zip::ZipArchive;
|
||||
use std::io::Cursor;
|
||||
|
||||
use crate::process_utils::first_non_empty_line;
|
||||
use crate::storage::{self};
|
||||
|
||||
const YT_DLP_REPO_URL: &str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download";
|
||||
@@ -285,6 +286,11 @@ pub async fn download_qjs(app: &AppHandle) -> Result<PathBuf> {
|
||||
pub async fn update_qjs(app: &AppHandle) -> Result<String> {
|
||||
// QuickJS doesn't have self-update, so we just re-download
|
||||
download_qjs(app).await?;
|
||||
|
||||
let mut settings = storage::load_settings(app)?;
|
||||
settings.last_updated = Some(chrono::Utc::now());
|
||||
storage::save_settings(app, &settings)?;
|
||||
|
||||
Ok("QuickJS 已更新/安装".to_string())
|
||||
}
|
||||
|
||||
@@ -441,18 +447,8 @@ pub fn get_ffmpeg_version(app: &AppHandle) -> Result<String> {
|
||||
|
||||
let output = cmd.output()?;
|
||||
if output.status.success() {
|
||||
// Prefer stdout, fallback to stderr if stdout empty
|
||||
let out = if !output.stdout.is_empty() {
|
||||
String::from_utf8_lossy(&output.stdout).to_string()
|
||||
} else {
|
||||
String::from_utf8_lossy(&output.stderr).to_string()
|
||||
};
|
||||
|
||||
if let Some(first_line) = out.lines().next() {
|
||||
let v = first_line.trim().to_string();
|
||||
if !v.is_empty() {
|
||||
return Ok(v);
|
||||
}
|
||||
if let Some(line) = first_non_empty_line(&output) {
|
||||
return Ok(line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,6 +461,31 @@ pub fn get_qjs_version(app: &AppHandle) -> Result<String> {
|
||||
if !path.exists() {
|
||||
return Ok("未安装".to_string());
|
||||
}
|
||||
|
||||
let mut version_cmd = std::process::Command::new(&path);
|
||||
version_cmd.arg("--version");
|
||||
#[cfg(target_os = "windows")]
|
||||
version_cmd.creation_flags(0x08000000);
|
||||
|
||||
if let Ok(output) = version_cmd.output() {
|
||||
if output.status.success() {
|
||||
if let Some(line) = first_non_empty_line(&output) {
|
||||
return Ok(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut help_cmd = std::process::Command::new(&path);
|
||||
help_cmd.arg("-h");
|
||||
#[cfg(target_os = "windows")]
|
||||
help_cmd.creation_flags(0x08000000);
|
||||
|
||||
if let Ok(output) = help_cmd.output() {
|
||||
if let Some(line) = first_non_empty_line(&output) {
|
||||
return Ok(line);
|
||||
}
|
||||
}
|
||||
|
||||
Ok("已安装".to_string())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user