From 800f4395643497e8099eefdde7d3bd7c10107229 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Tue, 23 Jan 2024 12:27:25 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=8D=9A=E5=AE=A2=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlogApplicationBuilderExtensions.cs | 2 + YaeBlog.Theme.FluentUI/Pages/Home.razor | 193 ++++++++++++------ YaeBlog.Theme.FluentUI/Pages/Home.razor.css | 34 +++ .../YaeBlog.Theme.FluentUI.csproj | 1 + 4 files changed, 172 insertions(+), 58 deletions(-) diff --git a/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs b/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs index 17bc010..6f2d378 100644 --- a/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs +++ b/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; +using Microsoft.FluentUI.AspNetCore.Components; using YaeBlog.Core.Builder; using YaeBlog.Core.Extensions; @@ -15,6 +16,7 @@ public static class BlogApplicationBuilderExtensions private static void ConfigureWebApplicationBuilder(WebApplicationBuilder builder) { builder.Services.AddRazorComponents(); + builder.Services.AddFluentUIComponents(); } private static void ConfigureWebApplication(WebApplication application) diff --git a/YaeBlog.Theme.FluentUI/Pages/Home.razor b/YaeBlog.Theme.FluentUI/Pages/Home.razor index db1bb00..70998c9 100644 --- a/YaeBlog.Theme.FluentUI/Pages/Home.razor +++ b/YaeBlog.Theme.FluentUI/Pages/Home.razor @@ -1,7 +1,10 @@ @page "/" @using YaeBlog.Core.Models +@using YaeBlog.Core.Services @inject BlogOptions BlogOptionsInstance +@inject EssayContentService EssayContentInstance +@inject NavigationManager NavigationManagerInstance
-
+
-
- -
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
+
+ + +
+ @foreach (KeyValuePair essay in _essays) + { + +
+ + + @essay.Value.Title + + + + + + + @(essay.Value.PublishTime.ToString("yyyy-MM-dd HH:mm:ss")) + + @if (essay.Value.Tags.Count != 0) + { + + @foreach (string tag in essay.Value.Tags) + { + + @tag + + } + } + +
+
+ } + + +
+
+ + + +
@@ -82,5 +125,39 @@ @code { + [SupplyParameterFromQuery] private int? Page { get; set; } + + private readonly List> _essays = []; + private int _pageCount; + + protected override void OnInitialized() + { + Page ??= 1; + + IEnumerable[]> chunks = + EssayContentInstance.Essays + .OrderByDescending(pair => pair.Value.PublishTime) + .Chunk(10); + + var count = 1; + var flag = false; + foreach (KeyValuePair[] chunk in chunks) + { + if (Page == count) + { + flag = true; + _essays.AddRange(chunk); + } + + count += 1; + } + + _pageCount = count - 1; + + if (flag is false) + { + NavigationManagerInstance.NavigateTo("NotFount"); + } + } } diff --git a/YaeBlog.Theme.FluentUI/Pages/Home.razor.css b/YaeBlog.Theme.FluentUI/Pages/Home.razor.css index e3804c8..51764bb 100644 --- a/YaeBlog.Theme.FluentUI/Pages/Home.razor.css +++ b/YaeBlog.Theme.FluentUI/Pages/Home.razor.css @@ -54,3 +54,37 @@ opacity: 0.4; } } + +.essay-description { + vertical-align: middle; +} + +.pagination { + font-size: 2em; +} + +.pagination-item { + margin: auto 0 auto 0; +} + +.chevron-left { + font-size: 1.2rem; + font-family: "Font Awesome 6 Free", sans-serif; + font-style: normal; + font-weight: 900; +} + +.chevron-left::before { + content: "\f053"; +} + +.chevron-right { + font-size: 1.2rem; + font-family: "Font Awesome 6 Free", sans-serif; + font-style: normal; + font-weight: 900; +} + +.chevron-right::before { + content: "\f054"; +} diff --git a/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj b/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj index 545c700..562c42d 100644 --- a/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj +++ b/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj @@ -14,6 +14,7 @@ +