refactor(FeedBack): 重构反馈信息构建逻辑并优化代码结构

将重复的反馈信息构建逻辑提取为独立方法
添加 MarkdownTemplate 属性简化访问
移除无用代码并优化按钮文本

Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com>
This commit is contained in:
doudou0720
2026-04-04 23:58:36 +08:00
parent 9bcdc56a45
commit ae6268e8e3
4 changed files with 101 additions and 174 deletions
@@ -56,11 +56,6 @@
</ui:SettingsCard>
<ui:SettingsCard x:Name="CardFanceId" ContentAlignment="Left">
<CheckBox x:Name="CheckFanceId" IsChecked="False" Content="遥测 ID" ToolTipService.ShowOnDisabled="True">
<CheckBox.ToolTip>
<ToolTip>
<TextBlock>暂无遥测 ID</TextBlock>
</ToolTip>
</CheckBox.ToolTip>
</CheckBox>
</ui:SettingsCard>
</ui:SettingsExpander.Items>
@@ -10,6 +10,8 @@ namespace Ink_Canvas.Windows.FeedbackPages
public event EventHandler<RoutedEventArgs> CardCopyIssueUrlClick;
public event EventHandler<RoutedEventArgs> BtnCopyMarkdownClick;
public string MarkdownTemplate => TextBoxMarkdownTemplate.Text;
public FeedbackPage3()
{
InitializeComponent();
+1 -4
View File
@@ -22,9 +22,6 @@
<ui:NavigationThemeTransition />
</ui:TransitionCollection>
</ui:Frame.ContentTransitions>
<ui:Frame.Content>
<feedbackPages:FeedbackPage1 x:Name="Page1"/>
</ui:Frame.Content>
</ui:Frame>
<Grid Grid.Row="1" VerticalAlignment="Bottom" Margin="0,20,0,0">
@@ -48,7 +45,7 @@
</Style>
</Button.Style>
</Button>
<Button x:Name="ButtonConfirm" Content="下一步" Width="120" Height="36" FontFamily="Microsoft YaHei UI" FontSize="14" FontWeight="SemiBold" Click="ButtonConfirm_Click" Visibility="Collapsed">
<Button x:Name="ButtonConfirm" Content="确认" Width="120" Height="36" FontFamily="Microsoft YaHei UI" FontSize="14" FontWeight="SemiBold" Click="ButtonConfirm_Click" Visibility="Collapsed">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource {x:Static ui:ThemeKeys.AccentButtonStyleKey}}"/>
</Button.Style>
+98 -165
View File
@@ -452,92 +452,106 @@ namespace Ink_Canvas
_page3.TextBoxMarkdownTemplate.Text = template;
}
private (string versionInfo, string systemInfo, string extraInfo) BuildFeedbackInfo()
{
string versionInfo = "";
string systemInfo = "";
string extraInfo = "";
if (_page1.CheckAppVersion.IsChecked == true || _page1.CheckUpdateChannel.IsChecked == true)
{
if (_page1.CheckAppVersion.IsChecked == true)
{
versionInfo += _appVersion;
}
if (_page1.CheckUpdateChannel.IsChecked == true)
{
if (!string.IsNullOrEmpty(versionInfo))
{
versionInfo += " ";
}
versionInfo += $"({_updateChannel})";
}
}
if (_page1.CheckOSVersion.IsChecked == true || _page1.CheckNetVersion.IsChecked == true || _page1.CheckTouchSupport.IsChecked == true)
{
if (_page1.CheckOSVersion.IsChecked == true)
{
systemInfo += _osVersion;
}
if (_page1.CheckNetVersion.IsChecked == true)
{
if (!string.IsNullOrEmpty(systemInfo))
{
systemInfo += " | ";
}
systemInfo += _netVersion;
}
if (_page1.CheckTouchSupport.IsChecked == true)
{
if (!string.IsNullOrEmpty(systemInfo))
{
systemInfo += " | ";
}
systemInfo += $"触控:{_touchSupport}";
}
}
if (_page1.CheckDeviceId.IsChecked == true)
{
extraInfo += $"设备ID: {_deviceId}\n";
}
if (_page1.CheckFanceId.IsChecked == true)
{
extraInfo += $"遥测ID: {_telemetryId}\n";
}
if (_page1.CheckPPTLinkage.IsChecked == true)
{
extraInfo += "\nPPT联动设置:\n";
extraInfo += _pptLinkageSettings;
}
if (_page1.CheckInkRecognition.IsChecked == true)
{
extraInfo += "\n墨迹识别设置:\n";
extraInfo += _inkRecognitionSettings;
}
return (versionInfo, systemInfo, extraInfo);
}
private string BuildGitHubIssueUrl()
{
var (versionInfo, systemInfo, extraInfo) = BuildFeedbackInfo();
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 (!string.IsNullOrEmpty(extraInfo))
{
url += $"&extra={Uri.EscapeDataString(extraInfo)}";
}
return url;
}
public void BtnOpenGitHubIssue_Click(object sender, RoutedEventArgs e)
{
try
{
string versionInfo = "";
string systemInfo = "";
if (_page1.CheckAppVersion.IsChecked == true || _page1.CheckUpdateChannel.IsChecked == true)
{
if (_page1.CheckAppVersion.IsChecked == true)
{
versionInfo += _appVersion;
}
if (_page1.CheckUpdateChannel.IsChecked == true)
{
if (!string.IsNullOrEmpty(versionInfo))
{
versionInfo += " ";
}
versionInfo += $"({_updateChannel})";
}
}
if (_page1.CheckOSVersion.IsChecked == true || _page1.CheckNetVersion.IsChecked == true || _page1.CheckTouchSupport.IsChecked == true)
{
if (_page1.CheckOSVersion.IsChecked == true)
{
systemInfo += _osVersion;
}
if (_page1.CheckNetVersion.IsChecked == true)
{
if (!string.IsNullOrEmpty(systemInfo))
{
systemInfo += " | ";
}
systemInfo += _netVersion;
}
if (_page1.CheckTouchSupport.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)}";
}
string extraInfo = "";
if (_page1.CheckDeviceId.IsChecked == true)
{
extraInfo += $"设备ID: {_deviceId}\n";
}
if (_page1.CheckFanceId.IsChecked == true)
{
extraInfo += $"遥测ID: {_telemetryId}\n";
}
if (_page1.CheckPPTLinkage.IsChecked == true)
{
extraInfo += "\nPPT联动设置:\n";
extraInfo += _pptLinkageSettings;
}
if (_page1.CheckInkRecognition.IsChecked == true)
{
extraInfo += "\n墨迹识别设置:\n";
extraInfo += _inkRecognitionSettings;
}
if (!string.IsNullOrEmpty(extraInfo))
{
url += $"&extra={Uri.EscapeDataString(extraInfo)}";
}
string url = BuildGitHubIssueUrl();
Process.Start(new ProcessStartInfo
{
@@ -557,88 +571,7 @@ namespace Ink_Canvas
{
try
{
string versionInfo = "";
string systemInfo = "";
if (_page1.CheckAppVersion.IsChecked == true || _page1.CheckUpdateChannel.IsChecked == true)
{
if (_page1.CheckAppVersion.IsChecked == true)
{
versionInfo += _appVersion;
}
if (_page1.CheckUpdateChannel.IsChecked == true)
{
if (!string.IsNullOrEmpty(versionInfo))
{
versionInfo += " ";
}
versionInfo += $"({_updateChannel})";
}
}
if (_page1.CheckOSVersion.IsChecked == true || _page1.CheckNetVersion.IsChecked == true || _page1.CheckTouchSupport.IsChecked == true)
{
if (_page1.CheckOSVersion.IsChecked == true)
{
systemInfo += _osVersion;
}
if (_page1.CheckNetVersion.IsChecked == true)
{
if (!string.IsNullOrEmpty(systemInfo))
{
systemInfo += " | ";
}
systemInfo += _netVersion;
}
if (_page1.CheckTouchSupport.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)}";
}
string extraInfo = "";
if (_page1.CheckDeviceId.IsChecked == true)
{
extraInfo += $"设备ID: {_deviceId}\n";
}
if (_page1.CheckFanceId.IsChecked == true)
{
extraInfo += $"遥测ID: {_telemetryId}\n";
}
if (_page1.CheckPPTLinkage.IsChecked == true)
{
extraInfo += "\nPPT联动设置:\n";
extraInfo += _pptLinkageSettings;
}
if (_page1.CheckInkRecognition.IsChecked == true)
{
extraInfo += "\n墨迹识别设置:\n";
extraInfo += _inkRecognitionSettings;
}
if (!string.IsNullOrEmpty(extraInfo))
{
url += $"&extra={Uri.EscapeDataString(extraInfo)}";
}
string url = BuildGitHubIssueUrl();
Clipboard.SetText(url);
_page3.CardCopyIssueUrl.Header = "已复制 ✓";
@@ -653,7 +586,7 @@ namespace Ink_Canvas
{
try
{
Clipboard.SetText(_page3.TextBoxMarkdownTemplate.Text);
Clipboard.SetText(_page3.MarkdownTemplate);
_page3.BtnCopyMarkdown.Content = "已复制 ✓";
}
catch (Exception ex)