From 6a7995f17c283fb5da6ea98e956c43e9773adc3b Mon Sep 17 00:00:00 2001 From: charles7668 Date: Sat, 14 Dec 2024 08:42:05 +0800 Subject: [PATCH] Improve show detail and close detail performance. --- GameManager/Components/Pages/Home.Razor.cs | 6 +----- .../Components/Pages/components/GameDetail.razor.cs | 1 - GameManager/wwwroot/js/webview_api.js | 12 ------------ 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/GameManager/Components/Pages/Home.Razor.cs b/GameManager/Components/Pages/Home.Razor.cs index 4a66ee3..cd87f44 100644 --- a/GameManager/Components/Pages/Home.Razor.cs +++ b/GameManager/Components/Pages/Home.Razor.cs @@ -491,22 +491,18 @@ private Task OnShowDetail(int id) { IsShowDetail = true; _showDetailId = id; - _ = InvokeAsync(StateHasChanged); return Task.CompletedTask; } private async Task OnCloseDetail() { - IsShowDetail = false; - await JsRuntime.InvokeVoidAsync("enableHtmlOverflow"); GameInfoDTO? updateItem = await ConfigService.GetGameInfoBaseDTOAsync(_showDetailId); ViewInfo? viewInfo = ViewGameInfos.Find(x => x.Info.Id == _showDetailId); if (updateItem != null && viewInfo != null) { viewInfo.Info = updateItem; } - - _ = InvokeAsync(StateHasChanged); + IsShowDetail = false; } private async Task OnEnableSyncClick() diff --git a/GameManager/Components/Pages/components/GameDetail.razor.cs b/GameManager/Components/Pages/components/GameDetail.razor.cs index bc51b16..790e1ab 100644 --- a/GameManager/Components/Pages/components/GameDetail.razor.cs +++ b/GameManager/Components/Pages/components/GameDetail.razor.cs @@ -98,7 +98,6 @@ private Task RefreshData(GameInfoDTO? inputGameInfo = null) try { Logger.LogInformation("start loading game info"); - _ = JsRuntime.InvokeVoidAsync("disableHtmlOverflow"); GameInfoDTO gameInfo = inputGameInfo ?? await ConfigService.GetGameInfoDTOAsync(x => x.Id == InitGameId, q => q.Include(x => x.LaunchOption)) ?? diff --git a/GameManager/wwwroot/js/webview_api.js b/GameManager/wwwroot/js/webview_api.js index b7915e7..d133a17 100644 --- a/GameManager/wwwroot/js/webview_api.js +++ b/GameManager/wwwroot/js/webview_api.js @@ -33,16 +33,4 @@ function getCardListWidth() { function remToPixels(rem) { return rem * parseFloat(getComputedStyle(document.documentElement).fontSize); -} - -function disableHtmlOverflow(){ - window.scrollTo({ - top: 0, - behavior: 'instant' - }) - document.querySelector("html").classList.add("overflow-y-hidden"); -} - -function enableHtmlOverflow(){ - document.querySelector("html").classList.remove("overflow-y-hidden"); } \ No newline at end of file