From 9b5a1732df3ddbfd7968a15020f62d69ec391bcf Mon Sep 17 00:00:00 2001 From: CreeperAWA Date: Sun, 13 Sep 2026 22:53:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(security/settings):=20=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E8=BE=93=E5=85=A5=E6=A1=86=E7=9A=84=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为密码输入框、API密钥输入框添加输入法禁用配置,防止中文输入法意外输入导致的格式错误,提升安全输入体验。 --- .../Services/Security/SecuritySetupWindows.cs | 14 ++++++++++---- .../Security/SecurityVerificationWindow.cs | 2 ++ .../Notification/VoiceSettingsPage.axaml.cs | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/SecRandom/Services/Security/SecuritySetupWindows.cs b/SecRandom/Services/Security/SecuritySetupWindows.cs index 767f3c84..f85edd5a 100644 --- a/SecRandom/Services/Security/SecuritySetupWindows.cs +++ b/SecRandom/Services/Security/SecuritySetupWindows.cs @@ -3,6 +3,7 @@ using Avalonia.Controls.Primitives; using Avalonia.Controls.Selection; using Avalonia.Controls.Templates; +using Avalonia.Input; using Avalonia.Input.Platform; using Avalonia.Layout; using Avalonia.Media; @@ -291,11 +292,16 @@ private static void AddUsbField( Content = content }; - private static TextBox CreatePasswordInput(string placeholderText) => new() + private static TextBox CreatePasswordInput(string placeholderText) { - PasswordChar = '●', - PlaceholderText = placeholderText - }; + var input = new TextBox + { + PasswordChar = '●', + PlaceholderText = placeholderText + }; + InputMethod.SetIsInputMethodEnabled(input, false); + return input; + } private static IImage BuildQrCode(string content) { diff --git a/SecRandom/Services/Security/SecurityVerificationWindow.cs b/SecRandom/Services/Security/SecurityVerificationWindow.cs index 9abe61ab..403cccff 100644 --- a/SecRandom/Services/Security/SecurityVerificationWindow.cs +++ b/SecRandom/Services/Security/SecurityVerificationWindow.cs @@ -4,6 +4,7 @@ using System.Windows.Input; using Avalonia; using Avalonia.Controls; +using Avalonia.Input; using Avalonia.Layout; using Avalonia.Threading; using FluentAvalonia.UI.Controls; @@ -23,6 +24,7 @@ public static async Task ShowAsync(TopLevel xamlRo PasswordChar = '●', PlaceholderText = SR.C_PasswordPlaceholder }; + InputMethod.SetIsInputMethodEnabled(password, false); var totp = new TextBox { PlaceholderText = SR.C_TotpPlaceholder, MaxLength = 6 }; var usb = new TextBlock { diff --git a/SecRandom/Views/SettingsPages/Notification/VoiceSettingsPage.axaml.cs b/SecRandom/Views/SettingsPages/Notification/VoiceSettingsPage.axaml.cs index 7c82753d..ae92c9a2 100644 --- a/SecRandom/Views/SettingsPages/Notification/VoiceSettingsPage.axaml.cs +++ b/SecRandom/Views/SettingsPages/Notification/VoiceSettingsPage.axaml.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Controls.Templates; +using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Media; using Avalonia.Platform.Storage; @@ -836,6 +837,7 @@ private async void OpenOmniTtsProviderButton_OnClick(object? sender, RoutedEvent (option, _) => new TextBlock { Text = option.DisplayName }); var baseUrlBox = new TextBox { MinWidth = 360, Text = Settings.OmniTtsApiBaseUrl }; var apiKeyBox = new TextBox { MinWidth = 360, PasswordChar = '*' }; + InputMethod.SetIsInputMethodEnabled(apiKeyBox, false); var keyStatus = new TextBlock { Opacity = 0.7, FontSize = 12 }; void RefreshKeyStatus()