chore: 更改 Blazor 客户端示例
|
@ -5,6 +5,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
|
@ -3,7 +3,10 @@ using BootstrapAdmin.Web.Core;
|
|||
|
||||
namespace BootstrapAdmin.Web.Services
|
||||
{
|
||||
class AdminService : IBootstrapAdminService
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class AdminService : IBootstrapAdminService
|
||||
{
|
||||
private IUsers User { get; set; }
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using BootstrapAdmin.DataAccess.Models;
|
||||
using BootstrapBlazor.Components;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
|
||||
namespace BootstrapAdmin.Web.Extensions
|
|
@ -5,7 +5,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Blazor" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ namespace BootstrapAdmin.Web.Shared
|
|||
|
||||
private string? DisplayName { get; set; }
|
||||
|
||||
private bool Login { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OnInitializedAsync 方法
|
||||
/// </summary>
|
||||
|
@ -61,8 +59,6 @@ namespace BootstrapAdmin.Web.Shared
|
|||
Context.DisplayName = DisplayName;
|
||||
|
||||
MenuItems = NavigationsService.GetAllMenus(userName).ToAdminMenus();
|
||||
|
||||
Login = true;
|
||||
}
|
||||
|
||||
Title = DictsService.GetWebTitle();
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
"DetailedErrors": true,
|
||||
"SimulateUserName": "",
|
||||
"AutoGenerateDatabase": true,
|
||||
"BootstrapAdminAuthenticationOptions": {
|
||||
"KeyPath": "..\\..\\keys"
|
||||
},
|
||||
"DB": [
|
||||
{
|
||||
"Enabled": false,
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="@typeof(MainLayout).Assembly" PreferExactMatches="@true">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
||||
</AuthorizeRouteView>
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<p>Sorry, there's nothing at this address.</p>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
</CascadingAuthenticationState>
|
|
@ -1,122 +0,0 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.Mvc;
|
||||
using BootstrapBlazor.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bootstrap.Client.Blazor.Shared.Shared
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public sealed partial class MainLayout
|
||||
{
|
||||
private bool UseTabSet { get; set; } = true;
|
||||
|
||||
private string Theme { get; set; } = "";
|
||||
|
||||
private bool IsOpen { get; set; }
|
||||
|
||||
private bool IsFixedHeader { get; set; } = true;
|
||||
|
||||
private bool IsFixedFooter { get; set; } = true;
|
||||
|
||||
private bool IsFullSide { get; set; } = true;
|
||||
|
||||
private bool ShowFooter { get; set; } = true;
|
||||
|
||||
[NotNull]
|
||||
private List<MenuItem>? Menus { get; set; }
|
||||
|
||||
[NotNull]
|
||||
private Dictionary<string, string>? TabItemTextDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得 当前用户登录显示名称
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public string? DisplayName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得 当前用户登录名
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public string? UserName { get; private set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private AuthenticationStateProvider? AuthenticationStateProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OnInitialized 方法
|
||||
/// </summary>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
// 通过当前登录名获取显示名称
|
||||
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
if (state.User.Identity?.IsAuthenticated ?? false)
|
||||
{
|
||||
UserName = state.User.Identity.Name;
|
||||
DisplayName = UserHelper.RetrieveUserByUserName(UserName)?.DisplayName;
|
||||
|
||||
// 模拟异步线程切换,正式代码中删除此行代码
|
||||
await Task.Yield();
|
||||
|
||||
// 菜单获取可以通过数据库获取,此处为示例直接拼装的菜单集合
|
||||
TabItemTextDictionary = new()
|
||||
{
|
||||
[""] = "Index"
|
||||
};
|
||||
|
||||
// 获取登录用户菜单
|
||||
Menus = GetMenus();
|
||||
}
|
||||
}
|
||||
|
||||
private List<MenuItem> GetMenus()
|
||||
{
|
||||
var menus = new List<MenuItem>();
|
||||
|
||||
if (OperatingSystem.IsBrowser())
|
||||
{
|
||||
// 需要调用 webapi 获取菜单数据 暂未实现
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = MenuHelper.RetrieveAppMenus(UserName, "");
|
||||
menus = CascadeMenu(data);
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
private List<MenuItem> CascadeMenu(IEnumerable<BootstrapMenu> datasource)
|
||||
{
|
||||
var menus = new List<MenuItem>();
|
||||
foreach (var m in datasource)
|
||||
{
|
||||
var item = new MenuItem()
|
||||
{
|
||||
Text = m.Name,
|
||||
Url = m.Url.TrimStart('~'),
|
||||
Target = m.Target,
|
||||
Icon = m.Icon
|
||||
};
|
||||
menus.Add(item);
|
||||
|
||||
if (m.Menus.Any())
|
||||
{
|
||||
item.Items = CascadeMenu(m.Menus);
|
||||
}
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Bootstrap.Client.Blazor.Shared.Shared
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class RedirectToLogin : ComponentBase
|
||||
{
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IConfiguration? Configuration { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private NavigationManager? Navigator { get; set; }
|
||||
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// OnAfterRender 方法
|
||||
/// </summary>
|
||||
/// <param name="firstRender"></param>
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
base.OnAfterRender(firstRender);
|
||||
|
||||
var option = Configuration.GetBootstrapAdminAuthenticationOptions();
|
||||
Navigator.NavigateTo(option.AuthHost, true);
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// OnInitialized 方法
|
||||
/// </summary>
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
var option = Configuration.GetBootstrapAdminAuthenticationOptions();
|
||||
Navigator.NavigateTo(option.AuthHost, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<IsWebProject>true</IsWebProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Bootstrap.Client.Blazor.Shared\Bootstrap.Client.Blazor.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,37 +0,0 @@
|
|||
@page "/"
|
||||
@using Bootstrap.Client.Blazor.Shared
|
||||
@namespace Bootstrap.Client.Blazor.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Bootstrap Blazor Server App</title>
|
||||
<base href="~/" />
|
||||
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css">
|
||||
<link rel="stylesheet" href="_content/Bootstrap.Client.Blazor.Shared/css/site.css">
|
||||
</head>
|
||||
<body>
|
||||
<component type="typeof(App)" render-mode="ServerPrerendered" />
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
<environment include="Staging,Production">
|
||||
An error has occurred. This application may no longer respond until reloaded.
|
||||
</environment>
|
||||
<environment include="Development">
|
||||
An unhandled exception has occurred. See browser dev tools for details.
|
||||
</environment>
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
<script src="_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,32 +0,0 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Bootstrap.Client.Blazor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
|
||||
namespace Bootstrap.Client.Blazor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class Startup
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCacheManager();
|
||||
services.AddDbAdapter();
|
||||
services.AddControllersWithViews();
|
||||
services.AddBootstrapAdminAuthentication(Configuration);
|
||||
services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireBootstrapAdminAuthorizate().Build());
|
||||
services.AddRazorPages();
|
||||
services.AddServerSideBlazor();
|
||||
services.AddBootstrapBlazor();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="env"></param>
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseCors(builder => builder.WithOrigins(Configuration["AllowOrigins"].Split(',', StringSplitOptions.RemoveEmptyEntries)).AllowAnyHeader().AllowAnyMethod().AllowCredentials());
|
||||
app.UseBootstrapAdminAuthentication(RoleHelper.RetrievesByUserName, RoleHelper.RetrievesByUrl, AppHelper.RetrievesByUserName);
|
||||
app.UseAuthorization();
|
||||
app.UseCacheManager();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapDefaultControllerRoute();
|
||||
endpoints.MapBlazorHub();
|
||||
endpoints.MapFallbackToPage("/_Host");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\admin\BootstrapAdmin.DataAccess.PetaPoco\BootstrapAdmin.DataAccess.PetaPoco.csproj" />
|
||||
<ProjectReference Include="..\..\admin\BootstrapAdmin.Web.Core\BootstrapAdmin.Web.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,15 @@
|
|||
<BootstrapBlazorRoot>
|
||||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="@typeof(MainLayout).Assembly" PreferExactMatches="@true">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
||||
</AuthorizeRouteView>
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<p>Sorry, there's nothing at this address.</p>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
</CascadingAuthenticationState>
|
||||
</BootstrapBlazorRoot>
|
|
@ -5,13 +5,12 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor" Version="5.16.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="5.0.11" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.11" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\mvc\client\Bootstrap.Client.DataAccess\Bootstrap.Client.DataAccess.csproj" />
|
||||
<ProjectReference Include="..\BootstrapClient.DataAccess\BootstrapClient.Web.DataAccess.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
<Layout SideWidth="0" IsPage="true" ShowGotoTop="true" ShowCollapseBar="true"
|
||||
IsFullSide="@IsFullSide" IsFixedHeader="@IsFixedHeader" IsFixedFooter="@IsFixedFooter" ShowFooter="@ShowFooter"
|
||||
Menus="@Menus" UseTabSet="@UseTabSet" TabItemTextDictionary="@TabItemTextDictionary" AdditionalAssemblies="new[] { GetType().Assembly }" class="@Theme">
|
||||
Menus="@MenuItems" UseTabSet="@UseTabSet" TabItemTextDictionary="@TabItemTextDictionary"
|
||||
AdditionalAssemblies="new[] { GetType().Assembly }" OnAuthorizing="@OnAuthorizing" class="@Theme">
|
||||
<Header>
|
||||
<span class="ml-3 flex-sm-fill d-none d-sm-block">Bootstrap of Blazor</span>
|
||||
<Widget></Widget>
|
||||
|
@ -14,7 +15,7 @@
|
|||
<div class="layout-banner">
|
||||
<img class="layout-logo" src="_content/Bootstrap.Client.Blazor.Shared/images/brand.png" />
|
||||
<div class="layout-title">
|
||||
<span>后台管理</span>
|
||||
<span>@Title</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-user">
|
||||
|
@ -32,11 +33,11 @@
|
|||
</Main>
|
||||
<Footer>
|
||||
<div class="text-center flex-fill">
|
||||
<a class="page-layout-demo-footer-link" href="https://gitee.com/LongbowEnterprise/BootstrapAdmin" target="_blank">Bootstrap Admin</a>
|
||||
<a class="page-layout-demo-footer-link" href="https://gitee.com/LongbowEnterprise/BootstrapAdmin" target="_blank">@Footer</a>
|
||||
</div>
|
||||
</Footer>
|
||||
<NotAuthorized>
|
||||
<RedirectToLogin />
|
||||
<Redirect Url="@GetAuthorUrl()" />
|
||||
</NotAuthorized>
|
||||
</Layout>
|
||||
|
||||
|
@ -141,9 +142,3 @@
|
|||
</div>
|
||||
</div>
|
||||
</Drawer>
|
||||
|
||||
<Toast />
|
||||
<Dialog />
|
||||
<PopoverConfirm />
|
||||
<Message />
|
||||
<SweetAlert />
|
|
@ -0,0 +1,101 @@
|
|||
using Bootstrap.Security.Blazor;
|
||||
using BootstrapAdmin.Web.Core;
|
||||
using BootstrapAdmin.Web.Extensions;
|
||||
using BootstrapBlazor.Components;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace BootstrapClient.Web.Shared.Shared
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public sealed partial class MainLayout
|
||||
{
|
||||
private bool UseTabSet { get; set; } = true;
|
||||
|
||||
private string Theme { get; set; } = "";
|
||||
|
||||
private bool IsOpen { get; set; }
|
||||
|
||||
private bool IsFixedHeader { get; set; } = true;
|
||||
|
||||
private bool IsFixedFooter { get; set; } = true;
|
||||
|
||||
private bool IsFullSide { get; set; } = true;
|
||||
|
||||
private bool ShowFooter { get; set; } = true;
|
||||
|
||||
private IEnumerable<MenuItem>? MenuItems { get; set; }
|
||||
|
||||
[NotNull]
|
||||
private Dictionary<string, string>? TabItemTextDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得 当前用户登录显示名称
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public string? DisplayName { get; private set; }
|
||||
|
||||
private string? Title { get; set; }
|
||||
|
||||
private string? Footer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得 当前用户登录名
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public string? UserName { get; private set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IBootstrapAdminService? SecurityService { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private AuthenticationStateProvider? AuthenticationStateProvider { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IDicts? DictsService { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IUsers? UsersService { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private INavigations? NavigationsService { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IOptions<BootstrapAdminAuthenticationOptions>? AuthorizationOption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OnInitialized 方法
|
||||
/// </summary>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
var userName = state.User.Identity?.Name;
|
||||
|
||||
if (!string.IsNullOrEmpty(userName))
|
||||
{
|
||||
UserName = userName;
|
||||
DisplayName = UsersService.GetDisplayName(userName);
|
||||
|
||||
MenuItems = NavigationsService.GetAllMenus(userName).ToClientMenus();
|
||||
|
||||
Title = DictsService.GetWebTitle();
|
||||
Footer = DictsService.GetWebFooter();
|
||||
}
|
||||
}
|
||||
|
||||
private Task<bool> OnAuthorizing(string url) => SecurityService.AuhorizingNavigation(UserName, url);
|
||||
|
||||
private string GetAuthorUrl() => $"{AuthorizationOption.Value.AuthHost}/Account/Login";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
@using Bootstrap.Client.Blazor.Shared.Shared
|
||||
@using BootstrapClient.Web.Shared.Shared
|
||||
@using BootstrapBlazor.Components
|
||||
|
||||
@using Microsoft.AspNetCore.Authorization
|
Before Width: | Height: | Size: 523 KiB After Width: | Height: | Size: 523 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<IsWebProject>true</IsWebProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BootstrapClient.Shared\BootstrapClient.Web.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="BootstrapBlazor.Components" />
|
||||
<Using Include="Microsoft.AspNetCore.Components" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,34 @@
|
|||
using BootstrapAdmin.Web.Services;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class ServicesExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加示例后台任务
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public static IServiceCollection AddBootstrapBlazorClient(this IServiceCollection services)
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
|
||||
services.AddCors();
|
||||
services.AddResponseCompression();
|
||||
|
||||
// 增加 BootstrapBlazor 组件
|
||||
services.AddBootstrapBlazor();
|
||||
|
||||
// 增加认证授权服务
|
||||
services.AddBootstrapAdminSecurity<AdminService>();
|
||||
|
||||
// 增加 PetaPoco 数据服务
|
||||
services.AddPetaPocoDataAccessServices();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
@page "/"
|
||||
@using BootstrapClient.Web.Shared
|
||||
@namespace BootstrapAdmin.Client.Blazor.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
||||
<component type="typeof(App)" render-mode="ServerPrerendered" />
|
|
@ -0,0 +1,40 @@
|
|||
@using Microsoft.AspNetCore.Components.Web
|
||||
@namespace BootstrapAdmin.Client.Blazor.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="~/favicon.ico" type="image/x-icon" />
|
||||
<link rel="apple-touch-icon" href="~/favicon.png" />
|
||||
<base href="~/" />
|
||||
<link href="libs/font-awesome/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css" rel="stylesheet">
|
||||
<link href="_content/BootstrapBlazor/css/motronic.min.css" rel="stylesheet">
|
||||
<link href="_content/BootstrapClient.Web.Shared/css/site.css" rel="stylesheet" />
|
||||
|
||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
<environment include="Staging,Production">
|
||||
An error has occurred. This application may no longer respond until reloaded.
|
||||
</environment>
|
||||
<environment include="Development">
|
||||
An unhandled exception has occurred. See browser dev tools for details.
|
||||
</environment>
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
<script src="_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,32 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
|
||||
// 注入项目服务
|
||||
builder.Services.AddBootstrapBlazorClient();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
// 开启 webapi
|
||||
app.MapDefaultControllerRoute();
|
||||
app.MapBlazorHub();
|
||||
app.MapFallbackToPage("/_Host");
|
||||
|
||||
app.Run();
|
|
@ -6,6 +6,6 @@
|
|||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using Bootstrap.Client.Blazor
|
||||
@using Bootstrap.Client.Blazor.Shared
|
||||
@using Bootstrap.Client.Blazor.Shared.Shared
|
||||
@using BootstrapClient.Web
|
||||
@using BootstrapClient.Web.Shared
|
||||
@using BootstrapClient.Web.Shared.Shared
|
|
@ -8,14 +8,10 @@
|
|||
}
|
||||
},
|
||||
"AppId": "Demo",
|
||||
"SimulateUserName": "Admin",
|
||||
"SimulateUserName": "",
|
||||
"BootstrapAdminAuthenticationOptions": {
|
||||
"AuthHost": "http://localhost:50852",
|
||||
"KeyPath": "..\\..\\admin\\keys"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa",
|
||||
"client": "Data Source=Client.db;"
|
||||
"AuthHost": "http://localhost:5110",
|
||||
"KeyPath": "..\\..\\keys"
|
||||
},
|
||||
"DB": [
|
||||
{
|
||||
|
@ -25,7 +21,7 @@
|
|||
"Enabled": true,
|
||||
"ProviderName": "Sqlite",
|
||||
"ConnectionStrings": {
|
||||
"ba": "Data Source=..\\..\\admin\\Bootstrap.Admin\\BootstrapAdmin.db;",
|
||||
"bb": "..\\..\\admin\\BootstrapAdmin.Web\\BootstrapAdmin.db;",
|
||||
"client": "Data Source=Client.db;"
|
||||
}
|
||||
},
|
|
@ -14,6 +14,7 @@
|
|||
},
|
||||
"ConnectionStrings": {
|
||||
"ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa",
|
||||
"bb": "..\\..\\admin\\BootstrapAdmin.Web\\BootstrapAdmin.db;",
|
||||
"client": "Data Source=Client.db;"
|
||||
},
|
||||
"DB": [
|
||||
|
@ -24,7 +25,7 @@
|
|||
"Enabled": true,
|
||||
"ProviderName": "Sqlite",
|
||||
"ConnectionStrings": {
|
||||
"ba": "Data Source=..\\BA\\BootstrapAdmin.db;",
|
||||
"ba": "Data Source=..\\..\\admin\\BootstrapAdmin.Web\\BootstrapAdmin.db;",
|
||||
"client": "Data Source=Client.db;"
|
||||
}
|
||||
},
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
4
src/blazor/client/BootstrapClient.Web/wwwroot/libs/font-awesome/css/font-awesome.min.css
vendored
Normal file
After Width: | Height: | Size: 434 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |