Skip to content

Commit

Permalink
optimize hoyolab toolbox pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Jan 13, 2024
1 parent 84fb5ec commit 9f92282
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
xmlns:sc="using:Starward.Controls"
xmlns:sp="using:Starward.Pages"
x:DefaultBindMode="OneWay"
Loaded="Page_Loaded"
mc:Ignorable="d">

<Page.Resources>
Expand Down
3 changes: 1 addition & 2 deletions src/Starward/Pages/HoyolabToolbox/ForgottenHallPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public ForgottenHallPage()

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter is GameRecordRole role)
{
gameRole = role;
Expand All @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<Grid>
Expand Down
5 changes: 2 additions & 3 deletions src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public HoyolabToolboxPage()

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter is GameBiz biz)
{
gameBiz = biz switch
Expand All @@ -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)
{
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/Starward/Pages/HoyolabToolbox/LoginPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<Grid>
Expand Down
22 changes: 4 additions & 18 deletions src/Starward/Pages/HoyolabToolbox/LoginPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -82,7 +68,7 @@ private string GetGameBizUrl()



private async void Page_Loaded(object sender, RoutedEventArgs e)
protected override async void OnLoaded()
{
await InitializeCoreWebView();
}
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
xmlns:sc="using:Starward.Controls"
xmlns:sp="using:Starward.Pages"
x:DefaultBindMode="OneWay"
Loaded="Page_Loaded"
mc:Ignorable="d">

<Page.Resources>
Expand Down
5 changes: 2 additions & 3 deletions src/Starward/Pages/HoyolabToolbox/PureFictionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public PureFictionPage()

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter is GameRecordRole role)
{
gameRole = role;
Expand All @@ -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();
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<Page.Resources>
Expand Down
16 changes: 3 additions & 13 deletions src/Starward/Pages/HoyolabToolbox/SimulatedUniversePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public SimulatedUniversePage()

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter is GameRecordRole role)
{
gameRole = role;
Expand All @@ -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();
}


Expand All @@ -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
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
xmlns:sc="using:Starward.Controls"
xmlns:sp="using:Starward.Pages"
x:DefaultBindMode="OneWay"
Loaded="Page_Loaded"
mc:Ignorable="d">

<Page.Resources>
Expand Down
3 changes: 1 addition & 2 deletions src/Starward/Pages/HoyolabToolbox/SpiralAbyssPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public SpiralAbyssPage()

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter is GameRecordRole role)
{
gameRole = role;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
xmlns:sp="using:ScottPlot.WinUI"
xmlns:sp2="using:Starward.Pages"
x:DefaultBindMode="OneWay"
Loaded="Page_Loaded"
mc:Ignorable="d">

<Grid>
Expand Down Expand Up @@ -388,7 +387,7 @@
Shadow="{ThemeResource ThemeShadow}"
Translation="0,0,16"
Visibility="{x:Bind SelectMonthData, Converter={StaticResource ObjectToVisibilityConverter}}">
<sp:WinUIPlot Name="WinUiPlot_Historical"
<sp:WinUIPlot x:Name="WinUiPlot_Historical"
Height="240"
PointerWheelChanged="WinUiPlot_Historical_PointerWheelChanged" />
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ public TrailblazeCalendarPage()

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();
}



[ObservableProperty]
Expand Down
1 change: 0 additions & 1 deletion src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
xmlns:sp="using:ScottPlot.WinUI"
xmlns:sp2="using:Starward.Pages"
x:DefaultBindMode="OneWay"
Loaded="Page_Loaded"
mc:Ignorable="d">

<Grid>
Expand Down
3 changes: 1 addition & 2 deletions src/Starward/Pages/HoyolabToolbox/TravelersDiaryPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9f92282

Please sign in to comment.