From c067f11be714b2c1e46a5563865965e454f2e48c Mon Sep 17 00:00:00 2001 From: jackfiled Date: Thu, 15 Feb 2024 20:21:52 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E6=B7=BB=E5=8A=A0=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E5=AD=90=E8=B7=AF=E5=BE=84=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YaeBlog.Core/Models/BlogOptions.cs | 5 +++++ .../Services/WebApplicationHostedService.cs | 5 +++++ YaeBlog.Theme.FluentUI/App.razor | 2 +- .../Components/AuthorInformation.razor | 4 ++-- .../Layout/MainLayout.razor | 12 +++++----- YaeBlog.Theme.FluentUI/Pages/Archives.razor | 2 +- YaeBlog.Theme.FluentUI/Pages/Home.razor | 22 +++++++++---------- YaeBlog.Theme.FluentUI/Pages/Tags.razor | 4 ++-- 8 files changed, 33 insertions(+), 23 deletions(-) diff --git a/YaeBlog.Core/Models/BlogOptions.cs b/YaeBlog.Core/Models/BlogOptions.cs index 6ae6dad..36f7fb4 100644 --- a/YaeBlog.Core/Models/BlogOptions.cs +++ b/YaeBlog.Core/Models/BlogOptions.cs @@ -9,6 +9,11 @@ public class BlogOptions /// public required string Root { get; set; } + /// + /// 博客挂载的子路径 + /// + public required string SubPath { get; set; } + /// /// 博客作者 /// diff --git a/YaeBlog.Core/Services/WebApplicationHostedService.cs b/YaeBlog.Core/Services/WebApplicationHostedService.cs index 77ce006..5a7465a 100644 --- a/YaeBlog.Core/Services/WebApplicationHostedService.cs +++ b/YaeBlog.Core/Services/WebApplicationHostedService.cs @@ -12,6 +12,8 @@ public class WebApplicationHostedService : IHostedService private readonly List> _webApplicationConfigurations; + private readonly IOptions _options; + private Website? _currentWebsite; public WebApplicationHostedService(List> webApplicationBuilderConfigurations, @@ -19,6 +21,8 @@ public class WebApplicationHostedService : IHostedService IServiceProvider hostServiceProvider) { _webApplicationConfigurations = webApplicationConfigurations; + _options = hostServiceProvider.GetRequiredService>(); + foreach (Action configure in webApplicationBuilderConfigurations) { configure(_websiteBuilder); @@ -35,6 +39,7 @@ public class WebApplicationHostedService : IHostedService } WebApplication application = _websiteBuilder.Build(); + application.UsePathBase("/" + _options.Value.SubPath); foreach (Action configure in _webApplicationConfigurations) { configure(application); diff --git a/YaeBlog.Theme.FluentUI/App.razor b/YaeBlog.Theme.FluentUI/App.razor index 70c5702..0eab9ae 100644 --- a/YaeBlog.Theme.FluentUI/App.razor +++ b/YaeBlog.Theme.FluentUI/App.razor @@ -7,7 +7,7 @@ - + diff --git a/YaeBlog.Theme.FluentUI/Components/AuthorInformation.razor b/YaeBlog.Theme.FluentUI/Components/AuthorInformation.razor index c993bcc..26c03de 100644 --- a/YaeBlog.Theme.FluentUI/Components/AuthorInformation.razor +++ b/YaeBlog.Theme.FluentUI/Components/AuthorInformation.razor @@ -21,7 +21,7 @@ - +
文章 @@ -32,7 +32,7 @@
- +
标签 diff --git a/YaeBlog.Theme.FluentUI/Layout/MainLayout.razor b/YaeBlog.Theme.FluentUI/Layout/MainLayout.razor index 01b9c0d..9fd90b2 100644 --- a/YaeBlog.Theme.FluentUI/Layout/MainLayout.razor +++ b/YaeBlog.Theme.FluentUI/Layout/MainLayout.razor @@ -8,7 +8,7 @@
-
+ @BlogOptionsInstance.Author @@ -16,7 +16,7 @@ - +