diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml b/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml index 3b634d046..ea6b5a798 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml +++ b/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml @@ -71,14 +71,24 @@ Text="Beta" /> - + DockPanel.Dock="Right"> + + + + + diff --git a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs index b53d85482..edcf2b20a 100644 --- a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs +++ b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs @@ -180,6 +180,17 @@ public sealed class ASFService : ReactiveObject ActionItem.Repo => "https://github.com/JustArchiNET/ArchiSteamFarm", ActionItem.Wiki => "https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Home-zh-CN", ActionItem.ConfigGenerator => "https://justarchinet.github.io/ASF-WebConfigGenerator", + _ => string.Empty, + }; + + if (url != string.Empty) + { + await Browser2.OpenAsync(url, BrowserLaunchMode.External); + return; + } + + url = tag switch + { ActionItem.WebConfig => IPCUrl + "/asf-config", ActionItem.WebAddBot => IPCUrl + "/bot/new", _ => IPCUrl, diff --git a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs index 24c833a27..fa5e0199a 100644 --- a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs @@ -1,3 +1,5 @@ +using FluentAvalonia.UI.Controls; + namespace BD.WTTS.UI.ViewModels; public partial class ArchiSteamFarmExePathSettingsPageViewModel : ViewModelBase @@ -9,7 +11,7 @@ public partial class ArchiSteamFarmExePathSettingsPageViewModel : ViewModelBase public ArchiSteamFarmExePathSettingsPageViewModel() { SelectProgramPath = ReactiveCommand.Create(ASFService.Current.SelectASFProgramLocationAsync); - DownloadASF = ReactiveCommand.Create(() => + DownloadASF = ReactiveCommand.Create(async () => { if (INotificationService.Instance.IsSupportNotifyDownload) { @@ -19,8 +21,41 @@ public partial class ArchiSteamFarmExePathSettingsPageViewModel : ViewModelBase } else { - Toast.Show(ToastIcon.Error, "当前平台无法调用下载通知,请自行下载", ToastLength.Short); + var (downloadDialog, progress) = CreateDownloadDialog(); + ASFService.Current.DownloadASFAsync(progress: progress); + _ = await downloadDialog.ShowAsync(true); } }); } -} + + private static (TaskDialog DownloadDialog, IProgress Progress) CreateDownloadDialog() + { + var downloadDialog = new TaskDialog + { + Title = "下载插件", + ShowProgressBar = true, + IconSource = new SymbolIconSource { Symbol = Symbol.Download }, + SubHeader = "开始下载 ASF", + Content = "正在初始化,请稍候", + XamlRoot = AvaloniaWindowManagerImpl.GetWindowTopLevel(), + // DownloadASFAsync() 无法取消后再次开启下载 + //Buttons = [new TaskDialogButton("取消", TaskDialogStandardResult.Cancel)], + }; + downloadDialog.Opened += (_, _) => { downloadDialog.SetProgressBarState(0, TaskDialogProgressState.Normal); }; + + var progress = new Progress(); + progress.ProgressChanged += (_, value) => + { + // Value here report 1-100 + downloadDialog.Content = $"正在下载 {value}%"; + downloadDialog.SetProgressBarState(value, TaskDialogProgressState.Normal); + + if (value >= 100) + { + downloadDialog.Hide(); + } + }; + + return (downloadDialog, progress); + } +} \ No newline at end of file