This commit is contained in:
mmrbnjd
2024-09-18 23:52:48 +03:30
parent 712ef32474
commit d976d75048
5 changed files with 59 additions and 13 deletions

View File

@@ -48,8 +48,8 @@ namespace Back.Controllers
public async Task<ActionResult<DateTime>> DateTimeServer() public async Task<ActionResult<DateTime>> DateTimeServer()
=> Ok(DateTime.Now); => Ok(DateTime.Now);
[HttpGet("LastBlog")] [HttpGet("LastBlog")]
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex, int PageSize,string? Tag) public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex, int PageSize,string? Tag, string? ItemSearch)
=> Ok(await _sBase.GetBlog(PageIndex, PageSize,Tag)); => Ok(await _sBase.GetBlog(PageIndex, PageSize,Tag, ItemSearch));
[HttpGet("GetBlogByID/{ID}")] [HttpGet("GetBlogByID/{ID}")]
public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID) public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID)
{ {

View File

@@ -38,9 +38,11 @@ namespace Back.Services
PermissionID=x.PermissionID, PermissionID=x.PermissionID,
}).ToListAsync(); }).ToListAsync();
} }
public async Task<PagingDto<BlogDto>> GetBlog(int PageIndex, int PageSize,string? Tag) public async Task<PagingDto<BlogDto>> GetBlog(int PageIndex, int PageSize,string? Tag, string? ItemSearch)
{ {
var request = _repoBlog.Get(w => w.Status); var request = _repoBlog.Get(w => w.Status);
if (!string.IsNullOrEmpty(ItemSearch))
request = request.Where(x => x.Tags.Contains(ItemSearch) || x.Title.Contains(ItemSearch) || x.Text.Contains(ItemSearch));
if (!string.IsNullOrEmpty(Tag)) if (!string.IsNullOrEmpty(Tag))
request = request.Where(x => x.Tags.Contains(Tag)); request = request.Where(x => x.Tags.Contains(Tag));

View File

@@ -15,11 +15,14 @@
<nav id="mobile-menu"> <nav id="mobile-menu">
<ul> <ul>
<li> <li>
<NavLink href="#">صفحه اصلی</NavLink> <NavLink href="/">صفحه اصلی</NavLink>
</li>
<li>
<NavLink href="ListBlog">مطالب</NavLink>
</li> </li>
</ul> </ul>
</nav> </nav>
</div> </div>
</div> </div>

View File

@@ -23,7 +23,9 @@
<link rel="stylesheet" href="css/spacing.css"> <link rel="stylesheet" href="css/spacing.css">
<link rel="stylesheet" href="css/Lanstyle.css"> <link rel="stylesheet" href="css/Lanstyle.css">
<link rel="stylesheet" href="css/rtl.css"> <link rel="stylesheet" href="css/rtl.css">
<meta name="description" content="تست" />
<meta name="description" content="@description" />
</HeadContent> </HeadContent>
<LBlogheader /> <LBlogheader />
<div id="smooth-wrapper"> <div id="smooth-wrapper">
@@ -31,7 +33,7 @@
<main> <main>
<!-- breadcrumb-area-start --> <!-- breadcrumb-area-start -->
<div class="breadcrumb__area breadcrumb-ptb-4 p-relative blue-bg-2"> <div style="border-radius: .8em;" class="breadcrumb__area breadcrumb-ptb-4 p-relative blue-bg-2">
<div class="breadcrumb__shape-1"> <div class="breadcrumb__shape-1">
<img src="img/breadcrumb/breadcrumb-shape-1.png" alt=""> <img src="img/breadcrumb/breadcrumb-shape-1.png" alt="">
</div> </div>
@@ -105,7 +107,28 @@
</div> </div>
<div class="col-xxl-4 col-xl-4 col-lg-4"> <div class="col-xxl-4 col-xl-4 col-lg-4">
<div class="sidebar__wrapper"> <div class="sidebar__wrapper">
<div class="sidebar__widget mb-40">
<div class="sidebar__widge-title-box">
<h3 class="sidebar__widget-title">جستوجو</h3>
</div>
<div class="sidebar__widget-content">
<div class="sidebar__search">
<form action="#">
<div class="sidebar__search-input-2">
<InputText @bind-Value="strSearch" type="text" class="inputText" placeholder="کلمه ای را بنویسید ..." />
<button @onclick="SearchClick">
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.01371 15.2219C11.9525 15.2219 15.1456 12.0382 15.1456 8.11096C15.1456 4.18368 11.9525 1 8.01371 1C4.07488 1 0.881836 4.18368 0.881836 8.11096C0.881836 12.0382 4.07488 15.2219 8.01371 15.2219Z" stroke="#5F6168" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M16.9287 16.9996L13.0508 13.1331" stroke="#5F6168" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="sidebar__widget mb-40"> <div class="sidebar__widget mb-40">
<div class="sidebar__widge-title-box"> <div class="sidebar__widge-title-box">
<h3 class="sidebar__widget-title">پست های اخیر</h3> <h3 class="sidebar__widget-title">پست های اخیر</h3>
@@ -165,7 +188,10 @@
@code { @code {
//meta tags
public string description { get; set; }
//---------------------
public string strSearch { get; set; }
[Parameter] [Parameter]
public int? ItemID { get; set; } public int? ItemID { get; set; }
@@ -177,10 +203,10 @@
if (ItemID != null) if (ItemID != null)
{ {
Item = await GetItems(); Item = await GetItems();
// Item.Text = "<p><strong>RTHH</strong></p>"; if (Item == null)
if (Item==null)
Navigation.NavigateTo("/"); Navigation.NavigateTo("/");
else await GenerateTags();
} }
else else
@@ -198,14 +224,24 @@
} }
} }
@functions{ @functions{
public async Task SearchClick()
{
if (!string.IsNullOrEmpty(strSearch))
Navigation.NavigateTo("/SearchBlog/" + strSearch);
}
public async Task<BlogDtoFull?> GetItems() public async Task<BlogDtoFull?> GetItems()
{ {
var response = await _hc.GetAsync($"Base/GetBlogByID/{ItemID}"); var response = await _hc.GetAsync($"Base/GetBlogByID/{ItemID}");
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
return null; return null;
return await response.Content.ReadFromJsonAsync<BlogDtoFull>(); return await response.Content.ReadFromJsonAsync<BlogDtoFull>();
} }
public async Task GenerateTags()
{
description = Item.Title;
}
} }

View File

@@ -3,6 +3,7 @@
@layout BlogLayout @layout BlogLayout
@page "/ListBlog" @page "/ListBlog"
@page "/ListBlog/{Tag}" @page "/ListBlog/{Tag}"
@page "/SearchBlog/{itemSearch}"
@inject NavigationManager Navigation @inject NavigationManager Navigation
<PageTitle>دانشنامه</PageTitle> <PageTitle>دانشنامه</PageTitle>
<main> <main>
@@ -102,6 +103,8 @@
[Parameter] [Parameter]
public string? Tag { get; set; } public string? Tag { get; set; }
[Parameter]
public string? itemSearch { get; set; }
[Parameter,SupplyParameterFromQuery] [Parameter,SupplyParameterFromQuery]
public int? PageIndex { get; set; } public int? PageIndex { get; set; }
@@ -111,7 +114,9 @@
{ {
if (PageIndex == null) PageIndex = 1; if (PageIndex == null) PageIndex = 1;
string url = $"Base/LastBlog?PageIndex={PageIndex ?? 1}&PageSize=6"; string url = $"Base/LastBlog?PageIndex={PageIndex ?? 1}&PageSize=6";
if (!string.IsNullOrEmpty(Tag)) url += $" &Tag={Tag}";
if (!string.IsNullOrEmpty(itemSearch)) url += $" &ItemSearch={itemSearch}";
else if (!string.IsNullOrEmpty(Tag)) url += $" &Tag={Tag}";
request = await _hc.GetFromJsonAsync<PagingDto<BlogDto>>(url); request = await _hc.GetFromJsonAsync<PagingDto<BlogDto>>(url);
await base.OnParametersSetAsync(); await base.OnParametersSetAsync();
} }