diff --git a/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs b/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs index a60cfe7aea..43fff403a9 100644 --- a/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs +++ b/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs @@ -29,14 +29,14 @@ namespace MaaWpfGui.Services.Notification public async Task SendAsync(string title, string content) { - var sendKey = SettingsViewModel.ExternalNotificationDataContext.BarkSendKey; + var sendKey = SettingsViewModel.ExternalNotificationSettings.BarkSendKey; if (string.IsNullOrWhiteSpace(sendKey)) { _logger.Warning("Failed to send Bark notification, Bark send key is empty"); return false; } - var apiBase = SettingsViewModel.ExternalNotificationDataContext.BarkServer; + var apiBase = SettingsViewModel.ExternalNotificationSettings.BarkServer; if (string.IsNullOrWhiteSpace(apiBase)) { _logger.Warning("Failed to send Bark notification, Bark server address is empty"); diff --git a/src/MaaWpfGui/Services/Notification/DiscordNotificationProvider.cs b/src/MaaWpfGui/Services/Notification/DiscordNotificationProvider.cs index 9843ff8a90..91f8b8f181 100644 --- a/src/MaaWpfGui/Services/Notification/DiscordNotificationProvider.cs +++ b/src/MaaWpfGui/Services/Notification/DiscordNotificationProvider.cs @@ -32,8 +32,8 @@ public class DiscordNotificationProvider(IHttpService httpService) : IExternalNo public async Task SendAsync(string title, string content) { - var botToken = SettingsViewModel.ExternalNotificationDataContext.DiscordBotToken; - var userId = SettingsViewModel.ExternalNotificationDataContext.DiscordUserId; + var botToken = SettingsViewModel.ExternalNotificationSettings.DiscordBotToken; + var userId = SettingsViewModel.ExternalNotificationSettings.DiscordUserId; var channelId = await CreateDmChannel(botToken, userId); diff --git a/src/MaaWpfGui/Services/Notification/ExternalNotificationService.cs b/src/MaaWpfGui/Services/Notification/ExternalNotificationService.cs index 2bc9904673..2801daa6d6 100644 --- a/src/MaaWpfGui/Services/Notification/ExternalNotificationService.cs +++ b/src/MaaWpfGui/Services/Notification/ExternalNotificationService.cs @@ -28,7 +28,7 @@ namespace MaaWpfGui.Services.Notification private static async Task SendAsync(string title, string content, bool isTest = false) { - var enabledProviders = SettingsViewModel.ExternalNotificationDataContext.EnabledExternalNotificationProviderList; + var enabledProviders = SettingsViewModel.ExternalNotificationSettings.EnabledExternalNotificationProviderList; foreach (var enabledProvider in enabledProviders) { diff --git a/src/MaaWpfGui/Services/Notification/QmsgNotificationProvider.cs b/src/MaaWpfGui/Services/Notification/QmsgNotificationProvider.cs index cea27c7738..1ab7ba3c86 100644 --- a/src/MaaWpfGui/Services/Notification/QmsgNotificationProvider.cs +++ b/src/MaaWpfGui/Services/Notification/QmsgNotificationProvider.cs @@ -37,10 +37,10 @@ namespace MaaWpfGui.Services.Notification public async Task SendAsync(string title, string content) { - var server = SettingsViewModel.ExternalNotificationDataContext.QmsgServer; - var key = SettingsViewModel.ExternalNotificationDataContext.QmsgKey; - var receiveUser = SettingsViewModel.ExternalNotificationDataContext.QmsgUser; - var sendBot = SettingsViewModel.ExternalNotificationDataContext.QmsgBot; + var server = SettingsViewModel.ExternalNotificationSettings.QmsgServer; + var key = SettingsViewModel.ExternalNotificationSettings.QmsgKey; + var receiveUser = SettingsViewModel.ExternalNotificationSettings.QmsgUser; + var sendBot = SettingsViewModel.ExternalNotificationSettings.QmsgBot; var uri = $"{server}/jsend/{key}"; diff --git a/src/MaaWpfGui/Services/Notification/ServerChanNotificationProvider.cs b/src/MaaWpfGui/Services/Notification/ServerChanNotificationProvider.cs index 188d411287..1aed1ea5ae 100644 --- a/src/MaaWpfGui/Services/Notification/ServerChanNotificationProvider.cs +++ b/src/MaaWpfGui/Services/Notification/ServerChanNotificationProvider.cs @@ -45,7 +45,7 @@ namespace MaaWpfGui.Services.Notification title = title[..32]; // 截取前 32 个字符 } - var sendKey = SettingsViewModel.ExternalNotificationDataContext.ServerChanSendKey; + var sendKey = SettingsViewModel.ExternalNotificationSettings.ServerChanSendKey; try { diff --git a/src/MaaWpfGui/Services/Notification/SmtpNotificationProvider.cs b/src/MaaWpfGui/Services/Notification/SmtpNotificationProvider.cs index 1c9631d6ea..8634a59076 100644 --- a/src/MaaWpfGui/Services/Notification/SmtpNotificationProvider.cs +++ b/src/MaaWpfGui/Services/Notification/SmtpNotificationProvider.cs @@ -30,12 +30,12 @@ namespace MaaWpfGui.Services.Notification public async Task SendAsync(string title, string content) { - var smtpServer = SettingsViewModel.ExternalNotificationDataContext.SmtpServer; - var smtpPortValid = int.TryParse(SettingsViewModel.ExternalNotificationDataContext.SmtpPort, out var smtpPort); - var smtpUser = SettingsViewModel.ExternalNotificationDataContext.SmtpUser; - var smtpPassword = SettingsViewModel.ExternalNotificationDataContext.SmtpPassword; - var smtpUseSsl = SettingsViewModel.ExternalNotificationDataContext.SmtpUseSsl; - var smtpRequiresAuthentication = SettingsViewModel.ExternalNotificationDataContext.SmtpRequireAuthentication; + var smtpServer = SettingsViewModel.ExternalNotificationSettings.SmtpServer; + var smtpPortValid = int.TryParse(SettingsViewModel.ExternalNotificationSettings.SmtpPort, out var smtpPort); + var smtpUser = SettingsViewModel.ExternalNotificationSettings.SmtpUser; + var smtpPassword = SettingsViewModel.ExternalNotificationSettings.SmtpPassword; + var smtpUseSsl = SettingsViewModel.ExternalNotificationSettings.SmtpUseSsl; + var smtpRequiresAuthentication = SettingsViewModel.ExternalNotificationSettings.SmtpRequireAuthentication; if (string.IsNullOrEmpty(smtpServer) || smtpPortValid is false) { @@ -56,8 +56,8 @@ namespace MaaWpfGui.Services.Notification Email.DefaultRenderer = new LiquidRenderer(new OptionsWrapper(new LiquidRendererOptions())); - var emailFrom = SettingsViewModel.ExternalNotificationDataContext.SmtpFrom; - var emailTo = SettingsViewModel.ExternalNotificationDataContext.SmtpTo; + var emailFrom = SettingsViewModel.ExternalNotificationSettings.SmtpFrom; + var emailTo = SettingsViewModel.ExternalNotificationSettings.SmtpTo; title = Regex.Replace(title, "\r(?!\n)", "\r\n"); content = Regex.Replace(content, "\r(?!\n)", "\r\n"); diff --git a/src/MaaWpfGui/Services/Notification/TelegramNotificationProvider.cs b/src/MaaWpfGui/Services/Notification/TelegramNotificationProvider.cs index 7a33d116e3..035db78241 100644 --- a/src/MaaWpfGui/Services/Notification/TelegramNotificationProvider.cs +++ b/src/MaaWpfGui/Services/Notification/TelegramNotificationProvider.cs @@ -29,8 +29,8 @@ public class TelegramNotificationProvider(IHttpService httpService) : IExternalN public async Task SendAsync(string title, string content) { - var botToken = SettingsViewModel.ExternalNotificationDataContext.TelegramBotToken; - var chatId = SettingsViewModel.ExternalNotificationDataContext.TelegramChatId; + var botToken = SettingsViewModel.ExternalNotificationSettings.TelegramBotToken; + var chatId = SettingsViewModel.ExternalNotificationSettings.TelegramChatId; var uri = $"https://api.telegram.org/bot{botToken}/sendMessage"; diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index de22e18362..c03123948d 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -115,7 +115,7 @@ namespace MaaWpfGui.ViewModels.UI /// /// Gets 外部通知model /// - public static ExternalNotificationSettingsUserControlModel ExternalNotificationDataContext { get; } = new(); + public static ExternalNotificationSettingsUserControlModel ExternalNotificationSettings { get; } = new(); #endregion 设置界面Model diff --git a/src/MaaWpfGui/Views/UI/SettingsView.xaml b/src/MaaWpfGui/Views/UI/SettingsView.xaml index 8890904cba..006229e009 100644 --- a/src/MaaWpfGui/Views/UI/SettingsView.xaml +++ b/src/MaaWpfGui/Views/UI/SettingsView.xaml @@ -84,7 +84,7 @@ + DataContext="{Binding ExternalNotificationSettings}" />