improve search user experience
This commit is contained in:
parent
b0e121a53f
commit
4f3190bf73
|
@ -76,13 +76,9 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (PageState.QueryString.ContainsKey("q"))
|
||||
if (_keywords == null && PageState.QueryString.ContainsKey("q"))
|
||||
{
|
||||
_keywords = WebUtility.UrlDecode(PageState.QueryString["q"]);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_keywords))
|
||||
{
|
||||
await PerformSearch();
|
||||
}
|
||||
}
|
||||
|
@ -97,18 +93,25 @@
|
|||
_loading = true;
|
||||
StateHasChanged();
|
||||
|
||||
var searchQuery = new SearchQuery
|
||||
{
|
||||
SiteId = PageState.Site.SiteId,
|
||||
Alias = PageState.Alias,
|
||||
Keywords = _keywords,
|
||||
SortDirection = _searchSortDirection,
|
||||
SortField = _searchSortField,
|
||||
PageIndex = 0,
|
||||
PageSize = int.MaxValue
|
||||
};
|
||||
if (!string.IsNullOrEmpty(_keywords))
|
||||
{
|
||||
var searchQuery = new SearchQuery
|
||||
{
|
||||
SiteId = PageState.Site.SiteId,
|
||||
Alias = PageState.Alias,
|
||||
Keywords = _keywords,
|
||||
SortDirection = _searchSortDirection,
|
||||
SortField = _searchSortField,
|
||||
PageIndex = 0,
|
||||
PageSize = int.MaxValue
|
||||
};
|
||||
|
||||
_searchResults = await SearchResultsService.GetSearchResultsAsync(searchQuery);
|
||||
_searchResults = await SearchResultsService.GetSearchResultsAsync(searchQuery);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage(Localizer["NoCriteria"], MessageType.Info, "bottom");
|
||||
}
|
||||
|
||||
_loading = false;
|
||||
StateHasChanged();
|
||||
|
|
|
@ -117,6 +117,9 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="NoCriteria" xml:space="preserve">
|
||||
<value>You Must Provide Some Search Criteria</value>
|
||||
</data>
|
||||
<data name="NoResult" xml:space="preserve">
|
||||
<value>No Content Matches The Criteria Provided</value>
|
||||
</data>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
private void PerformSearch()
|
||||
{
|
||||
var keywords = HttpContext.HttpContext.Request.Form["keywords"];
|
||||
if (!string.IsNullOrEmpty(keywords) && _searchResultsPage != null)
|
||||
if (_searchResultsPage != null)
|
||||
{
|
||||
var url = NavigateUrl(_searchResultsPage.Path, $"q={keywords}");
|
||||
NavigationManager.NavigateTo(url);
|
||||
|
|
Loading…
Reference in New Issue
Block a user