Skip to content

Commit

Permalink
feat: 跳轉頁面時帶上 accesstoken
Browse files Browse the repository at this point in the history
  • Loading branch information
aa89227 committed Jun 20, 2024
1 parent b794ba4 commit 23f4919
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Clients/Monopoly.Clients.Web/Pages/Ready/ReadyPage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public partial class ReadyPage
public ImmutableArray<Player> Players { get; set; } = [];
[Parameter] public string UserId { get; set; } = string.Empty;
[Parameter] public string RoomId { get; set; } = string.Empty;

[Parameter, SupplyParameterFromQuery(Name = "token")]
public string AccessToken { get; set; } = string.Empty;
[Inject] private IOptions<MonopolyApiOptions> BackendApiOptions { get; set; } = default!;
Expand Down Expand Up @@ -108,7 +109,7 @@ private Task OnGameStartEvent(GameStartedEventArgs e)
return Task.CompletedTask;
}

NavigationManager.NavigateTo($"/GamingPage?gameid={RoomId}");
NavigationManager.NavigateTo($"/GamingPage?gameid={e.GameId}&token={AccessToken}");
return Task.CompletedTask;
}

Expand Down Expand Up @@ -153,6 +154,17 @@ private async Task OnReady()

private async Task OnStart()
{
await Connection.StartGame();
try
{
await Connection.StartGame();
}
catch (HubException)
{
Popup?.Show(new Popup.PopupParameter
{
Message = "有人還沒準備,無法開始遊戲",
Delay = 1000
});
}
}
}

0 comments on commit 23f4919

Please sign in to comment.