From 7c85d208199df2faf0b011c4f97f7badad62f36f Mon Sep 17 00:00:00 2001 From: Vincent Wang <376787823@qq.com> Date: Thu, 24 Oct 2024 22:03:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AAbug?= =?UTF-8?q?=EF=BC=9B=E6=B8=85=E7=A9=BA=E6=97=A5=E5=BF=97=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WeiboAlbumDownloader/MainWindow.xaml | 2 + WeiboAlbumDownloader/MainWindow.xaml.cs | 58 ++++++++++++++++++++----- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/WeiboAlbumDownloader/MainWindow.xaml b/WeiboAlbumDownloader/MainWindow.xaml index 17ab3a7..a187055 100644 --- a/WeiboAlbumDownloader/MainWindow.xaml +++ b/WeiboAlbumDownloader/MainWindow.xaml @@ -182,6 +182,8 @@ + + diff --git a/WeiboAlbumDownloader/MainWindow.xaml.cs b/WeiboAlbumDownloader/MainWindow.xaml.cs index 22fee8a..46bdde2 100644 --- a/WeiboAlbumDownloader/MainWindow.xaml.cs +++ b/WeiboAlbumDownloader/MainWindow.xaml.cs @@ -12,6 +12,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -33,7 +34,7 @@ public partial class MainWindow : MicaWindow //①此处升级一下版本号 //②Github release新建一个新版本Tag //③上传压缩包删除Settings.json以及uidList.txt - double currentVersion = 3.4; + double currentVersion = 3.5; /// /// com1是根据uid获取相册id,https://photo.weibo.com/albums/get_all?uid=10000000000&page=1;根据uid和相册id以及相册type获取图片列表,https://photo.weibo.com/photos/get_all?uid=10000000000&album_id=3959362334782071&page=1&type=3 @@ -923,6 +924,10 @@ await Task.Run(async () => AppendLog(msg, MessageEnum.Error); SentrySdk.CaptureMessage(msg, SentryLevel.Error); } + finally + { + tbDownload.Text = "开始下载"; + } } private void AppendLog(string text, MessageEnum messageEnum = MessageEnum.Info) @@ -1038,7 +1043,46 @@ private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation. private void ListView_CopyLog(object sender, RoutedEventArgs e) { - Clipboard.SetText((ListView_Messages.SelectedItem as MessageModel)!.Message); + if(ListView_Messages.SelectedItem != null) + Clipboard.SetText((ListView_Messages.SelectedItem! as MessageModel)!.Message); + } + + private void ListView_ClearLog(object sender, RoutedEventArgs e) + { + Messages.Clear(); + } + + private void ListView_ExportLog(object sender, RoutedEventArgs e) + { + var dialog = new Microsoft.Win32.SaveFileDialog(); + dialog.FileName = $"{GlobalVar.gId}-log"; + dialog.DefaultExt = ".txt"; + dialog.Filter = "下载日志 (.txt)|*.txt"; + + bool? result = dialog.ShowDialog(); + + if (result == true) + { + StringBuilder sb = new StringBuilder(); + foreach (var message in Messages) + { + string line = $"{message.Time},{message.Message},{message.MessageType}"; + sb.AppendLine(line); + } + + File.WriteAllText(dialog.FileName, sb.ToString()); + } + } + + private async void TextBox_WeiboId_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key == System.Windows.Input.Key.Enter) + await Start(TextBox_WeiboId.Text.Trim()); + } + + private void OpenGithub(object sender, RoutedEventArgs e) + { + Process.Start(new ProcessStartInfo("https://github.com/hupo376787/WeiboAlbumDownloader") { UseShellExecute = true }); } private void ComboBox_DataSource_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) @@ -1138,15 +1182,5 @@ private void GetCookie(object sender, RoutedEventArgs e) driver.Quit(); } - private async void TextBox_WeiboId_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) - { - if (e.Key == System.Windows.Input.Key.Enter) - await Start(TextBox_WeiboId.Text.Trim()); - } - - private void OpenGithub(object sender, RoutedEventArgs e) - { - Process.Start(new ProcessStartInfo("https://github.com/hupo376787/WeiboAlbumDownloader") { UseShellExecute = true }); - } } }