mirror of https://github.com/abpframework/abp.git
committed by
GitHub
20 changed files with 329 additions and 70 deletions
@ -0,0 +1,31 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
public class BundleFile |
||||
|
{ |
||||
|
public string FileName { get; set; } |
||||
|
|
||||
|
public bool IsExternalFile { get; set; } |
||||
|
|
||||
|
public BundleFile(string fileName) |
||||
|
{ |
||||
|
FileName = fileName; |
||||
|
IsExternalFile = fileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || |
||||
|
fileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase); |
||||
|
} |
||||
|
|
||||
|
public BundleFile(string fileName, bool isExternalFile) |
||||
|
{ |
||||
|
FileName = fileName; |
||||
|
IsExternalFile = isExternalFile; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// This method is used to compatible with old code.
|
||||
|
/// </summary>
|
||||
|
public static implicit operator BundleFile(string fileName) |
||||
|
{ |
||||
|
return new BundleFile(fileName); |
||||
|
} |
||||
|
} |
||||
@ -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.FileName.Equals(file.FileName, StringComparison.OrdinalIgnoreCase), () => 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