mirror of https://github.com/abpframework/abp.git
11 changed files with 177 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||||
|
namespace Volo.CmsKit.Public.GlobalResources; |
||||
|
|
||||
|
public class GlobalResourceDto |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public string Value { get; set; } |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.GlobalResources; |
||||
|
|
||||
|
public interface IGlobalResourcePublicAppService : IApplicationService |
||||
|
{ |
||||
|
Task<GlobalResourceDto> GetGlobalScriptAsync(); |
||||
|
|
||||
|
Task<GlobalResourceDto> GetGlobalStyleAsync(); |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.GlobalFeatures; |
||||
|
using Volo.CmsKit.GlobalFeatures; |
||||
|
using Volo.CmsKit.GlobalResources; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.GlobalResources; |
||||
|
|
||||
|
[RequiresGlobalFeature(typeof(GlobalResourcesFeature))] |
||||
|
public class GlobalResourcePublicAppService : ApplicationService, IGlobalResourcePublicAppService |
||||
|
{ |
||||
|
public GlobalResourceManager GlobalResourceManager { get; } |
||||
|
|
||||
|
public GlobalResourcePublicAppService(GlobalResourceManager globalResourceManager) |
||||
|
{ |
||||
|
GlobalResourceManager = globalResourceManager; |
||||
|
} |
||||
|
|
||||
|
public async Task<GlobalResourceDto> GetGlobalScriptAsync() |
||||
|
{ |
||||
|
var globalScript = await GlobalResourceManager.GetGlobalScriptAsync(); |
||||
|
|
||||
|
return ObjectMapper.Map<GlobalResource, GlobalResourceDto>(globalScript); |
||||
|
} |
||||
|
|
||||
|
public async Task<GlobalResourceDto> GetGlobalStyleAsync() |
||||
|
{ |
||||
|
var globalStyle = await GlobalResourceManager.GetGlobalStyleAsync(); |
||||
|
|
||||
|
return ObjectMapper.Map<GlobalResource, GlobalResourceDto>(globalStyle); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.GlobalFeatures; |
||||
|
using Volo.CmsKit.GlobalFeatures; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.GlobalResources; |
||||
|
|
||||
|
[RequiresGlobalFeature(typeof(GlobalResourcesFeature))] |
||||
|
[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] |
||||
|
[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] |
||||
|
[Route("api/cms-kit-public/global-resources")] |
||||
|
public class GlobalResourcePublicController: CmsKitPublicControllerBase, IGlobalResourcePublicAppService |
||||
|
{ |
||||
|
private readonly IGlobalResourcePublicAppService _globalResourcePublicAppService; |
||||
|
|
||||
|
public GlobalResourcePublicController(IGlobalResourcePublicAppService globalResourcePublicAppService) |
||||
|
{ |
||||
|
_globalResourcePublicAppService = globalResourcePublicAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("script")] |
||||
|
public Task<GlobalResourceDto> GetGlobalScriptAsync() |
||||
|
{ |
||||
|
return _globalResourcePublicAppService.GetGlobalScriptAsync(); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("style")] |
||||
|
public Task<GlobalResourceDto> GetGlobalStyleAsync() |
||||
|
{ |
||||
|
return _globalResourcePublicAppService.GetGlobalStyleAsync(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.CmsKit.Public.GlobalResources; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Controllers; |
||||
|
|
||||
|
[Route("global-resources")] |
||||
|
public class CmsKitPublicGlobalResourcesController: AbpController |
||||
|
{ |
||||
|
private readonly IGlobalResourcePublicAppService _globalResourcePublicAppService; |
||||
|
|
||||
|
public CmsKitPublicGlobalResourcesController(IGlobalResourcePublicAppService globalResourcePublicAppService) |
||||
|
{ |
||||
|
_globalResourcePublicAppService = globalResourcePublicAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("style")] |
||||
|
public async Task<IActionResult> GetGlobalStyleAsync(string entityType, string entityId) |
||||
|
{ |
||||
|
var style = await _globalResourcePublicAppService.GetGlobalStyleAsync(); |
||||
|
|
||||
|
var contents = Encoding.ASCII.GetBytes(style.Value); |
||||
|
|
||||
|
return new FileContentResult(contents, "text/css"); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("script")] |
||||
|
public async Task<IActionResult> GetGlobalScriptAsync(string entityType, string entityId) |
||||
|
{ |
||||
|
var script = await _globalResourcePublicAppService.GetGlobalScriptAsync(); |
||||
|
|
||||
|
var contents = Encoding.ASCII.GetBytes(script.Value); |
||||
|
|
||||
|
return new FileContentResult(contents, "application/javascript"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
<script src="/global-resources/script"></script> |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Script; |
||||
|
|
||||
|
public class GlobalScriptViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
public async Task<IViewComponentResult> InvokeAsync() |
||||
|
{ |
||||
|
return View("~/Pages/CmsKit/Shared/Components/GlobalResources/Script/Default.cshtml"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
<link rel="stylesheet" href="/global-resources/style"/> |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style; |
||||
|
|
||||
|
public class GlobalStyleViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
public async Task<IViewComponentResult> InvokeAsync() |
||||
|
{ |
||||
|
return View("~/Pages/CmsKit/Shared/Components/GlobalResources/Style/Default.cshtml"); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue