From 41733615fd75cd35bf3933a90e92b93ae217e09a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 21 Feb 2025 20:45:42 +0800 Subject: [PATCH 1/3] Improve code quality --- Flow.Launcher/CustomQueryHotkeySetting.xaml | 5 +---- Flow.Launcher/CustomShortcutSetting.xaml | 5 +---- Flow.Launcher/PriorityChangeWindow.xaml | 5 +---- Flow.Launcher/SelectBrowserWindow.xaml | 5 +---- Flow.Launcher/SelectFileManagerWindow.xaml | 5 +---- Flow.Launcher/WelcomeWindow.xaml | 5 +---- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml b/Flow.Launcher/CustomQueryHotkeySetting.xaml index 068afda15b4..70ebb404b91 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml @@ -32,14 +32,11 @@ - - - + + + diff --git a/Flow.Launcher/ReportWindow.xaml.cs b/Flow.Launcher/ReportWindow.xaml.cs index a535dfb3eb0..12ffe3ffc5e 100644 --- a/Flow.Launcher/ReportWindow.xaml.cs +++ b/Flow.Launcher/ReportWindow.xaml.cs @@ -6,10 +6,10 @@ using System.Linq; using System.Windows; using System.Windows.Documents; -using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.SharedCommands; +using Flow.Launcher.Infrastructure.Exception; namespace Flow.Launcher { @@ -43,32 +43,36 @@ private void SetException(Exception exception) var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); var websiteUrl = exception switch - { - FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website), - _ => Constant.IssuesUrl - }; - + { + FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website), + _ => Constant.IssuesUrl + }; - var paragraph = Hyperlink("Please open new issue in: ", websiteUrl); - paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); - paragraph.Inlines.Add($"2. copy below exception message"); + var paragraph = Hyperlink(App.API.GetTranslation("reportWindow_please_open_issue"), websiteUrl); + paragraph.Inlines.Add(string.Format(App.API.GetTranslation("reportWindow_upload_log"), log.FullName)); + paragraph.Inlines.Add("\n"); + paragraph.Inlines.Add(App.API.GetTranslation("reportWindow_copy_below")); ErrorTextbox.Document.Blocks.Add(paragraph); StringBuilder content = new StringBuilder(); - content.AppendLine(ErrorReporting.RuntimeInfo()); - content.AppendLine(ErrorReporting.DependenciesInfo()); - content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); - content.AppendLine("Exception:"); + content.AppendLine(RuntimeInfo()); + content.AppendLine(); + content.AppendLine(DependenciesInfo()); + content.AppendLine(); + content.AppendLine(string.Format(App.API.GetTranslation("reportWindow_date"), DateTime.Now.ToString(CultureInfo.InvariantCulture))); + content.AppendLine(App.API.GetTranslation("reportWindow_exception")); content.AppendLine(exception.ToString()); paragraph = new Paragraph(); paragraph.Inlines.Add(content.ToString()); ErrorTextbox.Document.Blocks.Add(paragraph); } - private Paragraph Hyperlink(string textBeforeUrl, string url) + private static Paragraph Hyperlink(string textBeforeUrl, string url) { - var paragraph = new Paragraph(); - paragraph.Margin = new Thickness(0); + var paragraph = new Paragraph + { + Margin = new Thickness(0) + }; var link = new Hyperlink { @@ -79,10 +83,38 @@ private Paragraph Hyperlink(string textBeforeUrl, string url) link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); paragraph.Inlines.Add(textBeforeUrl); + paragraph.Inlines.Add(" "); paragraph.Inlines.Add(link); paragraph.Inlines.Add("\n"); return paragraph; } + + private void BtnCancel_OnClick(object sender, RoutedEventArgs e) + { + Close(); + } + + private static string RuntimeInfo() + { + var info = + $""" + Flow Launcher {App.API.GetTranslation("reportWindow_version")}: {Constant.Version} + OS {App.API.GetTranslation("reportWindow_version")}: {ExceptionFormatter.GetWindowsFullVersionFromRegistry()} + IntPtr {App.API.GetTranslation("reportWindow_length")}: {IntPtr.Size} + x64: {Environment.Is64BitOperatingSystem} + """; + return info; + } + + private static string DependenciesInfo() + { + var info = + $""" + {App.API.GetTranslation("pythonFilePath")}: {Constant.PythonPath} + {App.API.GetTranslation("nodeFilePath")}: {Constant.NodePath} + """; + return info; + } } } From 3fa88064bd572741c8590ce7a1064fb65324b65a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 26 Feb 2025 18:30:33 +0800 Subject: [PATCH 3/3] Remove useless localization --- Flow.Launcher/Languages/en.xaml | 3 --- Flow.Launcher/ReportWindow.xaml.cs | 33 +++++------------------------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 493528a8980..5d2cb2d9e98 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -386,9 +386,6 @@ Please open new issue in 1. Upload log file: {0} 2. Copy below exception message - Date: {0} - Exception: - Length Please wait... diff --git a/Flow.Launcher/ReportWindow.xaml.cs b/Flow.Launcher/ReportWindow.xaml.cs index 12ffe3ffc5e..6fe90783ec9 100644 --- a/Flow.Launcher/ReportWindow.xaml.cs +++ b/Flow.Launcher/ReportWindow.xaml.cs @@ -6,10 +6,10 @@ using System.Linq; using System.Windows; using System.Windows.Documents; +using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.SharedCommands; -using Flow.Launcher.Infrastructure.Exception; namespace Flow.Launcher { @@ -55,12 +55,11 @@ private void SetException(Exception exception) ErrorTextbox.Document.Blocks.Add(paragraph); StringBuilder content = new StringBuilder(); - content.AppendLine(RuntimeInfo()); + content.AppendLine(ErrorReporting.RuntimeInfo()); + content.AppendLine(ErrorReporting.DependenciesInfo()); content.AppendLine(); - content.AppendLine(DependenciesInfo()); - content.AppendLine(); - content.AppendLine(string.Format(App.API.GetTranslation("reportWindow_date"), DateTime.Now.ToString(CultureInfo.InvariantCulture))); - content.AppendLine(App.API.GetTranslation("reportWindow_exception")); + content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); + content.AppendLine("Exception:"); content.AppendLine(exception.ToString()); paragraph = new Paragraph(); paragraph.Inlines.Add(content.ToString()); @@ -94,27 +93,5 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e) { Close(); } - - private static string RuntimeInfo() - { - var info = - $""" - Flow Launcher {App.API.GetTranslation("reportWindow_version")}: {Constant.Version} - OS {App.API.GetTranslation("reportWindow_version")}: {ExceptionFormatter.GetWindowsFullVersionFromRegistry()} - IntPtr {App.API.GetTranslation("reportWindow_length")}: {IntPtr.Size} - x64: {Environment.Is64BitOperatingSystem} - """; - return info; - } - - private static string DependenciesInfo() - { - var info = - $""" - {App.API.GetTranslation("pythonFilePath")}: {Constant.PythonPath} - {App.API.GetTranslation("nodeFilePath")}: {Constant.NodePath} - """; - return info; - } } }