This commit is contained in:
Julian Freeman
2025-12-08 10:25:39 -04:00
parent 54f841355b
commit 618fd2d933
2 changed files with 9 additions and 9 deletions

View File

@@ -58,7 +58,7 @@ pub struct LogEvent {
pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool) -> Result<MetadataResult> { pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool) -> Result<MetadataResult> {
app.emit("download-log", LogEvent { app.emit("download-log", LogEvent {
id: "Analysis".to_string(), id: "Analysis".to_string(),
message: format!("Starting metadata fetch for URL: {}", url), message: format!("正在为 URL: {} 获取元数据", url),
level: "info".to_string(), level: "info".to_string(),
}).ok(); }).ok();
@@ -93,7 +93,7 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
app.emit("download-log", LogEvent { app.emit("download-log", LogEvent {
id: "Analysis".to_string(), id: "Analysis".to_string(),
message: format!("Metadata fetch failed: {}", stderr), message: format!("元数据获取失败: {}", stderr),
level: "error".to_string(), level: "error".to_string(),
}).ok(); }).ok();
return Err(anyhow!("yt-dlp error: {}", stderr)); return Err(anyhow!("yt-dlp error: {}", stderr));
@@ -120,7 +120,7 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool
app.emit("download-log", LogEvent { app.emit("download-log", LogEvent {
id: "Analysis".to_string(), id: "Analysis".to_string(),
message: "Metadata fetch success (Playlist)".to_string(), message: "元数据获取成功(播放列表)".to_string(),
level: "info".to_string(), level: "info".to_string(),
}).ok(); }).ok();
@@ -132,7 +132,7 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool
let result = MetadataResult::Video(parse_video_metadata(&json)); let result = MetadataResult::Video(parse_video_metadata(&json));
app.emit("download-log", LogEvent { app.emit("download-log", LogEvent {
id: "Analysis".to_string(), id: "Analysis".to_string(),
message: "Metadata fetch success (Video)".to_string(), message: "元数据获取成功(视频)".to_string(),
level: "info".to_string(), level: "info".to_string(),
}).ok(); }).ok();
@@ -201,7 +201,7 @@ pub async fn download_video(
let full_cmd_str = format!("{} {}", ytdlp_path.to_string_lossy(), args.join(" ")); let full_cmd_str = format!("{} {}", ytdlp_path.to_string_lossy(), args.join(" "));
app.emit("download-log", LogEvent { app.emit("download-log", LogEvent {
id: id.clone(), id: id.clone(),
message: format!("Executing command: {}", full_cmd_str), message: format!("正在执行命令: {}", full_cmd_str),
level: "info".to_string(), level: "info".to_string(),
}).ok(); }).ok();
@@ -241,7 +241,7 @@ pub async fn download_video(
app.emit("download-progress", ProgressEvent { app.emit("download-progress", ProgressEvent {
id: id.clone(), id: id.clone(),
progress: pct, progress: pct,
speed: "TODO".to_string(), speed: "待定".to_string(),
status: "downloading".to_string(), status: "downloading".to_string(),
}).ok(); }).ok();
} }
@@ -276,7 +276,7 @@ pub async fn download_video(
speed: "-".to_string(), speed: "-".to_string(),
status: "finished".to_string(), status: "finished".to_string(),
}).ok(); }).ok();
Ok("Download complete".to_string()) Ok("下载完成".to_string())
} else { } else {
app.emit("download-progress", ProgressEvent { app.emit("download-progress", ProgressEvent {
id: id.clone(), id: id.clone(),
@@ -284,6 +284,6 @@ pub async fn download_video(
speed: "-".to_string(), speed: "-".to_string(),
status: "error".to_string(), status: "error".to_string(),
}).ok(); }).ok();
Err(anyhow!("Download process failed")) Err(anyhow!("下载进程失败"))
} }
} }

View File

@@ -23,7 +23,7 @@ onMounted(async () => {
<template> <template>
<div class="flex h-screen bg-gray-50 dark:bg-zinc-950 text-zinc-900 dark:text-gray-100 font-sans overflow-hidden"> <div class="flex h-screen bg-gray-50 dark:bg-zinc-950 text-zinc-900 dark:text-gray-100 font-sans overflow-hidden">
<!-- Sidebar --> <!-- Sidebar -->
<aside class="w-20 lg:w-64 bg-white dark:bg-zinc-900 border-r border-gray-200 dark:border-zinc-800 flex flex-col flex-shrink-0"> <aside class="w-20 lg:w-56 bg-white dark:bg-zinc-900 border-r border-gray-200 dark:border-zinc-800 flex flex-col flex-shrink-0">
<div class="p-6 flex items-center gap-3 justify-center lg:justify-start"> <div class="p-6 flex items-center gap-3 justify-center lg:justify-start">
<div class="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white shrink-0"> <div class="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white shrink-0">
<Download class="w-5 h-5" /> <Download class="w-5 h-5" />