From d789b76ff3acf91e8a8e6cc52e5bcc30fcbfb08a Mon Sep 17 00:00:00 2001 From: DCTewi Date: Thu, 24 Jun 2021 01:04:46 +0800 Subject: [PATCH 1/2] Upgrade: top bar & search & nav --- VirtualGroupEx.Server/Localization/I18n.json | 4 +- VirtualGroupEx.Server/Pages/Search.razor | 48 ++++++++++++------- VirtualGroupEx.Server/Shared/MainLayout.razor | 29 +++++++++++ VirtualGroupEx.Server/Shared/NavMenu.razor | 23 --------- 4 files changed, 61 insertions(+), 43 deletions(-) diff --git a/VirtualGroupEx.Server/Localization/I18n.json b/VirtualGroupEx.Server/Localization/I18n.json index 7cae5cb..2eb732b 100644 --- a/VirtualGroupEx.Server/Localization/I18n.json +++ b/VirtualGroupEx.Server/Localization/I18n.json @@ -1,7 +1,7 @@ { "zh-CN": { "nav.bulletin": "公告栏", - "nav.search": "搜索框", + "nav.search": "搜索", "nav.routine": "打卡处", "nav.mission": "工作表", "nav.discussion": "讨论版", @@ -194,7 +194,7 @@ }, "ja-JP": { "nav.bulletin": "掲示板", - "nav.search": "検索ボックス", + "nav.search": "検索", "nav.routine": "ルーティン", "nav.mission": "仕事テーブル", "nav.discussion": "検討エリア", diff --git a/VirtualGroupEx.Server/Pages/Search.razor b/VirtualGroupEx.Server/Pages/Search.razor index e263a60..229bdf6 100644 --- a/VirtualGroupEx.Server/Pages/Search.razor +++ b/VirtualGroupEx.Server/Pages/Search.razor @@ -1,23 +1,32 @@ @page "/search" +@page "/search/{keyword}" @inject SearchService SearchService @inject NavigationManager NavigationManager @inject DiscussionService DiscussService @inject UserInfoService UserInfo -@inject JSInvokeService Js +@inject JSInvokeService Js @code { - private string keyword; + [Parameter] public string Keyword { get; set; } private List searchResults = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (!string.IsNullOrEmpty(Keyword)) + { + await SearchAsync(); + } + } + private async Task SearchAsync() { - if (!string.IsNullOrEmpty(keyword)) + if (!string.IsNullOrEmpty(Keyword)) { - keyword = keyword?.Trim(); - searchResults = SearchService.Search(keyword); + Keyword = Keyword?.Trim(); + searchResults = SearchService.Search(Keyword); StateHasChanged(); } await Js.ResetButtonAsync(); @@ -25,29 +34,32 @@ private async Task ReloadPage() { - keyword = string.Empty; + Keyword = string.Empty; searchResults = null; await Js.ResetButtonAsync(); } } -

@localizer["nav.search"]

+

@localizer["nav.search"]@(string.IsNullOrEmpty(Keyword) ? "" : $": {Keyword}")

-
-
+@if (string.IsNullOrEmpty(Keyword)) +{ +
+ -

- - -

+

+ + +

- + -
+ +} @if (searchResults != null) { diff --git a/VirtualGroupEx.Server/Shared/MainLayout.razor b/VirtualGroupEx.Server/Shared/MainLayout.razor index 46b5f81..d6d603a 100644 --- a/VirtualGroupEx.Server/Shared/MainLayout.razor +++ b/VirtualGroupEx.Server/Shared/MainLayout.razor @@ -1,4 +1,11 @@ @inherits LayoutComponentBase +@inject NavigationManager NavigationManager +@inject CurrentUserService CurrentUser + +@code +{ + private string keyword; +}
+
@Body
diff --git a/VirtualGroupEx.Server/Shared/NavMenu.razor b/VirtualGroupEx.Server/Shared/NavMenu.razor index f05ba9c..686e379 100644 --- a/VirtualGroupEx.Server/Shared/NavMenu.razor +++ b/VirtualGroupEx.Server/Shared/NavMenu.razor @@ -57,11 +57,6 @@ @localizer["nav.bulletin"] - } - @*@if (CurrentUser.User.IsAdministrator) - { - - }*@ } - } else { From fcbf57bbf34a82b8154b9e44f84f62cd92c4a64f Mon Sep 17 00:00:00 2001 From: DCTewi Date: Thu, 24 Jun 2021 01:16:42 +0800 Subject: [PATCH 2/2] Fix: modal bug #5 --- VirtualGroupEx.Server/Pages/Dashboard.razor | 13 +++++++++++++ VirtualGroupEx.Server/Pages/Discussions.razor | 12 ++++++++++++ VirtualGroupEx.Server/Pages/Index.razor | 13 +++++++++++++ VirtualGroupEx.Server/Pages/Missions.razor | 13 +++++++++++++ VirtualGroupEx.Server/Pages/Routines.razor | 13 +++++++++++++ VirtualGroupEx.Server/Pages/Search.razor | 1 + 6 files changed, 65 insertions(+) diff --git a/VirtualGroupEx.Server/Pages/Dashboard.razor b/VirtualGroupEx.Server/Pages/Dashboard.razor index c6111af..6295d44 100644 --- a/VirtualGroupEx.Server/Pages/Dashboard.razor +++ b/VirtualGroupEx.Server/Pages/Dashboard.razor @@ -3,6 +3,19 @@ @inject CurrentUserService CurrentUser @inject NavigationManager NavigationManager +@inject JSInvokeService Js +@code +{ + protected async override Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await Js.HideModalsAsync(); + } + await base.OnAfterRenderAsync(firstRender); + } +} + @code { protected override void OnInitialized() diff --git a/VirtualGroupEx.Server/Pages/Discussions.razor b/VirtualGroupEx.Server/Pages/Discussions.razor index 5e73b11..c62fa9b 100644 --- a/VirtualGroupEx.Server/Pages/Discussions.razor +++ b/VirtualGroupEx.Server/Pages/Discussions.razor @@ -2,6 +2,18 @@ @inject DiscussionService DiscussService @inject NavigationManager NavigationManager +@inject JSInvokeService Js +@code +{ + protected async override Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await Js.HideModalsAsync(); + } + await base.OnAfterRenderAsync(firstRender); + } +} @code { diff --git a/VirtualGroupEx.Server/Pages/Index.razor b/VirtualGroupEx.Server/Pages/Index.razor index fa8a06b..e3f332c 100644 --- a/VirtualGroupEx.Server/Pages/Index.razor +++ b/VirtualGroupEx.Server/Pages/Index.razor @@ -1,3 +1,16 @@ @page "/" +@inject JSInvokeService Js +@code +{ + protected async override Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await Js.HideModalsAsync(); + } + await base.OnAfterRenderAsync(firstRender); + } +} + \ No newline at end of file diff --git a/VirtualGroupEx.Server/Pages/Missions.razor b/VirtualGroupEx.Server/Pages/Missions.razor index 9df9d2c..5d37962 100644 --- a/VirtualGroupEx.Server/Pages/Missions.razor +++ b/VirtualGroupEx.Server/Pages/Missions.razor @@ -3,6 +3,19 @@ @inject MissionService MissionService @inject NavigationManager NavigationManager +@inject JSInvokeService Js +@code +{ + protected async override Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await Js.HideModalsAsync(); + } + await base.OnAfterRenderAsync(firstRender); + } +} + @code { [Parameter] public int? Id { get; set; } diff --git a/VirtualGroupEx.Server/Pages/Routines.razor b/VirtualGroupEx.Server/Pages/Routines.razor index e088bfd..ccb019f 100644 --- a/VirtualGroupEx.Server/Pages/Routines.razor +++ b/VirtualGroupEx.Server/Pages/Routines.razor @@ -1,3 +1,16 @@ @page "/routine" +@inject JSInvokeService Js +@code +{ + protected async override Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await Js.HideModalsAsync(); + } + await base.OnAfterRenderAsync(firstRender); + } +} + \ No newline at end of file diff --git a/VirtualGroupEx.Server/Pages/Search.razor b/VirtualGroupEx.Server/Pages/Search.razor index 229bdf6..cc7e6d7 100644 --- a/VirtualGroupEx.Server/Pages/Search.razor +++ b/VirtualGroupEx.Server/Pages/Search.razor @@ -19,6 +19,7 @@ { await SearchAsync(); } + await base.OnAfterRenderAsync(firstRender); } private async Task SearchAsync()