This commit is contained in:
Aigio Liu
2021-05-24 17:05:31 +08:00
parent 7121e416fc
commit 251ab23db8
12 changed files with 159 additions and 89 deletions
@@ -1,4 +1,5 @@
namespace System.Extensions
// ReSharper disable once CheckNamespace
namespace System
{
public static partial class StringExtensions
{
@@ -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"*/;
}
@@ -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;
@@ -5,24 +5,11 @@
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>System.Application</RootNamespace>
<AssemblyName>Steam++.Console</AssemblyName>
<DefineConstants>WINDOWS_DESKTOP_BRIDGE;CONSOLEAPP;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) Or ('$(OS)' == 'Windows_NT' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<DefineConstants>WINDOWS;$(DefineConstants)</DefineConstants>
<DefineConstants>WINDOWS;WINDOWS_DESKTOP_BRIDGE;CONSOLEAPP;$(DefineConstants)</DefineConstants>
<ApplicationIcon>..\ST.Client.Desktop.Avalonia\Application\UI\Assets\Icon.ico</ApplicationIcon>
<!--<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>-->
<Platforms>AnyCPU;x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<!-- 注意:RuntimeIdentifier win-x86 会导致亚克力效果会丢失 -->
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
<!--<UseWindowsForms>false</UseWindowsForms>-->
<!--<UseWPF>false</UseWPF>-->
</PropertyGroup>
<PropertyGroup Condition=" $(RuntimeIdentifier.Contains(`osx`)) Or ('$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<DefineConstants>MAC;$(DefineConstants)</DefineConstants>
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition=" $(DefineConstants.Contains(`PUBLISH`)) ">
@@ -67,29 +54,10 @@
<ProjectReference Include="..\ST.Client.Desktop.Avalonia\ST.Client.Desktop.Avalonia.csproj" />
<ProjectReference Include="..\ST.Client.Desktop\ST.Client.Desktop.csproj" />
<ProjectReference Include="..\Common.CoreLib\Common.CoreLib.csproj" />
<ProjectReference Include="..\ST.Client.Desktop.Windows\ST.Client.Desktop.Windows.csproj" />
<Reference Include="Microsoft.Windows.SDK.NET">
<HintPath>..\..\references\Microsoft.Windows.SDK.NET.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) Or ('$(OS)' == 'Windows_NT' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<ProjectReference Include="..\ST.Client.Desktop.Windows\ST.Client.Desktop.Windows.csproj" />
</ItemGroup>
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`osx`)) Or ('$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<ProjectReference Include="..\ST.Client.Desktop.Mac\ST.Client.Desktop.Mac.csproj" />
</ItemGroup>
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`linux`)) Or ('$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<ProjectReference Include="..\ST.Client.Desktop.Linux\ST.Client.Desktop.Linux.csproj" />
</ItemGroup>
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) Or ('$(OS)' == 'Windows_NT' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<!--Win8.1/10的开始菜单磁贴配置-->
<None Include="..\..\Resources\AppIcon\visualelementsmanifest.xml">
<Link>Steam++.Console.VisualElementsManifest.xml</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
@@ -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<Task<IApiResponse>>? apiCall = null)
public async Task SignOutAsync(Func<Task<IApiResponse>>? 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
/// </summary>
/// <param name="phoneNumber"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 解绑账号后更新
/// </summary>
/// <param name="channel"></param>
/// <returns></returns>
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;
}
}
}
+18
View File
@@ -3421,6 +3421,15 @@ namespace System.Application.UI.Resx {
}
}
/// <summary>
/// 查找类似 确定要退出 Steam++? 的本地化字符串。
/// </summary>
public static string User_SignOutTip {
get {
return ResourceManager.GetString("User_SignOutTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 短信验证码 的本地化字符串。
/// </summary>
@@ -3484,6 +3493,15 @@ namespace System.Application.UI.Resx {
}
}
/// <summary>
/// 查找类似 解绑第三方账号关联后将无法以该第三方账号快速登录,是否确定解绑? 的本地化字符串。
/// </summary>
public static string User_UnbundleAccountTip {
get {
return ResourceManager.GetString("User_UnbundleAccountTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 使用 {0} 登录 的本地化字符串。
/// </summary>
@@ -1298,6 +1298,9 @@
<data name="User_Rememberme" xml:space="preserve">
<value>记住登录状态</value>
</data>
<data name="User_SignOutTip" xml:space="preserve">
<value>确定要退出 Steam++?</value>
</data>
<data name="User_SMSCode" xml:space="preserve">
<value>短信验证码</value>
</data>
@@ -1319,6 +1322,9 @@
<data name="User_SteamUnLoginTip" xml:space="preserve">
<value>点击Steam Logo登录</value>
</data>
<data name="User_UnbundleAccountTip" xml:space="preserve">
<value>解绑第三方账号关联后将无法以该第三方账号快速登录,是否确定解绑?</value>
</data>
<data name="User_UseFastLoginChannel_" xml:space="preserve">
<value>使用 {0} 登录</value>
</data>
@@ -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();
@@ -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);
@@ -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)
@@ -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;
}
}
}
}
@@ -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
}
}