From 953f62b11e0bd6d8a7782884ccb288ecc2924f07 Mon Sep 17 00:00:00 2001 From: JWJUN233233 <1306334428@qq.com> Date: Wed, 5 Apr 2023 00:53:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E5=B1=8E=E5=B1=B1=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=20=20Fix#65?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WonderLab/MainWindow.axaml.cs | 2 +- .../Modules/Models/UserViewDataModels.cs | 4 +- WonderLab/ViewModels/UsersViewModel.cs | 27 +++++------ WonderLab/Views/UsersView.axaml | 13 +++--- WonderLab/Views/UsersView.axaml.cs | 45 ++++++++++++++----- 5 files changed, 55 insertions(+), 36 deletions(-) diff --git a/WonderLab/MainWindow.axaml.cs b/WonderLab/MainWindow.axaml.cs index 6e42c40..595fd20 100644 --- a/WonderLab/MainWindow.axaml.cs +++ b/WonderLab/MainWindow.axaml.cs @@ -510,7 +510,7 @@ public async void AppRunAnimaction() { await Task.Run(() => { - UsersView.ViewModel.GetSaveUserInfo(); + UsersView.ViewModel.GetSavedUserInfo(); }); await Task.Delay(2500); cover.Opacity= 0; diff --git a/WonderLab/Modules/Models/UserViewDataModels.cs b/WonderLab/Modules/Models/UserViewDataModels.cs index 23121fa..dd8cf4b 100644 --- a/WonderLab/Modules/Models/UserViewDataModels.cs +++ b/WonderLab/Modules/Models/UserViewDataModels.cs @@ -40,8 +40,8 @@ public UserModels(UserDataModels user) } public UserModels Current => this; - - public string Name { get; set; } + public string _Name; + public string Name { get => _Name; set => _Name = value; } public string Jvm { get; set; } diff --git a/WonderLab/ViewModels/UsersViewModel.cs b/WonderLab/ViewModels/UsersViewModel.cs index 5ac57ad..570e81f 100644 --- a/WonderLab/ViewModels/UsersViewModel.cs +++ b/WonderLab/ViewModels/UsersViewModel.cs @@ -1,3 +1,4 @@ +using DynamicData; using FluentAvalonia.UI.Controls; using MinecaftOAuth.Authenticator; using System; @@ -19,6 +20,7 @@ namespace WonderLab.ViewModels //Binding public partial class UsersViewModel : ViewModelBase { + public string UserNameText { get => _UserNameText; set => RaiseAndSetIfChanged(ref _UserNameText, value); } public string SelectedAuthenticator { get => _SelectedAuthenticator; set => RaiseAndSetIfChanged(ref _SelectedAuthenticator, value); } public string UrlTextBoxText { get => _UrlTextBoxText; set => RaiseAndSetIfChanged(ref _UrlTextBoxText, value); } @@ -57,10 +59,10 @@ public partial class UsersViewModel : ViewModelBase //Methods partial class UsersViewModel { - //public UsersViewModel() => GetSaveUserInfo(); public async ValueTask AuthAsync() { + TextBoxText = string.Empty; FirstBoxVisibility = false; PasswordBoxVisibility = false; TextBoxVisibility = false; @@ -174,10 +176,11 @@ public async void FindllyAuth() UserType = "离线账户" }; App.Data.UserList.Add(user); + Users.Add(new(user)); MainWindow.ShowInfoBarAsync("添加账户成功:", $"{user.UserType} {user.UserName} 欢迎回来,{user.UserName}", InfoBarSeverity.Success); UsersView.CloseDialog(); } - GetSaveUserInfo(); + JsonToolkit.JsonAllWrite(); StringsRefresh(); } @@ -192,22 +195,13 @@ public void StringsRefresh() DeviceTips = ""; } - public void GetSaveUserInfo() + public void GetSavedUserInfo() { - BackgroundWorker worker = new(); - worker.DoWork += (_, _) => + JsonToolkit.JsonAllWrite(); + App.Data.UserList.ForEach((x) => { - App.Data.UserList.ForEach(async x => - { - await Task.Run(async () => - { - Users.Add(new(x)); - await Task.Delay(1000); - }); - }); - }; - - worker.RunWorkerAsync(); + Users.Add(new(x)); + }); //CurrentUser = Users.GetUserInIndex(App.Data.SelectedUser.UserName); } @@ -225,6 +219,7 @@ partial class UsersViewModel public bool _PasswordBoxVisibility = false; public bool _ProgressBarVisibility = false; public bool _FirstBoxVisibility = false; + public string _UserNameText = string.Empty; public string _SelectedAuthenticator = "微软验证"; public string _UrlTextBoxText = string.Empty; public string _TextBoxText = string.Empty; diff --git a/WonderLab/Views/UsersView.axaml b/WonderLab/Views/UsersView.axaml index 1a970ad..3d9898f 100644 --- a/WonderLab/Views/UsersView.axaml +++ b/WonderLab/Views/UsersView.axaml @@ -110,7 +110,7 @@ Command="{Binding CopyCodeAsync}" Classes="accent" Content="将代码复制至剪贴板"/> @@ -132,7 +132,7 @@ VerticalAlignment="Center" FontSize="18" FontWeight="Bold" - Text="Starcloudsea 的账户信息" /> + x:Name="UserInfoTitle" /> @@ -187,14 +187,14 @@ - + - + @@ -206,12 +206,15 @@ Orientation="Horizontal">