mirror of https://github.com/abpframework/abp.git
15 changed files with 161 additions and 49 deletions
@ -0,0 +1,14 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
public class BundleFile |
||||
|
{ |
||||
|
public string File { get; set; } |
||||
|
|
||||
|
public bool IsCdn { get; set; } |
||||
|
|
||||
|
public BundleFile(string file, bool isCdn = false) |
||||
|
{ |
||||
|
File = file; |
||||
|
IsCdn = isCdn; |
||||
|
} |
||||
|
} |
||||
@ -1,22 +1,30 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
public class BundleFileContributor : BundleContributor |
public class BundleFileContributor : BundleContributor |
||||
{ |
{ |
||||
public string[] Files { get; } |
public List<BundleFile> Files { get; } |
||||
|
|
||||
|
public BundleFileContributor(params BundleFile[] files) |
||||
|
{ |
||||
|
Files = new List<BundleFile>(); |
||||
|
Files.AddRange(files); |
||||
|
} |
||||
|
|
||||
public BundleFileContributor(params string[] files) |
public BundleFileContributor(params string[] files) |
||||
{ |
{ |
||||
Files = files ?? Array.Empty<string>(); |
Files = new List<BundleFile>(); |
||||
|
Files.AddRange(files.Select(file => new BundleFile(file))); |
||||
} |
} |
||||
|
|
||||
public override void ConfigureBundle(BundleConfigurationContext context) |
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
{ |
{ |
||||
foreach (var file in Files) |
foreach (var file in Files) |
||||
{ |
{ |
||||
context.Files.AddIfNotContains(x => x.Equals(file, StringComparison.OrdinalIgnoreCase), () => file); |
context.Files.AddIfNotContains(x => x.File.Equals(file.File, StringComparison.OrdinalIgnoreCase), () => file); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,32 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// This class is used to compatible with old code.
|
||||
|
/// </summary>
|
||||
|
public static class BundleFileListExtensions |
||||
|
{ |
||||
|
public static void Add(this List<BundleFile> bundleFiles, params string[] files) |
||||
|
{ |
||||
|
bundleFiles.AddRange(files.Select(file => new BundleFile(file))); |
||||
|
} |
||||
|
|
||||
|
public static void AddRange(this List<BundleFile> bundleFiles, params string[] files) |
||||
|
{ |
||||
|
bundleFiles.AddRange(files.Select(file => new BundleFile(file))); |
||||
|
} |
||||
|
|
||||
|
public static void AddIfNotContains(this List<BundleFile> bundleFiles, params string[] files) |
||||
|
{ |
||||
|
foreach (var file in files) |
||||
|
{ |
||||
|
if (!bundleFiles.Any(x => x.File.Equals(file, StringComparison.OrdinalIgnoreCase))) |
||||
|
{ |
||||
|
bundleFiles.Add(new BundleFile(file)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,8 +1,9 @@ |
|||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Resources; |
namespace Volo.Abp.AspNetCore.Mvc.UI.Resources; |
||||
|
|
||||
public interface IWebRequestResources |
public interface IWebRequestResources |
||||
{ |
{ |
||||
List<string> TryAdd(List<string> resources); |
List<BundleFile> TryAdd(List<BundleFile> resources); |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue