mirror of https://github.com/abpframework/abp.git
18 changed files with 13034 additions and 1 deletions
@ -1,3 +1,4 @@ |
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap |
|||
@addTagHelper *, AbpDesk.Web.Mvc |
|||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -0,0 +1,31 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.ExtensionMethods.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Bundling |
|||
{ |
|||
public class BundleCollection |
|||
{ |
|||
private readonly Dictionary<string, List<string>> _bundles; |
|||
|
|||
public BundleCollection() |
|||
{ |
|||
_bundles = new Dictionary<string, List<string>>(); |
|||
} |
|||
|
|||
public void Add(string bundleName, string[] files) |
|||
{ |
|||
_bundles.GetOrAdd(bundleName, () => new List<string>()).AddRange(files); |
|||
} |
|||
|
|||
public List<string> GetFiles(string bundleName) |
|||
{ |
|||
var files = _bundles.GetOrDefault(bundleName); |
|||
if (files == null) |
|||
{ |
|||
throw new AbpException("Undefined bundle: " + bundleName); |
|||
} |
|||
|
|||
return files; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Bundling |
|||
{ |
|||
public class BundleManager : IBundleManager, ITransientDependency |
|||
{ |
|||
private readonly BundlingOptions _options; |
|||
|
|||
public BundleManager(IOptions<BundlingOptions> options) |
|||
{ |
|||
_options = options.Value; |
|||
} |
|||
|
|||
public List<string> GetStyleBundleFiles(string bundleName) |
|||
{ |
|||
return _options.StyleBundles.GetFiles(bundleName); |
|||
} |
|||
|
|||
public List<string> GetScriptBundleFiles(string bundleName) |
|||
{ |
|||
return _options.ScriptBundles.GetFiles(bundleName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.Bundling |
|||
{ |
|||
public class BundlingOptions |
|||
{ |
|||
public BundleCollection StyleBundles { get; set; } |
|||
|
|||
public BundleCollection ScriptBundles { get; set; } |
|||
|
|||
public BundlingOptions() |
|||
{ |
|||
StyleBundles = new BundleCollection(); |
|||
ScriptBundles = new BundleCollection(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Bundling |
|||
{ |
|||
public interface IBundleManager |
|||
{ |
|||
List<string> GetStyleBundleFiles(string bundleName); |
|||
|
|||
List<string> GetScriptBundleFiles(string bundleName); |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.Bundling; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Views.Shared.Components.AbpScriptBundle |
|||
{ |
|||
public class AbpScriptBundleViewComponent : ViewComponent |
|||
{ |
|||
private readonly IBundleManager _bundleManager; |
|||
|
|||
public AbpScriptBundleViewComponent(IBundleManager bundleManager) |
|||
{ |
|||
_bundleManager = bundleManager; |
|||
} |
|||
|
|||
public IViewComponentResult Invoke(string name) |
|||
{ |
|||
var files = _bundleManager.GetScriptBundleFiles(name); |
|||
return View(files); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
@model List<string> |
|||
@foreach (var scriptFile in Model) |
|||
{ |
|||
<script src="@scriptFile" type="text/javascript"></script> |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.Bundling; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Views.Shared.Components.AbpStyleBundle |
|||
{ |
|||
public class AbpStyleBundleViewComponent : ViewComponent |
|||
{ |
|||
private readonly IBundleManager _bundleManager; |
|||
|
|||
public AbpStyleBundleViewComponent(IBundleManager bundleManager) |
|||
{ |
|||
_bundleManager = bundleManager; |
|||
} |
|||
|
|||
public IViewComponentResult Invoke(string name) |
|||
{ |
|||
var files = _bundleManager.GetStyleBundleFiles(name); |
|||
return View(files); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
@model List<string> |
|||
@foreach (var styleFile in Model) |
|||
{ |
|||
<link rel="stylesheet" type="text/css" href="@styleFile" /> |
|||
} |
|||
Loading…
Reference in new issue