diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml
index af3fb63be..272108938 100644
--- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml
+++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml
@@ -91,7 +91,7 @@
-->
diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/ChangeBindPhoneNumberWindow.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/ChangeBindPhoneNumberWindow.axaml
index 73fa230ae..58c9ca9d2 100644
--- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/ChangeBindPhoneNumberWindow.axaml
+++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/ChangeBindPhoneNumberWindow.axaml
@@ -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}">
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
+
+
+
diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/UserProfileWindow.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/UserProfileWindow.axaml
index 7c1ddefe3..ab8e7f2a9 100644
--- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/UserProfileWindow.axaml
+++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/UserProfileWindow.axaml
@@ -129,7 +129,7 @@
Grid.Row="3"/>
diff --git a/src/ST.Client.Desktop/Models/Settings/AuthSettings.cs b/src/ST.Client.Desktop/Models/Settings/AuthSettings.cs
deleted file mode 100644
index 79e67c541..000000000
--- a/src/ST.Client.Desktop/Models/Settings/AuthSettings.cs
+++ /dev/null
@@ -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 e)
- {
- if (e.NewValue != e.OldValue)
- {
- if (AuthSettings.IsCurrentDirectorySaveAuthData.Value)
- {
- File.WriteAllText(Path.Combine(IOPath.AppDataDirectory, Constants.AUTHDATA_FILE), e.NewValue);
- }
- }
- }
-
- ///
- /// 令牌数据(压缩存储)
- ///
- public static SerializableProperty Authenticators { get; }
- = new SerializableProperty(GetKey(), Providers.Local) { AutoSave = true };
-
- ///
- /// 是否将令牌数据存储在程序路径下
- ///
- public static SerializableProperty IsCurrentDirectorySaveAuthData { get; }
- = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true };
-
- private static string GetKey([CallerMemberName] string propertyName = "")
- {
- return nameof(AuthSettings) + "." + propertyName;
- }
- }
-}
diff --git a/src/ST.Client.Desktop/Services/Mvvm/UserService.cs b/src/ST.Client.Desktop/Services/Mvvm/UserService.cs
index 0fe6b0535..5bcb576ba 100644
--- a/src/ST.Client.Desktop/Services/Mvvm/UserService.cs
+++ b/src/ST.Client.Desktop/Services/Mvvm/UserService.cs
@@ -150,15 +150,41 @@ namespace System.Application.Services
}
bool _HasPhoneNumber;
+ ///
+ /// 当前登录用户是否有手机号码
+ ///
public bool HasPhoneNumber
{
get => _HasPhoneNumber;
set => this.RaiseAndSetIfChanged(ref _HasPhoneNumber, value);
}
- public async Task RefreshUserAsync()
+ string _PhoneNumber = string.Empty;
+ ///
+ /// 用于 UI 显示的当前登录用户的手机号码(隐藏中间四位)
+ ///
+ 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);
}
///
@@ -187,7 +219,7 @@ namespace System.Application.Services
if (user == null) return;
user.PhoneNumber = phoneNumber;
await userManager.SetCurrentUserAsync(user);
- HasPhoneNumber = true;
+ RefreshCurrentUser(user);
}
///
@@ -217,7 +249,7 @@ namespace System.Application.Services
return;
}
await userManager.SetCurrentUserInfoAsync(user, true);
- User = user;
+ await RefreshUserAsync(user);
}
///
@@ -248,7 +280,7 @@ namespace System.Application.Services
return;
}
await userManager.SetCurrentUserInfoAsync(user, true);
- User = user;
+ await RefreshUserAsync(user);
}
}
}
\ No newline at end of file
diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs
index b28efdfd1..6c153e50f 100644
--- a/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs
+++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/ChangeBindPhoneNumberWindowViewModel.cs
@@ -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().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
{
diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs
index 94743b621..4c9a90045 100644
--- a/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs
+++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.cs
@@ -35,8 +35,6 @@ namespace System.Application.UI.ViewModels
if (userInfoSource.AreaId.HasValue) this.SetAreaId(userInfoSource.AreaId.Value);
userInfoSource = Serializable.DMP(userInfoValue) ?? throw new ArgumentNullException(nameof(userInfoSource));
- _CurrentPhoneNumber = await userManager.GetCurrentUserPhoneNumberAsync();
- if (string.IsNullOrWhiteSpace(_CurrentPhoneNumber)) _CurrentPhoneNumber = AppResources.Unbound;
// IsModifySubscribe
void SubscribeOnNext(T value, Action 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
{