fix data format and zhcn
This commit is contained in:
@@ -74,7 +74,7 @@ pub async fn download_ytdlp(app: &AppHandle) -> Result<PathBuf> {
|
||||
|
||||
let response = reqwest::get(&url).await?;
|
||||
if !response.status().is_success() {
|
||||
return Err(anyhow!("Failed to download yt-dlp: Status {}", response.status()));
|
||||
return Err(anyhow!("下载 yt-dlp 失败:状态 {}", response.status()));
|
||||
}
|
||||
|
||||
let bytes = response.bytes().await?;
|
||||
@@ -100,7 +100,7 @@ pub async fn update_ytdlp(app: &AppHandle) -> Result<String> {
|
||||
let path = get_ytdlp_path(app)?;
|
||||
if !path.exists() {
|
||||
download_ytdlp(app).await?;
|
||||
return Ok("Downloaded fresh yt-dlp".to_string());
|
||||
return Ok("yt-dlp 已全新下载".to_string());
|
||||
}
|
||||
|
||||
// Use built-in update for yt-dlp
|
||||
@@ -110,7 +110,7 @@ pub async fn update_ytdlp(app: &AppHandle) -> Result<String> {
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
|
||||
return Err(anyhow!("yt-dlp update failed: {}", stderr));
|
||||
return Err(anyhow!("yt-dlp 更新失败:{}", stderr));
|
||||
}
|
||||
|
||||
// Update settings timestamp
|
||||
@@ -118,13 +118,13 @@ pub async fn update_ytdlp(app: &AppHandle) -> Result<String> {
|
||||
settings.last_updated = Some(chrono::Utc::now());
|
||||
storage::save_settings(app, &settings)?;
|
||||
|
||||
Ok("yt-dlp updated".to_string())
|
||||
Ok("yt-dlp 已更新".to_string())
|
||||
}
|
||||
|
||||
pub fn get_ytdlp_version(app: &AppHandle) -> Result<String> {
|
||||
let path = get_ytdlp_path(app)?;
|
||||
if !path.exists() {
|
||||
return Ok("Not installed".to_string());
|
||||
return Ok("未安装".to_string());
|
||||
}
|
||||
|
||||
let output = std::process::Command::new(&path)
|
||||
@@ -134,7 +134,7 @@ pub fn get_ytdlp_version(app: &AppHandle) -> Result<String> {
|
||||
if output.status.success() {
|
||||
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
||||
} else {
|
||||
Ok("Unknown".to_string())
|
||||
Ok("未知".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ pub async fn download_qjs(app: &AppHandle) -> Result<PathBuf> {
|
||||
let latest_url = format!("{}/LATEST.json", QJS_REPO_URL);
|
||||
let latest_resp = reqwest::get(&latest_url).await?;
|
||||
if !latest_resp.status().is_success() {
|
||||
return Err(anyhow!("Failed to fetch QuickJS version info"));
|
||||
return Err(anyhow!("获取 QuickJS 版本信息失败"));
|
||||
}
|
||||
let latest_info: LatestInfo = latest_resp.json().await?;
|
||||
let version = latest_info.version;
|
||||
@@ -170,14 +170,14 @@ pub async fn download_qjs(app: &AppHandle) -> Result<PathBuf> {
|
||||
// Bellard lists: quickjs-cosmo-YYYY-MM-DD.zip
|
||||
format!("quickjs-cosmo-{}.zip", version)
|
||||
} else {
|
||||
return Err(anyhow!("Unsupported OS for QuickJS auto-download"));
|
||||
return Err(anyhow!("不支持当前操作系统的 QuickJS 自动下载"));
|
||||
};
|
||||
|
||||
let download_url = format!("{}/{}", QJS_REPO_URL, filename);
|
||||
let response = reqwest::get(&download_url).await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
return Err(anyhow!("Failed to download QuickJS: Status {}", response.status()));
|
||||
return Err(anyhow!("下载 QuickJS 失败:状态 {}", response.status()));
|
||||
}
|
||||
|
||||
let bytes = response.bytes().await?;
|
||||
@@ -210,7 +210,7 @@ pub async fn download_qjs(app: &AppHandle) -> Result<PathBuf> {
|
||||
}
|
||||
|
||||
if !found {
|
||||
return Err(anyhow!("Could not find {} in downloaded archive", source_name));
|
||||
return Err(anyhow!("在下载的压缩包中找不到 {}", source_name));
|
||||
}
|
||||
|
||||
let final_path = get_qjs_path(app)?;
|
||||
@@ -228,15 +228,15 @@ 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?;
|
||||
Ok("QuickJS updated/installed".to_string())
|
||||
Ok("QuickJS 已更新/安装".to_string())
|
||||
}
|
||||
|
||||
pub fn get_qjs_version(app: &AppHandle) -> Result<String> {
|
||||
let path = get_qjs_path(app)?;
|
||||
if !path.exists() {
|
||||
return Ok("Not installed".to_string());
|
||||
return Ok("未安装".to_string());
|
||||
}
|
||||
Ok("Installed".to_string())
|
||||
Ok("已安装".to_string())
|
||||
}
|
||||
|
||||
pub async fn ensure_binaries(app: &AppHandle) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user