mirror of https://github.com/abpframework/abp.git
committed by
GitHub
36 changed files with 568 additions and 211 deletions
@ -1,11 +1,10 @@ |
|||||
using System; |
using System; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Application.Dtos; |
|
||||
using Volo.Abp.Application.Services; |
using Volo.Abp.Application.Services; |
||||
using Volo.Abp.Content; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Pages; |
namespace Volo.CmsKit.Admin.Pages; |
||||
|
|
||||
public interface IPageAdminAppService : ICrudAppService<PageDto, PageDto, Guid, GetPagesInputDto, CreatePageInputDto, UpdatePageInputDto> |
public interface IPageAdminAppService : ICrudAppService<PageDto, PageDto, Guid, GetPagesInputDto, CreatePageInputDto, UpdatePageInputDto> |
||||
{ |
{ |
||||
|
Task SetAsHomePageAsync(Guid id); |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,23 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Runtime.Serialization; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
|
||||
|
namespace Volo.CmsKit.Domain.Volo.CmsKit.Pages; |
||||
|
|
||||
|
[Serializable] |
||||
|
public class MultipleHomePageException : BusinessException |
||||
|
{ |
||||
|
public MultipleHomePageException() |
||||
|
{ |
||||
|
Code = CmsKitErrorCodes.Pages.MultipleHomePage; |
||||
|
} |
||||
|
|
||||
|
public MultipleHomePageException(SerializationInfo serializationInfo, StreamingContext context) |
||||
|
: base(serializationInfo, context) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Volo.CmsKit.Pages; |
||||
|
using Volo.CmsKit.Public.Pages; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web; |
||||
|
|
||||
|
public class DefaultHomePageMiddleware |
||||
|
{ |
||||
|
private readonly RequestDelegate _next; |
||||
|
private readonly IPagePublicAppService _pagePublicAppService; |
||||
|
|
||||
|
public DefaultHomePageMiddleware(RequestDelegate next, IPagePublicAppService pagePublicAppService) |
||||
|
{ |
||||
|
_next = next; |
||||
|
_pagePublicAppService = pagePublicAppService; |
||||
|
} |
||||
|
public async Task InvokeAsync(HttpContext httpContext) |
||||
|
{ |
||||
|
var page = await _pagePublicAppService.FindDefaultHomePageAsync(); |
||||
|
if (page is not null && httpContext.Request.Path.Value == "/") |
||||
|
{ |
||||
|
httpContext.Request.Path = $"{PageConsts.UrlPrefix}{page.Slug}"; |
||||
|
} |
||||
|
|
||||
|
await _next(httpContext); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web; |
||||
|
|
||||
|
public static class HomePageDefaultMiddlewareExtensions |
||||
|
{ |
||||
|
public static IApplicationBuilder UseHomePageDefaultMiddleware(this IApplicationBuilder builder) |
||||
|
{ |
||||
|
return builder.UseMiddleware<DefaultHomePageMiddleware>(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue