From 251ab23db8bb00a15e48b55e123fa4a5718ddb13 Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Mon, 24 May 2021 17:05:22 +0800 Subject: [PATCH] fix --- .../Extensions/StringExtensions.Enhance.cs | 3 +- .../Properties/ThisAssembly.Version.cs | 2 +- .../DesktopBridgeHelper2.cs | 9 +++ ...T.Client.Desktop.Console.App.Bridge.csproj | 38 +----------- .../Services/Mvvm/UserService.cs | 58 +++++++++++++++++-- .../UI/Resx/AppResources.Designer.cs | 18 ++++++ .../UI/Resx/AppResources.resx | 6 ++ .../Windows/BindPhoneNumberWindowViewModel.cs | 2 +- .../ChangeBindPhoneNumberWindowViewModel.cs | 2 +- .../Windows/LoginOrRegisterWindowViewModel.cs | 23 +------- .../Windows/UserProfileWindowViewModel.cs | 33 +++++------ .../Models/UserInfoDTO.cs | 54 +++++++++++++++-- 12 files changed, 159 insertions(+), 89 deletions(-) diff --git a/src/Common.CoreLib/Extensions/StringExtensions.Enhance.cs b/src/Common.CoreLib/Extensions/StringExtensions.Enhance.cs index 1de4ccfa6..800830938 100644 --- a/src/Common.CoreLib/Extensions/StringExtensions.Enhance.cs +++ b/src/Common.CoreLib/Extensions/StringExtensions.Enhance.cs @@ -1,4 +1,5 @@ -namespace System.Extensions +// ReSharper disable once CheckNamespace +namespace System { public static partial class StringExtensions { diff --git a/src/Common.CoreLib/Properties/ThisAssembly.Version.cs b/src/Common.CoreLib/Properties/ThisAssembly.Version.cs index 2082efbaf..aa8393daa 100644 --- a/src/Common.CoreLib/Properties/ThisAssembly.Version.cs +++ b/src/Common.CoreLib/Properties/ThisAssembly.Version.cs @@ -2,7 +2,7 @@ namespace System.Properties { static partial class ThisAssembly { - public const string Version = "2.2.1"; + public const string Version = "2.3.0"; public const string InfoVersion = Version /*+ "-beta"*/; } diff --git a/src/ST.Client.Desktop.Avalonia.App.Bridge/DesktopBridgeHelper2.cs b/src/ST.Client.Desktop.Avalonia.App.Bridge/DesktopBridgeHelper2.cs index b9db23917..b7f0e5a47 100644 --- a/src/ST.Client.Desktop.Avalonia.App.Bridge/DesktopBridgeHelper2.cs +++ b/src/ST.Client.Desktop.Avalonia.App.Bridge/DesktopBridgeHelper2.cs @@ -1,4 +1,5 @@ using System.ApplicationModel; +using Windows.ApplicationModel; // ReSharper disable once CheckNamespace namespace System.Application @@ -10,6 +11,14 @@ namespace System.Application if (DI.Platform != Platform.Windows) return false; var osVer = Environment.OSVersion.Version; if (osVer.Major != 10 || osVer.Build < 17763) return false; + try + { + if (string.IsNullOrWhiteSpace(Package.Current.Id.Name)) return false; + } + catch + { + return false; + } DesktopBridgeHelper.IsDesktopBridge = true; FileSystemDesktopBridge.InitFileSystem(); return true; diff --git a/src/ST.Client.Desktop.Console.App.Bridge/ST.Client.Desktop.Console.App.Bridge.csproj b/src/ST.Client.Desktop.Console.App.Bridge/ST.Client.Desktop.Console.App.Bridge.csproj index 5fc0a92e0..bb6512abb 100644 --- a/src/ST.Client.Desktop.Console.App.Bridge/ST.Client.Desktop.Console.App.Bridge.csproj +++ b/src/ST.Client.Desktop.Console.App.Bridge/ST.Client.Desktop.Console.App.Bridge.csproj @@ -5,24 +5,11 @@ net6.0 System.Application Steam++.Console - WINDOWS_DESKTOP_BRIDGE;CONSOLEAPP;$(DefineConstants) - - - - WINDOWS;$(DefineConstants) + WINDOWS;WINDOWS_DESKTOP_BRIDGE;CONSOLEAPP;$(DefineConstants) ..\ST.Client.Desktop.Avalonia\Application\UI\Assets\Icon.ico - AnyCPU;x86 x86 - - win7-x86 - - - - - - MAC;$(DefineConstants) + win10-x86 @@ -67,29 +54,10 @@ + ..\..\references\Microsoft.Windows.SDK.NET.dll - - - - - - - - - - - - - - - - Steam++.Console.VisualElementsManifest.xml - PreserveNewest - - - diff --git a/src/ST.Client.Desktop/Services/Mvvm/UserService.cs b/src/ST.Client.Desktop/Services/Mvvm/UserService.cs index 7c4321eff..b405ebea8 100644 --- a/src/ST.Client.Desktop/Services/Mvvm/UserService.cs +++ b/src/ST.Client.Desktop/Services/Mvvm/UserService.cs @@ -1,7 +1,10 @@ using ReactiveUI; using System.Application.Models; +using System.Application.UI.Resx; using System.Application.UI.ViewModels; +using System.Properties; using System.Threading.Tasks; +using System.Windows; namespace System.Application.Services { @@ -35,7 +38,7 @@ namespace System.Application.Services } } - public async Task SignOutAsync(Func>? apiCall = null) + public async Task SignOutAsync(Func>? apiCall = null, string? message = null) { if (User == null) return; if (apiCall != null) @@ -48,16 +51,27 @@ namespace System.Application.Services } await SignOutUserManagerAsync(); await RefreshUserAsync(); + if (message != null) + { + Toast.Show(message); + } } public async void SignOut() { - await SignOutAsync(ICloudServiceClient.Instance.Manage.SignOut); + if (!IsAuthenticated) return; + var r = await MessageBoxCompat.ShowAsync(AppResources.User_SignOutTip, ThisAssembly.AssemblyTrademark, MessageBoxButtonCompat.OKCancel); + if (r == MessageBoxResultCompat.OK) + { + await SignOutAsync(ICloudServiceClient.Instance.Manage.SignOut); + } } public async void DelAccount() { - await SignOutAsync(ICloudServiceClient.Instance.Manage.DeleteAccount); + if (!IsAuthenticated) return; + var msg = AppResources.Success_.Format(AppResources.DelAccount); + await SignOutAsync(ICloudServiceClient.Instance.Manage.DeleteAccount, msg); } public async Task SignOutUserManagerAsync() @@ -153,8 +167,10 @@ namespace System.Application.Services CurrentSteamUser.AvatarStream = IHttpService.Instance.GetImageAsync(CurrentSteamUser.AvatarFull, ImageChannelType.SteamAvatars); AvaterPath = CircleImageStream.Convert(await CurrentSteamUser.AvatarStream); } - - //AvaterPath = GetAvaterPath(User); + else + { + AvaterPath = DefaultAvaterPath; + } var userInfo = await userManager.GetCurrentUserAsync(); HasPhoneNumber = !string.IsNullOrWhiteSpace(userInfo?.PhoneNumber); @@ -165,7 +181,7 @@ namespace System.Application.Services /// /// /// - public async Task UpdateCurrentUserPhoneNumber(string phoneNumber) + public async Task UpdateCurrentUserPhoneNumberAsync(string phoneNumber) { var user = await userManager.GetCurrentUserAsync(); if (user == null) return; @@ -173,5 +189,35 @@ namespace System.Application.Services await userManager.SetCurrentUserAsync(user); HasPhoneNumber = true; } + + /// + /// 解绑账号后更新 + /// + /// + /// + public async Task UnbundleAccountAfterUpdateAsync(FastLoginChannel channel) + { + var user = await userManager.GetCurrentUserInfoAsync(); + if (user == null) return; + switch (channel) + { + case FastLoginChannel.Steam: + user.SteamAccountId = null; + break; + case FastLoginChannel.Microsoft: + user.MicrosoftAccountEmail = null; + break; + case FastLoginChannel.QQ: + user.QQAccountNumber = null; + break; + case FastLoginChannel.Apple: + user.AppleAccountEmail = null; + break; + default: + return; + } + await userManager.SetCurrentUserInfoAsync(user, true); + User = user; + } } } \ No newline at end of file diff --git a/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs b/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs index 696f6c0c1..ad143b69a 100644 --- a/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs +++ b/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs @@ -3421,6 +3421,15 @@ namespace System.Application.UI.Resx { } } + /// + /// 查找类似 确定要退出 Steam++? 的本地化字符串。 + /// + public static string User_SignOutTip { + get { + return ResourceManager.GetString("User_SignOutTip", resourceCulture); + } + } + /// /// 查找类似 短信验证码 的本地化字符串。 /// @@ -3484,6 +3493,15 @@ namespace System.Application.UI.Resx { } } + /// + /// 查找类似 解绑第三方账号关联后将无法以该第三方账号快速登录,是否确定解绑? 的本地化字符串。 + /// + public static string User_UnbundleAccountTip { + get { + return ResourceManager.GetString("User_UnbundleAccountTip", resourceCulture); + } + } + /// /// 查找类似 使用 {0} 登录 的本地化字符串。 /// diff --git a/src/ST.Client.Desktop/UI/Resx/AppResources.resx b/src/ST.Client.Desktop/UI/Resx/AppResources.resx index b3620872e..46ca5b720 100644 --- a/src/ST.Client.Desktop/UI/Resx/AppResources.resx +++ b/src/ST.Client.Desktop/UI/Resx/AppResources.resx @@ -1298,6 +1298,9 @@ 记住登录状态 + + 确定要退出 Steam++? + 短信验证码 @@ -1319,6 +1322,9 @@ 点击Steam Logo登录 + + 解绑第三方账号关联后将无法以该第三方账号快速登录,是否确定解绑? + 使用 {0} 登录 diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/BindPhoneNumberWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/BindPhoneNumberWindowViewModel.cs index f514e0539..a8b323d80 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/BindPhoneNumberWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/BindPhoneNumberWindowViewModel.cs @@ -79,7 +79,7 @@ namespace System.Application.UI.ViewModels if (response.IsSuccess) { - await UserService.Current.UpdateCurrentUserPhoneNumber(request.PhoneNumber!); + await UserService.Current.UpdateCurrentUserPhoneNumberAsync(request.PhoneNumber!); var msg = AppResources.Success_.Format(AppResources.User_BindPhoneNum); Toast.Show(msg); Close?.Invoke(); diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs index 4babef7c9..b28efdfd1 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs @@ -235,7 +235,7 @@ namespace System.Application.UI.ViewModels var response = await ICloudServiceClient.Instance.Manage.ChangeBindPhoneNumber(request); if (response.IsSuccess) { - await UserService.Current.UpdateCurrentUserPhoneNumber(request.PhoneNumber!); + await UserService.Current.UpdateCurrentUserPhoneNumberAsync(request.PhoneNumber!); IsComplete = true; var msg = AppResources.Success_.Format(AppResources.User_ChangePhoneNum); Toast.Show(msg); diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs index 84bba82ed..0a7c48897 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs @@ -211,30 +211,11 @@ namespace System.Application.UI.ViewModels public FastLoginChannel[] FastLoginChannels { get; } = new[] { FastLoginChannel.Steam, - FastLoginChannel.QQ, FastLoginChannel.Xbox, - FastLoginChannel.Apple, + //FastLoginChannel.Apple, + //FastLoginChannel.QQ, }; - //int _FastLoginChannelsSelectedIndex = -1; - //public int FastLoginChannelsSelectedIndex - //{ - // get => _FastLoginChannelsSelectedIndex; - // set - // { - // if (value > -1 && value < FastLoginChannels.Length) - // { - // var item = FastLoginChannels[value].ToString(); - // if (FastLogin.CanExecute(item)) - // { - // FastLogin.Execute(item); - // } - // } - // this.RaiseAndSetIfChanged(ref _FastLoginChannelsSelectedIndex, value); - // this.RaiseAndSetIfChanged(ref _FastLoginChannelsSelectedIndex, -1); - // } - //} - protected override void Dispose(bool disposing) { if (disposing) diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs index 031e5e2c7..1b946ff5a 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Linq.Expressions; using System.Properties; using System.Threading.Tasks; +using System.Windows; using System.Windows.Input; namespace System.Application.UI.ViewModels @@ -194,26 +195,22 @@ namespace System.Application.UI.ViewModels if (IsLoading) return; - IsLoading = true; - - var response = await ICloudServiceClient.Instance.Manage.UnbundleAccount(channel); - - if (response.IsSuccess) + var r = await MessageBoxCompat.ShowAsync(AppResources.User_UnbundleAccountTip, ThisAssembly.AssemblyTrademark, MessageBoxButtonCompat.OKCancel); + if (r == MessageBoxResultCompat.OK) { - switch (channel) - { - case FastLoginChannel.Steam: - break; - case FastLoginChannel.Microsoft: - break; - case FastLoginChannel.QQ: - break; - case FastLoginChannel.Apple: - break; - } - } + IsLoading = true; - IsLoading = false; + var response = await ICloudServiceClient.Instance.Manage.UnbundleAccount(channel); + + if (response.IsSuccess) + { + await UserService.Current.UnbundleAccountAfterUpdateAsync(channel); + var msg = AppResources.Success_.Format(AppResources.Unbundling); + Toast.Show(msg); + } + + IsLoading = false; + } } } } \ No newline at end of file diff --git a/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs b/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs index 1fdf0d12a..9c1ce6f4e 100644 --- a/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs +++ b/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs @@ -1,3 +1,6 @@ +#if MVVM_VM +using ReactiveUI; +#endif using System.Application.Columns; using System.Diagnostics; using MPIgnore = MessagePack.IgnoreMemberAttribute; @@ -12,7 +15,12 @@ namespace System.Application.Models { [MPObject] [DebuggerDisplay("{DebuggerDisplay,nq}")] - public sealed class UserInfoDTO : IUserDTO, IBirthDateTimeZone + public sealed class UserInfoDTO : + +#if MVVM_VM + ReactiveObject, +#endif + IUserDTO, IBirthDateTimeZone { string DebuggerDisplay => IUserDTO.GetDebuggerDisplay(this); @@ -74,7 +82,16 @@ namespace System.Application.Models [MPKey(8)] [N_JsonProperty("8")] [S_JsonProperty("8")] - public long? SteamAccountId { get; set; } + public long? SteamAccountId +#if MVVM_VM + { + get => _SteamAccountId; + set => this.RaiseAndSetIfChanged(ref _SteamAccountId, value); + } + long? _SteamAccountId; +#else + { get; set; } +#endif [MPKey(9)] [N_JsonProperty("9")] @@ -125,16 +142,43 @@ namespace System.Application.Models [MPKey(14)] [N_JsonProperty("14")] [S_JsonProperty("14")] - public string? MicrosoftAccountEmail { get; set; } + public string? MicrosoftAccountEmail +#if MVVM_VM + { + get => _MicrosoftAccountEmail; + set => this.RaiseAndSetIfChanged(ref _MicrosoftAccountEmail, value); + } + string? _MicrosoftAccountEmail; +#else + { get; set; } +#endif [MPKey(15)] [N_JsonProperty("15")] [S_JsonProperty("15")] - public long? QQAccountNumber { get; set; } + public long? QQAccountNumber +#if MVVM_VM + { + get => _QQAccountNumber; + set => this.RaiseAndSetIfChanged(ref _QQAccountNumber, value); + } + long? _QQAccountNumber; +#else + { get; set; } +#endif [MPKey(16)] [N_JsonProperty("16")] [S_JsonProperty("16")] - public string? AppleAccountEmail { get; set; } + public string? AppleAccountEmail +#if MVVM_VM + { + get => _AppleAccountEmail; + set => this.RaiseAndSetIfChanged(ref _AppleAccountEmail, value); + } + string? _AppleAccountEmail; +#else + { get; set; } +#endif } } \ No newline at end of file