From bfd6b82a95bc71f8a37a268afc90cc32b26bdfae Mon Sep 17 00:00:00 2001 From: RMBGAME Date: Wed, 18 Oct 2023 19:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20=F0=9F=90=9B=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=B4=A6=E5=8F=B7=E5=88=87=E6=8D=A2=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E5=88=87=E6=8D=A2=E5=90=8E=E4=BB=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=99=BB=E5=BD=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ref/SteamClient | 2 +- .../UI/ViewModels/SteamDetailPageViewModel.cs | 31 +-- .../UI/ViewModels/SteamTradePageViewModel.cs | 61 +++--- .../UI/ViewModels/IdleCardPageViewModel.cs | 12 ++ .../ViewModels/IdleCardPageViewModel.props.cs | 1 - .../ViewModels/IdleSteamLoginPageViewModel.cs | 4 + .../UI/Views/Pages/IdleCardPage.axaml | 199 +++++++++--------- 7 files changed, 173 insertions(+), 137 deletions(-) diff --git a/ref/SteamClient b/ref/SteamClient index 866d8ac88dd..4ff3e4bb429 160000 --- a/ref/SteamClient +++ b/ref/SteamClient @@ -1 +1 @@ -Subproject commit 866d8ac88ddd7768c4c938b20cb1a37b25076a27 +Subproject commit 4ff3e4bb429ff6d7fa80ad2bae469ae6e79e9903 diff --git a/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamDetailPageViewModel.cs b/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamDetailPageViewModel.cs index 6d83d900964..c3b70eb25a6 100644 --- a/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamDetailPageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamDetailPageViewModel.cs @@ -13,20 +13,27 @@ public class SteamDetailPageViewModel : ViewModelBase public SteamDetailPageViewModel(IAuthenticatorDTO authenticatorDto) { - if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator) + try { - SteamData = - Serializable.GetIndented(steamAuthenticator.SteamData, Serializable.JsonImplType.SystemTextJson); - RecoverCode = steamAuthenticator.RecoveryCode; - DeviceId = steamAuthenticator.DeviceId; + if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator) + { + SteamData = + Serializable.GetIndented(steamAuthenticator.SteamData, Serializable.JsonImplType.SystemTextJson); + RecoverCode = steamAuthenticator.RecoveryCode; + DeviceId = steamAuthenticator.DeviceId; - // var viewModel = new TextBoxWindowViewModel() - // { - // InputType = TextBoxWindowViewModel.TextBoxInputType.ReadOnlyText, - // Value = steamData, - // - // }; - //await IWindowManager.Instance.ShowTaskDialogAsync(viewModel, Strings.LocalAuth_ShowAuthInfo); + // var viewModel = new TextBoxWindowViewModel() + // { + // InputType = TextBoxWindowViewModel.TextBoxInputType.ReadOnlyText, + // Value = steamData, + // + // }; + //await IWindowManager.Instance.ShowTaskDialogAsync(viewModel, Strings.LocalAuth_ShowAuthInfo); + } + } + catch (Exception ex) + { + ex.LogAndShowT(); } } } \ No newline at end of file diff --git a/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamTradePageViewModel.cs b/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamTradePageViewModel.cs index 82d29fcecc4..300a9a6618e 100644 --- a/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamTradePageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.Authenticator/UI/ViewModels/SteamTradePageViewModel.cs @@ -21,37 +21,44 @@ public SteamTradePageViewModel(ref IAuthenticatorDTO authenticatorDto) ConfirmTradeCommand = ReactiveCommand.Create(ConfirmTrade); CancelTradeCommand = ReactiveCommand.Create(CancelTrade); - if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator) + try { - _steamAuthenticator = steamAuthenticator; - _steamClient = _steamAuthenticator.GetClient(ResourceService.GetCurrentCultureSteamLanguageName()); - UserNameText = _steamAuthenticator.AccountName ?? ""; - authenticatorDto.Value = _steamAuthenticator; - _ = Initialize(); - - this.WhenAnyValue(v => v.Confirmations) - .Subscribe(items => items? - .ToObservableChangeSet() - .AutoRefresh(x => x.IsSelected) - .WhenValueChanged(x => x.IsSelected) - .Subscribe(_ => - { - bool? b = null; - var count = items.Count(s => s.IsSelected); - if (!items.Any_Nullable() || count == 0) - b = false; - else if (count == items.Count) - b = true; - - if (SelectedAll != b) + if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator) + { + _steamAuthenticator = steamAuthenticator; + _steamClient = _steamAuthenticator.GetClient(ResourceService.GetCurrentCultureSteamLanguageName()); + UserNameText = _steamAuthenticator.AccountName ?? ""; + authenticatorDto.Value = _steamAuthenticator; + _ = Initialize(); + + this.WhenAnyValue(v => v.Confirmations) + .Subscribe(items => items? + .ToObservableChangeSet() + .AutoRefresh(x => x.IsSelected) + .WhenValueChanged(x => x.IsSelected) + .Subscribe(_ => { - SelectedAll = b; - } - })); + bool? b = null; + var count = items.Count(s => s.IsSelected); + if (!items.Any_Nullable() || count == 0) + b = false; + else if (count == items.Count) + b = true; + + if (SelectedAll != b) + { + SelectedAll = b; + } + })); + } + else + { + Close?.Invoke(); + } } - else + catch (Exception ex) { - Close?.Invoke(); + ex.LogAndShowT(); } } diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs index 14b3809e36d..9d8cf4fd727 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs @@ -117,6 +117,18 @@ public void ManualRunNext() private async Task LoginSteam() { + var seesion = await Ioc.Get() + .LoadSession(Path.Combine(Plugin.Instance.CacheDirectory)); + + if (seesion != null && ulong.TryParse(seesion.SteamId, out var steamid)) + { + SteamLoginState.Success = true; + SteamLoginState.SteamId = steamid; + SteamLoginState.AccessToken = seesion.AccessToken; + SteamLoginState.RefreshToken = seesion.RefreshToken; + SteamLoginState.Cookies = seesion.CookieContainer.GetAllCookies(); + } + if (!SteamLoginState.Success) { var vm = new IdleSteamLoginPageViewModel(ref SteamLoginState); diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs index 6995f615fe6..0d8355a7cb6 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs @@ -6,7 +6,6 @@ namespace BD.WTTS.UI.ViewModels; public sealed partial class IdleCardPageViewModel { - public ICommand IdleRunStartOrStop { get; } public ICommand IdleManualRunNext { get; } diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleSteamLoginPageViewModel.cs b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleSteamLoginPageViewModel.cs index db2ea834b6d..080ca818827 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleSteamLoginPageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleSteamLoginPageViewModel.cs @@ -6,6 +6,7 @@ namespace BD.WTTS.UI.ViewModels; public sealed partial class IdleSteamLoginPageViewModel : WindowViewModel { readonly ISteamAccountService Account = Ioc.Get(); + readonly ISteamSessionService SteamSession = Ioc.Get(); public SteamLoginState SteamLoginState { get; set; } @@ -49,7 +50,10 @@ private async void SteamLogin() { if (RemenberLogin) { + var session = SteamSession.RentSession(SteamLoginState.SteamId.ToString()); + if (session != null) + await SteamSession.SaveSession(session); } Toast.Show(ToastIcon.Success, Strings.Success_.Format(Strings.User_Login)); IsLoading = false; diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml index 8253844a281..adbcb22575f 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml @@ -25,49 +25,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - + + + + + + + +