diff --git a/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml b/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml index a16ee69ee..150f94d3c 100644 --- a/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml @@ -10,7 +10,6 @@ xmlns:sc="using:Starward.Controls" xmlns:sp="using:Starward.Pages" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" mc:Ignorable="d"> diff --git a/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml.cs index ac80a2b9f..bb1226c86 100644 --- a/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml.cs @@ -48,7 +48,6 @@ public ForgottenHallPage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is GameRecordRole role) { gameRole = role; @@ -57,7 +56,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { await Task.Delay(16); InitializeForgottenHallData(); diff --git a/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml b/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml index a0b701227..c4ecca414 100644 --- a/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml @@ -10,8 +10,6 @@ xmlns:sh="using:Starward.Helpers" xmlns:sp="using:Starward.Pages" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" - Unloaded="Page_Unloaded" mc:Ignorable="d"> diff --git a/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs index f9b3ca3f5..a57cc5e8b 100644 --- a/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs @@ -51,7 +51,6 @@ public HoyolabToolboxPage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is GameBiz biz) { gameBiz = biz switch @@ -68,7 +67,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { if (AppConfig.HoyolabToolboxPaneOpen) { @@ -94,7 +93,7 @@ private async void Page_Loaded(object sender, RoutedEventArgs e) - private void Page_Unloaded(object sender, RoutedEventArgs e) + protected override void OnUnloaded() { WeakReferenceMessenger.Default.UnregisterAll(this); } diff --git a/src/Starward/Pages/HoyolabToolbox/HyperionWebBridgePage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/HyperionWebBridgePage.xaml.cs index bc6cbc7af..a25a7fdc7 100644 --- a/src/Starward/Pages/HoyolabToolbox/HyperionWebBridgePage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/HyperionWebBridgePage.xaml.cs @@ -24,7 +24,6 @@ public HyperionWebBridgePage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is PageParameter parameter) { webBridge.GameRecordRole = parameter.GameRole; diff --git a/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml b/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml index 4fce3839a..070acedc4 100644 --- a/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml @@ -7,7 +7,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sp="using:Starward.Pages" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" mc:Ignorable="d"> diff --git a/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml.cs index 042618243..8f0514c25 100644 --- a/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/LoginPage.xaml.cs @@ -45,26 +45,12 @@ public LoginPage() - private GameBiz gameBiz; - - - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - base.OnNavigatedTo(e); - if (e.Parameter is GameBiz biz) - { - gameBiz = biz; - } - } - - private string GetGameBizUrl() { - if (gameBiz.IsChinaServer()) + if (CurrentGameBiz.IsChinaServer()) { - return gameBiz.ToGame() switch + return CurrentGameBiz.ToGame() switch { GameBiz.GenshinImpact => $"{URL_CN}ys", GameBiz.StarRail => $"{URL_CN}sr", @@ -82,7 +68,7 @@ private string GetGameBizUrl() - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { await InitializeCoreWebView(); } @@ -257,7 +243,7 @@ private async void Button_Finish_Click(object sender, RoutedEventArgs e) var cookieString = string.Join(";", cookies.Select(x => $"{x.Name}={x.Value}")); var user = await _gameRecordService.AddRecordUserAsync(cookieString); var roles = await _gameRecordService.AddGameRolesAsync(cookieString); - WeakReferenceMessenger.Default.Send(new GameRecordRoleChangedMessage(roles.FirstOrDefault(x => x.GameBiz == gameBiz.ToString()))); + WeakReferenceMessenger.Default.Send(new GameRecordRoleChangedMessage(roles.FirstOrDefault(x => x.GameBiz == CurrentGameBiz.ToString()))); TextBlock_Tip.Text = string.Format(Lang.LoginPage_AlreadyAddedGameRoles, roles.Count, string.Join("\r\n", roles.Select(x => $"{x.Nickname} {x.Uid}"))); } catch (miHoYoApiException ex) diff --git a/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml b/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml index 93c91ac5c..bd9cd8046 100644 --- a/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml @@ -10,7 +10,6 @@ xmlns:sc="using:Starward.Controls" xmlns:sp="using:Starward.Pages" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" mc:Ignorable="d"> diff --git a/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml.cs index 28a0a1f3e..bf90d4d10 100644 --- a/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml.cs @@ -48,7 +48,6 @@ public PureFictionPage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is GameRecordRole role) { gameRole = role; @@ -57,7 +56,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { await Task.Delay(16); InitializePureFictionInfoData(); @@ -81,7 +80,7 @@ private void InitializePureFictionInfoData() { CurrentPureFiction = null; var list = _gameRecordService.GetPureFictionInfoList(gameRole); - if (list.Any()) + if (list.Count != 0) { PureFictionList = list; ListView_ForgottenHall.SelectedIndex = 0; diff --git a/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml b/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml index 63e1f7d0c..5b4f20e98 100644 --- a/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml @@ -11,7 +11,6 @@ xmlns:sp="using:Starward.Pages" xmlns:su="using:Starward.Core.GameRecord.StarRail.SimulatedUniverse" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" mc:Ignorable="d"> diff --git a/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml.cs index 400c4e923..6da44237d 100644 --- a/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml.cs @@ -47,7 +47,6 @@ public SimulatedUniversePage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is GameRecordRole role) { gameRole = role; @@ -56,10 +55,10 @@ protected override void OnNavigatedTo(NavigationEventArgs e) - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { await Task.Delay(16); - await InitializeDataAsync(); + InitializeSimulatedUniverseRecord(); } @@ -79,15 +78,6 @@ private async void Page_Loaded(object sender, RoutedEventArgs e) - - private async Task InitializeDataAsync() - { - await Task.Delay(16); - InitializeSimulatedUniverseRecord(); - } - - - private void InitializeSimulatedUniverseRecord() { try @@ -99,7 +89,7 @@ private void InitializeSimulatedUniverseRecord() } CurrentRecord = null; var list = _gameRecordService.GetSimulatedUniverseRecordBasics(gameRole); - if (list.Any()) + if (list.Count != 0) { RecordBasicList = list; ListView_SimulatedUniverse.SelectedIndex = 0; diff --git a/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml b/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml index 7ae3af35c..c836bfe50 100644 --- a/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml @@ -10,7 +10,6 @@ xmlns:sc="using:Starward.Controls" xmlns:sp="using:Starward.Pages" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" mc:Ignorable="d"> diff --git a/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml.cs index 83b9e8b88..2c524b931 100644 --- a/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml.cs @@ -48,7 +48,6 @@ public SpiralAbyssPage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is GameRecordRole role) { gameRole = role; @@ -57,7 +56,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { await Task.Delay(160); InitializeAbyssData(); diff --git a/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml b/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml index f476dc21b..9a68cc0a1 100644 --- a/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml @@ -11,7 +11,6 @@ xmlns:sp="using:ScottPlot.WinUI" xmlns:sp2="using:Starward.Pages" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" mc:Ignorable="d"> @@ -388,7 +387,7 @@ Shadow="{ThemeResource ThemeShadow}" Translation="0,0,16" Visibility="{x:Bind SelectMonthData, Converter={StaticResource ObjectToVisibilityConverter}}"> - diff --git a/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml.cs index 3ab418e99..98ec6b422 100644 --- a/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/TrailblazeCalendarPage.xaml.cs @@ -49,7 +49,6 @@ public TrailblazeCalendarPage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is GameRecordRole role) { gameRole = role; @@ -57,12 +56,12 @@ protected override void OnNavigatedTo(NavigationEventArgs e) } - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { await Task.Delay(16); await InitializeDataAsync(); } - + [ObservableProperty] diff --git a/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml b/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml index 990a69d77..75eaf9105 100644 --- a/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml +++ b/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml @@ -11,7 +11,6 @@ xmlns:sp="using:ScottPlot.WinUI" xmlns:sp2="using:Starward.Pages" x:DefaultBindMode="OneWay" - Loaded="Page_Loaded" mc:Ignorable="d"> diff --git a/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml.cs b/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml.cs index 5b57ef13c..e7c50890f 100644 --- a/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml.cs +++ b/src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml.cs @@ -50,14 +50,13 @@ public TravelersDiaryPage() protected override void OnNavigatedTo(NavigationEventArgs e) { - base.OnNavigatedTo(e); if (e.Parameter is GameRecordRole role) { gameRole = role; } } - private async void Page_Loaded(object sender, RoutedEventArgs e) + protected override async void OnLoaded() { await Task.Delay(16); await InitializeDataAsync();