Browse Source
Update `AbpStyles` and `AbpScripts` to support `WebAssembly` assets.
pull/18876/head
maliming
3 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
11 changed files with
66 additions and
18 deletions
-
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpScripts.razor
-
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpStyles.razor
-
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/WebAssemblyComponentBundleManager.cs
-
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Client/MyCompanyName.MyProjectName.Blazor.Client.csproj
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Client/MyCompanyName.MyProjectName.Blazor.WebApp.Client.csproj
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client.csproj
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered/Components/App.razor
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.csproj
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp/Components/App.razor
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp/MyCompanyName.MyProjectName.Blazor.WebApp.csproj
|
|
|
@ -10,17 +10,26 @@ |
|
|
|
} |
|
|
|
|
|
|
|
@code { |
|
|
|
private IReadOnlyList<string>? ScriptFiles { get; set; } |
|
|
|
[Parameter] |
|
|
|
public List<string>? WebAssemblyScriptFiles { get; set; } |
|
|
|
|
|
|
|
[Parameter] |
|
|
|
public string? BundleName { get; set; } |
|
|
|
|
|
|
|
private List<string>? ScriptFiles { get; set; } |
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync() |
|
|
|
{ |
|
|
|
if (OperatingSystem.IsBrowser() && WebAssemblyScriptFiles != null) |
|
|
|
{ |
|
|
|
ScriptFiles = WebAssemblyScriptFiles; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (BundleName == null) |
|
|
|
{ |
|
|
|
throw new AbpException("The BundleName parameter of the AbpScripts component can not be null!"); |
|
|
|
} |
|
|
|
ScriptFiles = await BundleManager.GetScriptBundleFilesAsync(BundleName!); |
|
|
|
ScriptFiles = (await BundleManager.GetScriptBundleFilesAsync(BundleName!)).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -10,18 +10,26 @@ |
|
|
|
} |
|
|
|
|
|
|
|
@code { |
|
|
|
private IReadOnlyList<string>? StyleFiles { get; set; } |
|
|
|
[Parameter] |
|
|
|
public List<string>? WebAssemblyStyleFiles { get; set; } |
|
|
|
|
|
|
|
[Parameter] |
|
|
|
public string? BundleName { get; set; } |
|
|
|
|
|
|
|
private List<string>? StyleFiles { get; set; } |
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync() |
|
|
|
{ |
|
|
|
if (OperatingSystem.IsBrowser() && WebAssemblyStyleFiles != null) |
|
|
|
{ |
|
|
|
StyleFiles = WebAssemblyStyleFiles; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (BundleName == null) |
|
|
|
{ |
|
|
|
throw new AbpException("The BundleName parameter of the AbpStyles component can not be null!"); |
|
|
|
} |
|
|
|
|
|
|
|
StyleFiles = await BundleManager.GetStyleBundleFilesAsync(BundleName!); |
|
|
|
StyleFiles = (await BundleManager.GetStyleBundleFilesAsync(BundleName!)).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -9,11 +9,11 @@ public class WebAssemblyComponentBundleManager : IComponentBundleManager, ITrans |
|
|
|
{ |
|
|
|
public virtual Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName) |
|
|
|
{ |
|
|
|
return Task.FromResult<IReadOnlyList<string>>(new List<string> {"global.css", "main.css"}); |
|
|
|
return Task.FromResult<IReadOnlyList<string>>(new List<string>()); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName) |
|
|
|
{ |
|
|
|
return Task.FromResult<IReadOnlyList<string>>(new List<string> {"global.js"}); |
|
|
|
return Task.FromResult<IReadOnlyList<string>>(new List<string>()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -462,6 +462,10 @@ public abstract class ProjectCreationCommandBase |
|
|
|
{ |
|
|
|
path = Path.Combine(path, "host"); |
|
|
|
searchPattern = "*.Blazor.Host.csproj"; |
|
|
|
if (Directory.GetFiles(path, "*.Blazor.Host.Client.csproj", SearchOption.AllDirectories).Any()) |
|
|
|
{ |
|
|
|
searchPattern = "*.Blazor.Host.Client.csproj"; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (MicroserviceTemplateBase.IsMicroserviceTemplate(projectArgs.TemplateName)) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -24,7 +24,7 @@ |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel.WebAssembly\Volo.Abp.Http.Client.IdentityModel.WebAssembly.csproj" /> |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Web.Theming\Volo.Abp.AspNetCore.Components.Web.Theming.csproj" /> |
|
|
|
<!-- </TEMPLATE-REMOVE> --> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme" Version="3.0.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme" Version="3.1.*-*" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel.WebAssembly\Volo.Abp.Http.Client.IdentityModel.WebAssembly.csproj" /> |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Web.Theming\Volo.Abp.AspNetCore.Components.Web.Theming.csproj" /> |
|
|
|
<!-- </TEMPLATE-REMOVE> --> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme" Version="3.0.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme" Version="3.1.*-*" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel.WebAssembly\Volo.Abp.Http.Client.IdentityModel.WebAssembly.csproj" /> |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Web.Theming\Volo.Abp.AspNetCore.Components.Web.Theming.csproj" /> |
|
|
|
<!-- </TEMPLATE-REMOVE> --> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme" Version="3.0.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme" Version="3.1.*-*" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
|
|
|
|
@ -20,7 +20,7 @@ |
|
|
|
<title>MyCompanyName.MyProjectName.Blazor.Server</title> |
|
|
|
<base href="/" /> |
|
|
|
|
|
|
|
<AbpStyles BundleName="@BlazorLeptonXLiteThemeBundles.Styles.Global" @rendermode="InteractiveAuto" /> |
|
|
|
<AbpStyles BundleName="@BlazorLeptonXLiteThemeBundles.Styles.Global" WebAssemblyStyleFiles="GlobalStyles" @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
<HeadOutlet @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
@ -29,7 +29,7 @@ |
|
|
|
|
|
|
|
<Routes @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
<AbpScripts BundleName="@BlazorLeptonXLiteThemeBundles.Scripts.Global" @rendermode="InteractiveAuto" /> |
|
|
|
<AbpScripts BundleName="@BlazorLeptonXLiteThemeBundles.Scripts.Global" WebAssemblyScriptFiles="GlobalScripts" @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
<script src="_framework/blazor.web.js"></script> |
|
|
|
|
|
|
|
@ -50,6 +50,19 @@ |
|
|
|
</html> |
|
|
|
|
|
|
|
@code{ |
|
|
|
private List<string> GlobalStyles => |
|
|
|
[ |
|
|
|
"global.css", |
|
|
|
"main.css", |
|
|
|
"blazor-global-styles.css" |
|
|
|
]; |
|
|
|
|
|
|
|
private List<string> GlobalScripts => |
|
|
|
[ |
|
|
|
"global.js", |
|
|
|
"global.js" |
|
|
|
]; |
|
|
|
|
|
|
|
[CascadingParameter] |
|
|
|
private HttpContext HttpContext { get; set; } = default!; |
|
|
|
|
|
|
|
|
|
|
|
@ -32,8 +32,8 @@ |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Server.Theming\Volo.Abp.AspNetCore.Components.Server.Theming.csproj" /> |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Web.Theming\Volo.Abp.AspNetCore.Components.Web.Theming.csproj" /> |
|
|
|
<!-- </TEMPLATE-REMOVE> --> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme" Version="3.0.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="3.0.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme" Version="3.1.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="3.1.*-*" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
|
|
|
|
@ -17,7 +17,7 @@ |
|
|
|
<title>MyCompanyName.MyProjectName.Blazor.Server</title> |
|
|
|
<base href="/" /> |
|
|
|
|
|
|
|
<AbpStyles BundleName="@BlazorLeptonXLiteThemeBundles.Styles.Global" @rendermode="InteractiveAuto" /> |
|
|
|
<AbpStyles BundleName="@BlazorLeptonXLiteThemeBundles.Styles.Global" WebAssemblyStyleFiles="GlobalStyles" @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
<HeadOutlet @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
@ -26,7 +26,7 @@ |
|
|
|
|
|
|
|
<Routes @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
<AbpScripts BundleName="@BlazorLeptonXLiteThemeBundles.Scripts.Global" @rendermode="InteractiveAuto" /> |
|
|
|
<AbpScripts BundleName="@BlazorLeptonXLiteThemeBundles.Scripts.Global" WebAssemblyScriptFiles="GlobalScripts" @rendermode="InteractiveAuto" /> |
|
|
|
|
|
|
|
<script src="_framework/blazor.web.js"></script> |
|
|
|
|
|
|
|
@ -45,3 +45,17 @@ |
|
|
|
|
|
|
|
</body> |
|
|
|
</html> |
|
|
|
@code{ |
|
|
|
private List<string> GlobalStyles => |
|
|
|
[ |
|
|
|
"global.css", |
|
|
|
"main.css", |
|
|
|
"blazor-global-styles.css" |
|
|
|
]; |
|
|
|
|
|
|
|
private List<string> GlobalScripts => |
|
|
|
[ |
|
|
|
"global.js", |
|
|
|
"global.js" |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
@ -30,8 +30,8 @@ |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Server.Theming\Volo.Abp.AspNetCore.Components.Server.Theming.csproj" /> |
|
|
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Web.Theming\Volo.Abp.AspNetCore.Components.Web.Theming.csproj" /> |
|
|
|
<!-- </TEMPLATE-REMOVE> --> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme" Version="3.0.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="3.0.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme" Version="3.1.*-*" /> |
|
|
|
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="3.1.*-*" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
|