From 956f3b12ac98c1b7954ada3a1e8c49930af31e43 Mon Sep 17 00:00:00 2001 From: doudou0720 <98651603+doudou0720@users.noreply.github.com> Date: Sat, 21 Mar 2026 23:28:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8F=8D=E9=A6=88):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8F=8D=E9=A6=88=E7=AA=97=E5=8F=A3=E6=9B=BF=E4=BB=A3=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=89=93=E5=BC=80=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构关于面板的反馈功能,将直接打开GitHub问题链接改为显示一个反馈窗口。用户可以在窗口中自定义包含哪些系统信息。 --- Ink Canvas/Windows/FeedbackWindow.xaml | 64 ++++++ Ink Canvas/Windows/FeedbackWindow.xaml.cs | 200 ++++++++++++++++++ .../SettingsViews/AboutPanel.xaml.cs | 90 +------- 3 files changed, 267 insertions(+), 87 deletions(-) create mode 100644 Ink Canvas/Windows/FeedbackWindow.xaml create mode 100644 Ink Canvas/Windows/FeedbackWindow.xaml.cs diff --git a/Ink Canvas/Windows/FeedbackWindow.xaml b/Ink Canvas/Windows/FeedbackWindow.xaml new file mode 100644 index 00000000..5a19e1b1 --- /dev/null +++ b/Ink Canvas/Windows/FeedbackWindow.xaml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/Windows/FeedbackWindow.xaml.cs b/Ink Canvas/Windows/FeedbackWindow.xaml.cs new file mode 100644 index 00000000..973510b4 --- /dev/null +++ b/Ink Canvas/Windows/FeedbackWindow.xaml.cs @@ -0,0 +1,200 @@ +using Ink_Canvas.Helpers; +using OSVersionExtension; +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; + +namespace Ink_Canvas +{ + public partial class FeedbackWindow : Window + { + private string _appVersion = ""; + private string _updateChannel = ""; + private string _osVersion = ""; + private string _netVersion = ""; + private string _touchSupport = ""; + private string _deviceId = ""; + + public FeedbackWindow() + { + InitializeComponent(); + LoadInformation(); + UpdatePreviewText(); + } + + private void LoadInformation() + { + try + { + var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; + _appVersion = $"v{assemblyVersion}"; + } + catch (Exception ex) + { + _appVersion = "未知"; + System.Diagnostics.Debug.WriteLine($"获取软件版本失败: {ex.Message}"); + } + + try + { + if (MainWindow.Settings?.Startup != null) + { + _updateChannel = MainWindow.Settings.Startup.UpdateChannel.ToString(); + } + } + catch (Exception ex) + { + _updateChannel = "未知"; + System.Diagnostics.Debug.WriteLine($"获取更新通道失败: {ex.Message}"); + } + + try + { + _osVersion = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}"; + } + catch (Exception ex) + { + _osVersion = "未知"; + System.Diagnostics.Debug.WriteLine($"获取系统版本失败: {ex.Message}"); + } + + try + { + _netVersion = RuntimeInformation.FrameworkDescription; + } + catch (Exception ex) + { + _netVersion = "未知"; + System.Diagnostics.Debug.WriteLine($"获取.NET版本失败: {ex.Message}"); + } + + try + { + var support = Ink_Canvas.Windows.SettingsViews.AboutPanel.TouchTabletDetectHelper.IsTouchEnabled(); + var touchcount = Ink_Canvas.Windows.SettingsViews.AboutPanel.TouchTabletDetectHelper.GetTouchTabletDevices().Count; + if (support) + { + if (touchcount > 0) + { + _touchSupport = $"支持({touchcount}个设备)"; + } + else + { + _touchSupport = "支持"; + } + } + else + { + _touchSupport = "不支持"; + } + } + catch (Exception ex) + { + _touchSupport = "未知"; + System.Diagnostics.Debug.WriteLine($"获取触控支持失败: {ex.Message}"); + } + + try + { + _deviceId = DeviceIdentifier.GetDeviceId(); + } + catch (Exception ex) + { + _deviceId = "获取失败"; + System.Diagnostics.Debug.WriteLine($"获取设备ID失败: {ex.Message}"); + } + } + + private void UpdatePreviewText() + { + TextAppVersionInfo.Text = $"{_appVersion} ({_updateChannel})"; + TextSystemInfo.Text = $"{_osVersion} | {_netVersion} | 触控:{_touchSupport}"; + TextDeviceInfo.Text = $"设备ID: {_deviceId}"; + } + + private void ButtonCancel_Click(object sender, RoutedEventArgs e) + { + Close(); + } + + private void ButtonSubmit_Click(object sender, RoutedEventArgs e) + { + try + { + string versionInfo = ""; + string systemInfo = ""; + + if (CheckBoxAppVersion.IsChecked == true || CheckBoxUpdateChannel.IsChecked == true) + { + if (CheckBoxAppVersion.IsChecked == true) + { + versionInfo += _appVersion; + } + if (CheckBoxUpdateChannel.IsChecked == true) + { + if (!string.IsNullOrEmpty(versionInfo)) + { + versionInfo += " "; + } + versionInfo += $"({_updateChannel})"; + } + } + + if (CheckBoxOSVersion.IsChecked == true || CheckBoxNetVersion.IsChecked == true || CheckBoxTouchSupport.IsChecked == true) + { + if (CheckBoxOSVersion.IsChecked == true) + { + systemInfo += _osVersion; + } + if (CheckBoxNetVersion.IsChecked == true) + { + if (!string.IsNullOrEmpty(systemInfo)) + { + systemInfo += " | "; + } + systemInfo += _netVersion; + } + if (CheckBoxTouchSupport.IsChecked == true) + { + if (!string.IsNullOrEmpty(systemInfo)) + { + systemInfo += " | "; + } + systemInfo += $"触控:{_touchSupport}"; + } + } + + string url = "https://github.com/InkCanvasForClass/community/issues/new?template=01-bug_report.yml"; + + if (!string.IsNullOrEmpty(versionInfo)) + { + url += $"&version={Uri.EscapeDataString(versionInfo)}"; + } + + if (!string.IsNullOrEmpty(systemInfo)) + { + url += $"&os={Uri.EscapeDataString(systemInfo)}"; + } + + if (CheckBoxDeviceId.IsChecked == true) + { + url += $"&device={Uri.EscapeDataString(_deviceId)}"; + } + + Process.Start(new ProcessStartInfo + { + FileName = url, + UseShellExecute = true + }); + + Close(); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"打开反馈链接失败: {ex.Message}"); + } + } + } +} diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs index db84b8e0..05d4028b 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs @@ -464,96 +464,12 @@ namespace Ink_Canvas.Windows.SettingsViews { try { - string version = ""; - string updateChannel = ""; - string osInfo = ""; - string netVersion = ""; - string touchSupport = ""; - - try - { - var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; - version = $"v{assemblyVersion}"; - } - catch (Exception ex) - { - version = "未知"; - System.Diagnostics.Debug.WriteLine($"获取软件版本失败: {ex.Message}"); - } - - try - { - if (MainWindow.Settings?.Startup != null) - { - updateChannel = MainWindow.Settings.Startup.UpdateChannel.ToString(); - } - } - catch (Exception ex) - { - updateChannel = "未知"; - System.Diagnostics.Debug.WriteLine($"获取更新通道失败: {ex.Message}"); - } - - try - { - osInfo = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}"; - } - catch (Exception ex) - { - osInfo = "未知"; - System.Diagnostics.Debug.WriteLine($"获取系统版本失败: {ex.Message}"); - } - - try - { - netVersion = RuntimeInformation.FrameworkDescription; - } - catch (Exception ex) - { - netVersion = "未知"; - System.Diagnostics.Debug.WriteLine($"获取.NET版本失败: {ex.Message}"); - } - - try - { - var support = TouchTabletDetectHelper.IsTouchEnabled(); - var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count; - if (support) - { - if (touchcount > 0) - { - touchSupport = $"支持({touchcount}个设备)"; - } - else - { - touchSupport = "支持"; - } - } - else - { - touchSupport = "不支持"; - } - } - catch (Exception ex) - { - touchSupport = "未知"; - System.Diagnostics.Debug.WriteLine($"获取触控支持失败: {ex.Message}"); - } - - string versionInfo = $"{version} ({updateChannel})"; - string systemInfo = $"{osInfo} | {netVersion} | 触控:{touchSupport}"; - - string url = $"https://github.com/InkCanvasForClass/community/issues/new?template=01-bug_report.yml&version={Uri.EscapeDataString(versionInfo)}&os={Uri.EscapeDataString(systemInfo)}"; - - Process.Start(new ProcessStartInfo - { - FileName = url, - UseShellExecute = true - }); + var feedbackWindow = new FeedbackWindow(); + feedbackWindow.ShowDialog(); } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"打开反馈链接失败: {ex.Message}"); + System.Diagnostics.Debug.WriteLine($"打开反馈窗口失败: {ex.Message}"); } }