Merge pull request #13705 from abpframework/auto-merge/rel-6-0/1283

Merge branch dev with rel-6.0
pull/13711/head
Enis Necipoglu 3 years ago committed by GitHub
commit 257e74c4e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
namespace Volo.CmsKit.GlobalResources;
public class GlobalResourceConsts
public static class GlobalResourceConsts
{
public const string GlobalStyleName = "GlobalStyle";

@ -1,8 +1,12 @@
namespace Volo.CmsKit.Public.GlobalResources;
using System;
using Volo.Abp.Application.Dtos;
public class GlobalResourceDto
namespace Volo.CmsKit.Public.GlobalResources;
[Serializable]
public class GlobalResourceDto : AuditedEntityDto
{
public string Name { get; set; }
public string Value { get; set; }
}

@ -5,11 +5,10 @@ using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus;
using Volo.Abp.ObjectMapping;
using Volo.CmsKit.GlobalResources;
using Volo.CmsKit.Public.GlobalResources;
namespace Volo.CmsKit.Public.GlobalResources.Handlers;
public class GlobalResourceEventHandler:
public class GlobalResourceEventHandler :
ILocalEventHandler<EntityUpdatedEventData<GlobalResource>>,
ITransientDependency
{
@ -23,11 +22,11 @@ public class GlobalResourceEventHandler:
ObjectMapper = objectMapper;
_resourceCache = resourceCache;
}
public async Task HandleEventAsync(EntityUpdatedEventData<GlobalResource> eventData)
{
await _resourceCache.SetAsync(
eventData.Entity.Name,
eventData.Entity.Name,
ObjectMapper.Map<GlobalResource, GlobalResourceDto>(eventData.Entity));
}
}

@ -1 +1,3 @@
<link rel="stylesheet" href="/cms-kit/global-resources/style"/>
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style.GlobalStyleModel
<link rel="stylesheet" href="@("/cms-kit/global-resources/style?v=" + Model.LastModificationTimeTimestamp)"/>

@ -0,0 +1,6 @@
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style;
public class GlobalStyleModel
{
public long LastModificationTimeTimestamp { get; set; }
}

@ -1,13 +1,33 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.CmsKit.Public.GlobalResources;
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style;
public class GlobalStyleViewComponent : AbpViewComponent
{
protected IGlobalResourcePublicAppService GlobalResourcePublicAppService { get; }
public GlobalStyleViewComponent(IGlobalResourcePublicAppService globalResourcePublicAppService)
{
GlobalResourcePublicAppService = globalResourcePublicAppService;
}
[BindProperty(SupportsGet = true)]
public DateTime? LastModificationTime { get; set; }
public async Task<IViewComponentResult> InvokeAsync()
{
return View("~/Pages/CmsKit/Shared/Components/GlobalResources/Style/Default.cshtml");
var lastModificationTime = (await GlobalResourcePublicAppService.GetGlobalStyleAsync())?.LastModificationTime;
var lastModificationTimeTimestamp = (long)(lastModificationTime.HasValue ? lastModificationTime.Value.Subtract(DateTime.UnixEpoch).TotalSeconds : 0);
return View("~/Pages/CmsKit/Shared/Components/GlobalResources/Style/Default.cshtml",
new GlobalStyleModel()
{
LastModificationTimeTimestamp = lastModificationTimeTimestamp
});
}
}
Loading…
Cancel
Save