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?;
|
let response = reqwest::get(&url).await?;
|
||||||
if !response.status().is_success() {
|
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?;
|
let bytes = response.bytes().await?;
|
||||||
@@ -100,7 +100,7 @@ pub async fn update_ytdlp(app: &AppHandle) -> Result<String> {
|
|||||||
let path = get_ytdlp_path(app)?;
|
let path = get_ytdlp_path(app)?;
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
download_ytdlp(app).await?;
|
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
|
// Use built-in update for yt-dlp
|
||||||
@@ -110,7 +110,7 @@ pub async fn update_ytdlp(app: &AppHandle) -> Result<String> {
|
|||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
|
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
|
// Update settings timestamp
|
||||||
@@ -118,13 +118,13 @@ pub async fn update_ytdlp(app: &AppHandle) -> Result<String> {
|
|||||||
settings.last_updated = Some(chrono::Utc::now());
|
settings.last_updated = Some(chrono::Utc::now());
|
||||||
storage::save_settings(app, &settings)?;
|
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> {
|
pub fn get_ytdlp_version(app: &AppHandle) -> Result<String> {
|
||||||
let path = get_ytdlp_path(app)?;
|
let path = get_ytdlp_path(app)?;
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
return Ok("Not installed".to_string());
|
return Ok("未安装".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = std::process::Command::new(&path)
|
let output = std::process::Command::new(&path)
|
||||||
@@ -134,7 +134,7 @@ pub fn get_ytdlp_version(app: &AppHandle) -> Result<String> {
|
|||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
||||||
} else {
|
} 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_url = format!("{}/LATEST.json", QJS_REPO_URL);
|
||||||
let latest_resp = reqwest::get(&latest_url).await?;
|
let latest_resp = reqwest::get(&latest_url).await?;
|
||||||
if !latest_resp.status().is_success() {
|
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 latest_info: LatestInfo = latest_resp.json().await?;
|
||||||
let version = latest_info.version;
|
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
|
// Bellard lists: quickjs-cosmo-YYYY-MM-DD.zip
|
||||||
format!("quickjs-cosmo-{}.zip", version)
|
format!("quickjs-cosmo-{}.zip", version)
|
||||||
} else {
|
} else {
|
||||||
return Err(anyhow!("Unsupported OS for QuickJS auto-download"));
|
return Err(anyhow!("不支持当前操作系统的 QuickJS 自动下载"));
|
||||||
};
|
};
|
||||||
|
|
||||||
let download_url = format!("{}/{}", QJS_REPO_URL, filename);
|
let download_url = format!("{}/{}", QJS_REPO_URL, filename);
|
||||||
let response = reqwest::get(&download_url).await?;
|
let response = reqwest::get(&download_url).await?;
|
||||||
|
|
||||||
if !response.status().is_success() {
|
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?;
|
let bytes = response.bytes().await?;
|
||||||
@@ -210,7 +210,7 @@ pub async fn download_qjs(app: &AppHandle) -> Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
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)?;
|
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> {
|
pub async fn update_qjs(app: &AppHandle) -> Result<String> {
|
||||||
// QuickJS doesn't have self-update, so we just re-download
|
// QuickJS doesn't have self-update, so we just re-download
|
||||||
download_qjs(app).await?;
|
download_qjs(app).await?;
|
||||||
Ok("QuickJS updated/installed".to_string())
|
Ok("QuickJS 已更新/安装".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_qjs_version(app: &AppHandle) -> Result<String> {
|
pub fn get_qjs_version(app: &AppHandle) -> Result<String> {
|
||||||
let path = get_qjs_path(app)?;
|
let path = get_qjs_path(app)?;
|
||||||
if !path.exists() {
|
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<()> {
|
pub async fn ensure_binaries(app: &AppHandle) -> Result<()> {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useSettingsStore } from '../stores/settings'
|
|||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
import { Folder, RefreshCw, Monitor, Sun, Moon, Terminal } from 'lucide-vue-next'
|
import { Folder, RefreshCw, Monitor, Sun, Moon, Terminal } from 'lucide-vue-next'
|
||||||
|
import { format } from 'date-fns' // Import format
|
||||||
|
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
const updatingYtdlp = ref(false)
|
const updatingYtdlp = ref(false)
|
||||||
@@ -164,7 +165,7 @@ function setTheme(theme: 'light' | 'dark' | 'system') {
|
|||||||
<div v-if="updateStatus" class="mt-4 p-3 bg-gray-50 dark:bg-zinc-800 rounded-lg text-xs font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap border border-gray-200 dark:border-zinc-700">
|
<div v-if="updateStatus" class="mt-4 p-3 bg-gray-50 dark:bg-zinc-800 rounded-lg text-xs font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap border border-gray-200 dark:border-zinc-700">
|
||||||
{{ updateStatus }}
|
{{ updateStatus }}
|
||||||
</div>
|
</div>
|
||||||
<p class="text-xs text-gray-400 mt-4 text-right">上次检查: {{ settingsStore.settings.last_updated ? new Date(settingsStore.settings.last_updated).toLocaleString() : '从未' }}</p>
|
<p class="text-xs text-gray-400 mt-4 text-right">上次检查: {{ settingsStore.settings.last_updated ? format(new Date(settingsStore.settings.last_updated), 'yyyy-MM-dd HH:mm:ss') : '从未' }}</p>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user