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 @@ - +