From 332cb15e6513bba5d0aafef711eda07daf8a75d3 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sun, 20 Jul 2025 22:45:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9F=A5=E7=9C=8B=E5=85=AC=E5=91=8A?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0=E6=A3=80=E6=9F=A5=E6=97=B6?= =?UTF-8?q?=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/UI/SettingsViewModel.cs | 30 +++++++++++++++++-- .../Settings/AboutUserControl.xaml | 4 ++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 70f985ce09..fdf7fc3523 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -678,12 +678,38 @@ namespace MaaWpfGui.ViewModels.UI (sender as ComboBox)?.MakeComboBoxSearchable(); } + private bool _isCheckingAnnouncement = false; + + public bool IsCheckingAnnouncement + { + get => _isCheckingAnnouncement; + set + { + SetAndNotify(ref _isCheckingAnnouncement, value); + } + } + // UI 绑定的方法 [UsedImplicitly] public async Task CheckAndDownloadAnnouncement() { - await Instances.AnnouncementViewModel.CheckAndDownloadAnnouncement(); - _ = Execute.OnUIThreadAsync(() => Instances.WindowManager.ShowWindow(Instances.AnnouncementViewModel)); + if (IsCheckingAnnouncement) + { + return; + } + + IsCheckingAnnouncement = true; + + try + { + await Instances.AnnouncementViewModel.CheckAndDownloadAnnouncement(); + await Execute.OnUIThreadAsync(() => + Instances.WindowManager.ShowWindow(Instances.AnnouncementViewModel)); + } + finally + { + IsCheckingAnnouncement = false; + } } /// diff --git a/src/MaaWpfGui/Views/UserControl/Settings/AboutUserControl.xaml b/src/MaaWpfGui/Views/UserControl/Settings/AboutUserControl.xaml index cff3114f2a..30d0b08f02 100644 --- a/src/MaaWpfGui/Views/UserControl/Settings/AboutUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/Settings/AboutUserControl.xaml @@ -2,6 +2,7 @@ x:Class="MaaWpfGui.Views.UserControl.Settings.AboutUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding" xmlns:constants="clr-namespace:MaaWpfGui.Constants" xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" @@ -59,7 +60,8 @@ Width="Auto" Margin="5" Command="{s:Action CheckAndDownloadAnnouncement}" - Content="{DynamicResource CheckAndDownloadAnnouncement}" /> + Content="{DynamicResource CheckAndDownloadAnnouncement}" + IsEnabled="{c:Binding !IsCheckingAnnouncement}" />