Skip to content

Commit

Permalink
support to click go back button while verifing account
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Jan 20, 2024
1 parent 512b225 commit 54d9323
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Starward/Controls/HyperionWebBridge.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.UI.Xaml;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Starward.Core.GameRecord;
using Starward.Messages;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -154,7 +156,7 @@ private async void CoreWebView2_WebMessageReceived(Microsoft.Web.WebView2.Core.C

JsResult? result = param.Method switch
{
"closePage" => null,
"closePage" => ClosePage(param),
"configure_share" => null,
"eventTrack" => null,
//"getActionTicket" => await GetActionTicketAsync(param).ConfigureAwait(false),
Expand Down Expand Up @@ -234,6 +236,20 @@ private async Task CallbackAsync(string? callback, JsResult? result)
}


private JsResult? ClosePage(JsParam param)
{
if (webview2.CoreWebView2.CanGoBack)
{
webview2.CoreWebView2.GoBack();
}
else
{
this.DispatcherQueue.TryEnqueue(() => WeakReferenceMessenger.Default.Send(new GameRecordPageNavigationGoBackMessage()));

}
return null;
}


private JsResult? PushPage(JsParam param)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Starward.Messages;

public record GameRecordPageNavigationGoBackMessage();
4 changes: 4 additions & 0 deletions src/Starward/Pages/HoyolabToolbox/HoyolabToolboxPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ protected override async void OnLoaded()
{
NavigateTo(typeof(HyperionWebBridgePage), new HyperionWebBridgePage.PageParameter(m.GameRole, m.TargetUrl));
});
WeakReferenceMessenger.Default.Register<GameRecordPageNavigationGoBackMessage>(this, (r, m) =>
{
if (frame.CanGoBack) { frame.GoBack(); }
});
await Task.Delay(16);
NavigateTo(typeof(BlankPage));
await CheckAgreementAsync();
Expand Down

0 comments on commit 54d9323

Please sign in to comment.