mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 05:56:52 +08:00
修复 UI 通知
This commit is contained in:
@@ -91,7 +91,7 @@
|
||||
</Image.Clip>-->
|
||||
</Image>
|
||||
<TextBlock
|
||||
Text="{ReflectionBinding Path=User.NickName,Source={x:Static service:UserService.Current}}"
|
||||
Text="{ReflectionBinding Path=User.NickName,Mode=OneWay,Source={x:Static service:UserService.Current}}"
|
||||
FontSize="14"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="{DynamicResource HighlightForegroundBrushKey}"></TextBlock>
|
||||
|
||||
+52
-51
@@ -10,6 +10,7 @@
|
||||
x:Class="System.Application.UI.Views.Windows.ChangeBindPhoneNumberWindow"
|
||||
xmlns:controls="clr-namespace:System.Application.UI.Views.Controls"
|
||||
xmlns:resx="clr-namespace:System.Application.UI.Resx;assembly=System.Application.SteamTools.Client.Desktop"
|
||||
xmlns:service="clr-namespace:System.Application.Services;assembly=System.Application.SteamTools.Client.Desktop"
|
||||
xmlns:ccl_services="clr-namespace:System.Application.Services;assembly=System.Application.SteamTools.Client"
|
||||
xmlns:vm="clr-namespace:System.Application.UI.ViewModels;assembly=System.Application.SteamTools.Client.Desktop"
|
||||
xmlns:ms="clr-namespace:System.Application.Models.Settings;assembly=System.Application.SteamTools.Client.Desktop"
|
||||
@@ -22,68 +23,68 @@
|
||||
x:DataType="vm:ChangeBindPhoneNumberWindowViewModel"
|
||||
x:CompileBindings="True"
|
||||
Title="{Binding Title}">
|
||||
<Panel>
|
||||
<controls:TitleBar />
|
||||
<Panel Margin="{StaticResource UnifyTitleBarAfterContentMargin}">
|
||||
<controls:ProgressRing IsIndeterminate="True" HorizontalAlignment="Stretch" Height="100" Width="100" IsVisible="{Binding IsLoading}" />
|
||||
<!--<Grid RowDefinitions="*,Auto" IsVisible="{Binding !IsLoading}">-->
|
||||
<StackPanel VerticalAlignment="Center" Spacing="10" IsVisible="{Binding !IsLoading}">
|
||||
<Panel>
|
||||
<controls:TitleBar />
|
||||
<Panel Margin="{StaticResource UnifyTitleBarAfterContentMargin}">
|
||||
<controls:ProgressRing IsIndeterminate="True" HorizontalAlignment="Stretch" Height="100" Width="100" IsVisible="{Binding IsLoading}" />
|
||||
<!--<Grid RowDefinitions="*,Auto" IsVisible="{Binding !IsLoading}">-->
|
||||
<StackPanel VerticalAlignment="Center" Spacing="10" IsVisible="{Binding !IsLoading}">
|
||||
|
||||
<TextBox Watermark="{Binding CurrentPhoneNumber,Mode=OneWay}" IsReadOnly="True" Focusable="False" />
|
||||
<TextBox Watermark="{ReflectionBinding Path=PhoneNumber,Mode=OneWay,Source={x:Static service:UserService.Current}}" IsReadOnly="True" Focusable="False" />
|
||||
|
||||
<Panel>
|
||||
<TextBox
|
||||
x:Name="TbSmsCodeValidation"
|
||||
Text="{Binding SmsCodeValidation}"
|
||||
Watermark="{ReflectionBinding Path=Res.User_SMSCode,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
MaxLength="{ReflectionBinding Path=SMS_CAPTCHA,Mode=OneTime,Source={x:Static ccl_services:InputLengthConstants.Current}}"
|
||||
IsEnabled="{Binding CurrentStepIsValidation}" />
|
||||
<Border HorizontalAlignment="Right" Cursor="Hand">
|
||||
<Button Classes="CodeButton"
|
||||
Content="{Binding BtnSendSmsCodeTextValidation}"
|
||||
Command="{ReflectionBinding SendSms}"
|
||||
IsEnabled="{Binding !IsUnTimeLimitValidation}" />
|
||||
</Border>
|
||||
</Panel>
|
||||
<Panel>
|
||||
<TextBox
|
||||
x:Name="TbSmsCodeValidation"
|
||||
Text="{Binding SmsCodeValidation}"
|
||||
Watermark="{ReflectionBinding Path=Res.User_SMSCode,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
MaxLength="{ReflectionBinding Path=SMS_CAPTCHA,Mode=OneTime,Source={x:Static ccl_services:InputLengthConstants.Current}}"
|
||||
IsEnabled="{Binding CurrentStepIsValidation}" />
|
||||
<Border HorizontalAlignment="Right" Cursor="Hand">
|
||||
<Button Classes="CodeButton"
|
||||
Content="{Binding BtnSendSmsCodeTextValidation}"
|
||||
Command="{ReflectionBinding SendSms}"
|
||||
IsEnabled="{Binding !IsUnTimeLimitValidation}" />
|
||||
</Border>
|
||||
</Panel>
|
||||
|
||||
<TextBox
|
||||
x:Name="TbPhoneNumber"
|
||||
Text="{Binding PhoneNumber}"
|
||||
Watermark="{ReflectionBinding Path=Res.User_NewPhone,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
IsEnabled="{Binding CurrentStepIsValidation}"
|
||||
MaxLength="{ReflectionBinding Path=PhoneNumber,Mode=OneTime,Source={x:Static ccl_services:InputLengthConstants.Current}}" />
|
||||
<TextBox
|
||||
x:Name="TbPhoneNumber"
|
||||
Text="{Binding PhoneNumber}"
|
||||
Watermark="{ReflectionBinding Path=Res.User_NewPhone,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
IsEnabled="{Binding CurrentStepIsValidation}"
|
||||
MaxLength="{ReflectionBinding Path=PhoneNumber,Mode=OneTime,Source={x:Static ccl_services:InputLengthConstants.Current}}" />
|
||||
|
||||
<Panel>
|
||||
<TextBox
|
||||
x:Name="TbSmsCodeNew"
|
||||
Text="{Binding SmsCodeNew}"
|
||||
Watermark="{ReflectionBinding Path=Res.User_SMSCode,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
IsEnabled="{Binding CurrentStepIsNew}"
|
||||
MaxLength="{ReflectionBinding Path=SMS_CAPTCHA,Mode=OneTime,Source={x:Static ccl_services:InputLengthConstants.Current}}" />
|
||||
<Border HorizontalAlignment="Right" Cursor="Hand">
|
||||
<Button Classes="CodeButton"
|
||||
Content="{Binding BtnSendSmsCodeTextNew}"
|
||||
Command="{ReflectionBinding SendSms}"
|
||||
IsEnabled="{Binding !IsUnTimeLimitNew}" />
|
||||
</Border>
|
||||
</Panel>
|
||||
<Panel>
|
||||
<TextBox
|
||||
x:Name="TbSmsCodeNew"
|
||||
Text="{Binding SmsCodeNew}"
|
||||
Watermark="{ReflectionBinding Path=Res.User_SMSCode,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
IsEnabled="{Binding CurrentStepIsNew}"
|
||||
MaxLength="{ReflectionBinding Path=SMS_CAPTCHA,Mode=OneTime,Source={x:Static ccl_services:InputLengthConstants.Current}}" />
|
||||
<Border HorizontalAlignment="Right" Cursor="Hand">
|
||||
<Button Classes="CodeButton"
|
||||
Content="{Binding BtnSendSmsCodeTextNew}"
|
||||
Command="{ReflectionBinding SendSms}"
|
||||
IsEnabled="{Binding !IsUnTimeLimitNew}" />
|
||||
</Border>
|
||||
</Panel>
|
||||
|
||||
<Button Classes="action"
|
||||
Content="{Binding BtnSubmitText}"
|
||||
Command="{ReflectionBinding Submit}"
|
||||
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" />
|
||||
<Button Classes="action"
|
||||
Content="{Binding BtnSubmitText}"
|
||||
Command="{ReflectionBinding Submit}"
|
||||
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" />
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<!--<StackPanel Grid.Row="1">
|
||||
<!--<StackPanel Grid.Row="1">
|
||||
<Button
|
||||
HorizontalAlignment="Center" HorizontalContentAlignment="Center" Background="Transparent" BorderThickness="0" Cursor="Hand">
|
||||
<TextBlock Text="遇到问题?"></TextBlock>
|
||||
</Button>
|
||||
</StackPanel>-->
|
||||
<!--</Grid>-->
|
||||
</Panel>
|
||||
<!--Toast-->
|
||||
<controls:ToastMessage />
|
||||
<!--</Grid>-->
|
||||
</Panel>
|
||||
<!--Toast-->
|
||||
<controls:ToastMessage />
|
||||
</Panel>
|
||||
</Window>
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
Grid.Row="3"/>
|
||||
<TextBox IsReadOnly="True"
|
||||
Focusable="False"
|
||||
Watermark="{Binding CurrentPhoneNumber,Mode=OneWay}"
|
||||
Watermark="{ReflectionBinding Path=PhoneNumber,Mode=OneWay,Source={x:Static service:UserService.Current}}"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
MaxLength="{ReflectionBinding Path=PhoneNumber,Mode=OneTime,Source={x:Static ccl_services:InputLengthConstants.Current}}"/>
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Application.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Application.Models.Settings
|
||||
{
|
||||
public static class AuthSettings
|
||||
{
|
||||
static AuthSettings()
|
||||
{
|
||||
Authenticators.ValueChanged += Authenticators_ValueChanged;
|
||||
}
|
||||
|
||||
private static void Authenticators_ValueChanged(object sender, ValueChangedEventArgs<string> e)
|
||||
{
|
||||
if (e.NewValue != e.OldValue)
|
||||
{
|
||||
if (AuthSettings.IsCurrentDirectorySaveAuthData.Value)
|
||||
{
|
||||
File.WriteAllText(Path.Combine(IOPath.AppDataDirectory, Constants.AUTHDATA_FILE), e.NewValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 令牌数据(压缩存储)
|
||||
/// </summary>
|
||||
public static SerializableProperty<string> Authenticators { get; }
|
||||
= new SerializableProperty<string>(GetKey(), Providers.Local) { AutoSave = true };
|
||||
|
||||
/// <summary>
|
||||
/// 是否将令牌数据存储在程序路径下
|
||||
/// </summary>
|
||||
public static SerializableProperty<bool> IsCurrentDirectorySaveAuthData { get; }
|
||||
= new SerializableProperty<bool>(GetKey(), Providers.Local, false) { AutoSave = true };
|
||||
|
||||
private static string GetKey([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
return nameof(AuthSettings) + "." + propertyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,15 +150,41 @@ namespace System.Application.Services
|
||||
}
|
||||
|
||||
bool _HasPhoneNumber;
|
||||
/// <summary>
|
||||
/// 当前登录用户是否有手机号码
|
||||
/// </summary>
|
||||
public bool HasPhoneNumber
|
||||
{
|
||||
get => _HasPhoneNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref _HasPhoneNumber, value);
|
||||
}
|
||||
|
||||
public async Task RefreshUserAsync()
|
||||
string _PhoneNumber = string.Empty;
|
||||
/// <summary>
|
||||
/// 用于 UI 显示的当前登录用户的手机号码(隐藏中间四位)
|
||||
/// </summary>
|
||||
public string PhoneNumber
|
||||
{
|
||||
User = await userManager.GetCurrentUserInfoAsync();
|
||||
get => _PhoneNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref _PhoneNumber, value);
|
||||
}
|
||||
|
||||
static string GetCurrentUserPhoneNumber(CurrentUser? user, bool notHideMiddleFour = false)
|
||||
{
|
||||
var phone_number = user?.PhoneNumber;
|
||||
if (string.IsNullOrWhiteSpace(phone_number)) return AppResources.Unbound;
|
||||
return notHideMiddleFour ? phone_number : PhoneNumberHelper.ToStringHideMiddleFour(phone_number);
|
||||
}
|
||||
|
||||
public void RefreshCurrentUser(CurrentUser? currentUser)
|
||||
{
|
||||
PhoneNumber = GetCurrentUserPhoneNumber(currentUser);
|
||||
HasPhoneNumber = !string.IsNullOrWhiteSpace(currentUser?.PhoneNumber);
|
||||
}
|
||||
|
||||
public async Task RefreshUserAsync(UserInfoDTO? user)
|
||||
{
|
||||
User = user;
|
||||
this.RaisePropertyChanged(nameof(IsAuthenticated));
|
||||
|
||||
if (User != null && User.SteamAccountId.HasValue)
|
||||
@@ -172,8 +198,14 @@ namespace System.Application.Services
|
||||
AvaterPath = DefaultAvaterPath;
|
||||
}
|
||||
|
||||
var userInfo = await userManager.GetCurrentUserAsync();
|
||||
HasPhoneNumber = !string.IsNullOrWhiteSpace(userInfo?.PhoneNumber);
|
||||
var currentUser = await userManager.GetCurrentUserAsync();
|
||||
RefreshCurrentUser(currentUser);
|
||||
}
|
||||
|
||||
public async Task RefreshUserAsync()
|
||||
{
|
||||
var user = await userManager.GetCurrentUserInfoAsync();
|
||||
await RefreshUserAsync(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -187,7 +219,7 @@ namespace System.Application.Services
|
||||
if (user == null) return;
|
||||
user.PhoneNumber = phoneNumber;
|
||||
await userManager.SetCurrentUserAsync(user);
|
||||
HasPhoneNumber = true;
|
||||
RefreshCurrentUser(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -217,7 +249,7 @@ namespace System.Application.Services
|
||||
return;
|
||||
}
|
||||
await userManager.SetCurrentUserInfoAsync(user, true);
|
||||
User = user;
|
||||
await RefreshUserAsync(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -248,7 +280,7 @@ namespace System.Application.Services
|
||||
return;
|
||||
}
|
||||
await userManager.SetCurrentUserInfoAsync(user, true);
|
||||
User = user;
|
||||
await RefreshUserAsync(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,6 @@ namespace System.Application.UI.ViewModels
|
||||
{ Step.Validation, new SendSmsUIViewModelValidation(this) },
|
||||
{ Step.New, new SendSmsUIViewModelNew(this) },
|
||||
};
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public async void Initialize()
|
||||
{
|
||||
CurrentPhoneNumber = await DI.Get<IUserManager>().GetCurrentUserPhoneNumberAsync();
|
||||
}
|
||||
|
||||
bool _IsLoading;
|
||||
@@ -36,13 +30,6 @@ namespace System.Application.UI.ViewModels
|
||||
set => this.RaiseAndSetIfChanged(ref _IsLoading, value);
|
||||
}
|
||||
|
||||
string? _CurrentPhoneNumber;
|
||||
public string? CurrentPhoneNumber
|
||||
{
|
||||
get => _CurrentPhoneNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref _CurrentPhoneNumber, value);
|
||||
}
|
||||
|
||||
string? _SmsCodeValidation;
|
||||
public string? SmsCodeValidation
|
||||
{
|
||||
|
||||
@@ -35,8 +35,6 @@ namespace System.Application.UI.ViewModels
|
||||
if (userInfoSource.AreaId.HasValue) this.SetAreaId(userInfoSource.AreaId.Value);
|
||||
|
||||
userInfoSource = Serializable.DMP<UserInfoDTO>(userInfoValue) ?? throw new ArgumentNullException(nameof(userInfoSource));
|
||||
_CurrentPhoneNumber = await userManager.GetCurrentUserPhoneNumberAsync();
|
||||
if (string.IsNullOrWhiteSpace(_CurrentPhoneNumber)) _CurrentPhoneNumber = AppResources.Unbound;
|
||||
|
||||
// IsModifySubscribe
|
||||
void SubscribeOnNext<T>(T value, Action<T> onNext)
|
||||
@@ -97,13 +95,6 @@ namespace System.Application.UI.ViewModels
|
||||
set => this.RaiseAndSetIfChanged(ref _NickName, value);
|
||||
}
|
||||
|
||||
string? _CurrentPhoneNumber;
|
||||
public string? CurrentPhoneNumber
|
||||
{
|
||||
get => _CurrentPhoneNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref _CurrentPhoneNumber, value);
|
||||
}
|
||||
|
||||
Gender _Gender;
|
||||
public Gender Gender
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user