mirror of https://github.com/abpframework/abp.git
17 changed files with 139 additions and 82 deletions
@ -1,26 +0,0 @@ |
|||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|
||||
@inject IBundleManager BundleManager |
|
||||
|
|
||||
@if (ScriptBundleFiles != null) |
|
||||
{ |
|
||||
foreach (var bundleFile in ScriptBundleFiles) |
|
||||
{ |
|
||||
<script src="@bundleFile.FileName"></script> |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@code { |
|
||||
private IReadOnlyList<BundleFile>? ScriptBundleFiles { get; set; } |
|
||||
|
|
||||
[Parameter] |
|
||||
public string? BundleName { get; set; } |
|
||||
|
|
||||
protected override async Task OnInitializedAsync() |
|
||||
{ |
|
||||
if (BundleName == null) |
|
||||
{ |
|
||||
throw new AbpException("The BundleName parameter of the AbpScripts component can not be null!"); |
|
||||
} |
|
||||
ScriptBundleFiles = await BundleManager.GetScriptBundleFilesAsync(BundleName!); |
|
||||
} |
|
||||
} |
|
||||
@ -1,26 +0,0 @@ |
|||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|
||||
@inject IBundleManager BundleManager |
|
||||
|
|
||||
@if (StyleBundleFiles != null) |
|
||||
{ |
|
||||
foreach (var bundleFile in StyleBundleFiles) |
|
||||
{ |
|
||||
<link rel="stylesheet" href="@bundleFile.FileName" /> |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@code { |
|
||||
private IReadOnlyList<BundleFile>? StyleBundleFiles { get; set; } |
|
||||
|
|
||||
[Parameter] |
|
||||
public string? BundleName { get; set; } |
|
||||
|
|
||||
protected override async Task OnInitializedAsync() |
|
||||
{ |
|
||||
if (BundleName == null) |
|
||||
{ |
|
||||
throw new AbpException("The BundleName parameter of the AbpStyles component can not be null!"); |
|
||||
} |
|
||||
StyleBundleFiles = await BundleManager.GetStyleBundleFilesAsync(BundleName!); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,28 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling; |
||||
|
|
||||
|
public class BlazorServerComponentBundleManager : IComponentBundleManager, ITransientDependency |
||||
|
{ |
||||
|
protected IBundleManager BundleManager { get; } |
||||
|
|
||||
|
public BlazorServerComponentBundleManager(IBundleManager bundleManager) |
||||
|
{ |
||||
|
BundleManager = bundleManager; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName) |
||||
|
{ |
||||
|
return (await BundleManager.GetStyleBundleFilesAsync(bundleName)).Select(f => f.FileName).ToList(); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName) |
||||
|
{ |
||||
|
return (await BundleManager.GetScriptBundleFilesAsync(bundleName)).Select(f => f.FileName).ToList(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
@using Volo.Abp |
||||
|
@inject IComponentBundleManager BundleManager |
||||
|
|
||||
|
@if (ScriptFiles != null) |
||||
|
{ |
||||
|
foreach (var file in ScriptFiles) |
||||
|
{ |
||||
|
<script src="@file"></script> |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@code { |
||||
|
private IReadOnlyList<string>? ScriptFiles { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public string? BundleName { get; set; } |
||||
|
|
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
if (BundleName == null) |
||||
|
{ |
||||
|
throw new AbpException("The BundleName parameter of the AbpScripts component can not be null!"); |
||||
|
} |
||||
|
ScriptFiles = await BundleManager.GetScriptBundleFilesAsync(BundleName!); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
@using Volo.Abp |
||||
|
@inject IComponentBundleManager BundleManager |
||||
|
|
||||
|
@if (StyleFiles != null) |
||||
|
{ |
||||
|
foreach (var file in StyleFiles) |
||||
|
{ |
||||
|
<link rel="stylesheet" href="@file"/> |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@code { |
||||
|
private IReadOnlyList<string>? StyleFiles { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public string? BundleName { get; set; } |
||||
|
|
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
if (BundleName == null) |
||||
|
{ |
||||
|
throw new AbpException("The BundleName parameter of the AbpStyles component can not be null!"); |
||||
|
} |
||||
|
|
||||
|
StyleFiles = await BundleManager.GetStyleBundleFilesAsync(BundleName!); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.Web.Theming.Bundling; |
||||
|
|
||||
|
public interface IComponentBundleManager |
||||
|
{ |
||||
|
Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName); |
||||
|
|
||||
|
Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName); |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming.Bundling; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming; |
||||
|
|
||||
|
public class WebAssemblyComponentBundleManager : IComponentBundleManager, ITransientDependency |
||||
|
{ |
||||
|
public virtual Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName) |
||||
|
{ |
||||
|
return Task.FromResult<IReadOnlyList<string>>(new List<string> {"global.css", "main.css"}); |
||||
|
} |
||||
|
|
||||
|
public virtual Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName) |
||||
|
{ |
||||
|
return Task.FromResult<IReadOnlyList<string>>(new List<string> {"global.js"}); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue