From e50cda5478891d503d7f136fc00145a7fb562bc8 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 19 Mar 2020 11:32:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20Blazor=20=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A2=9E=E5=8A=A0=E5=90=8E=E5=8F=B0=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=9C=B0=E5=9D=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Views/Admin/Settings.razor | 67 +++++++++++++++++++ .../Pages/Views/Components/SettingsBase.cs | 37 ++++++++++ 2 files changed, 104 insertions(+) diff --git a/src/admin/Bootstrap.Admin/Pages/Views/Admin/Settings.razor b/src/admin/Bootstrap.Admin/Pages/Views/Admin/Settings.razor index e4eea25e..5f0009ef 100644 --- a/src/admin/Bootstrap.Admin/Pages/Views/Admin/Settings.razor +++ b/src/admin/Bootstrap.Admin/Pages/Views/Admin/Settings.razor @@ -44,6 +44,73 @@ +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + + +
+
+ + +
+ +
+
+
+
+
+
+
+
前台应用设置
+
+ + + +
+
+ @foreach (var app in Model.Apps) + { +
+ +
+ + +
+ + +
+
+
+
+ } +
+
+
+ + + +
网站样式设置
diff --git a/src/admin/Bootstrap.Admin/Pages/Views/Components/SettingsBase.cs b/src/admin/Bootstrap.Admin/Pages/Views/Components/SettingsBase.cs index ccbac2f2..824bb040 100644 --- a/src/admin/Bootstrap.Admin/Pages/Views/Components/SettingsBase.cs +++ b/src/admin/Bootstrap.Admin/Pages/Views/Components/SettingsBase.cs @@ -6,6 +6,7 @@ using Bootstrap.Security.Mvc; using Longbow.Cache; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; +using System; using System.Collections.Generic; using System.Linq; @@ -98,6 +99,22 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components Model.CookiePeriod = DictHelper.RetrieveCookieExpiresPeriod(); Model.IPCachePeriod = DictHelper.RetrieveLocaleIPSvrCachePeriod(); Model.EnableDemo = DictHelper.RetrieveSystemModel(); + + Model.Logins = DictHelper.RetrieveLogins().Select(d => new SelectedItem(){ + Value = d.Code, + Text = d.Name + }); + var view = DictHelper.RetrieveLoginView(); + var viewName = Model.Logins.FirstOrDefault(d => d.Value == view)?.Text ?? "系统默认"; + Model.SelectedLogin = new SelectedItem() { Value = view, Text = viewName }; + Model.AdminPathBase = DictHelper.RetrievePathBase(); + + var dicts = DictHelper.RetrieveDicts(); + Model.Apps = DictHelper.RetrieveApps().Where(d => !d.Key.Equals("BA", StringComparison.OrdinalIgnoreCase)).Select(k => + { + var url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == k.Key && d.Define == 0)?.Code ?? "未设置"; + return (k.Key, k.Value, url); + }); } /// @@ -380,6 +397,26 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components /// 获得 系统是否允许健康检查 /// public bool EnableHealth { get; set; } + + /// + /// 获得/设置 字典表中登录首页集合 + /// + public IEnumerable Logins { get; set; } = new SelectedItem[0]; + + /// + /// 获得/设置 登录视图名称 默认是 Login + /// + public SelectedItem SelectedLogin { get; set; } = new SelectedItem(); + + /// + /// 获得/设置 后台管理网站地址 + /// + public string AdminPathBase { get; set; } = ""; + + /// + /// 获得/设置 系统应用程序集合 + /// + public IEnumerable<(string Key, string Name, string Url)> Apps { get; set; } = new List<(string, string, string)>(); } } } From fb40cfff108430056167e9b834e7c59a3d93add7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 19 Mar 2020 14:14:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20Client=20=E6=BC=94=E7=A4=BA=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80=20Home/Dummy=20?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Helper/MenuHelper.cs | 9 +++++++++ src/client/Bootstrap.Client.DataAccess/Menu.cs | 13 +++++++++++++ src/client/Bootstrap.Client/Startup.cs | 1 + 3 files changed, 23 insertions(+) diff --git a/src/client/Bootstrap.Client.DataAccess/Helper/MenuHelper.cs b/src/client/Bootstrap.Client.DataAccess/Helper/MenuHelper.cs index afcee38c..5f917db0 100644 --- a/src/client/Bootstrap.Client.DataAccess/Helper/MenuHelper.cs +++ b/src/client/Bootstrap.Client.DataAccess/Helper/MenuHelper.cs @@ -37,5 +37,14 @@ namespace Bootstrap.Client.DataAccess /// /// public static IEnumerable RetrieveAllMenus(string userName) => CacheManager.GetOrAdd($"{RetrieveMenusAll}-{userName}", key => DbContextManager.Create()?.RetrieveAllMenus(userName), RetrieveMenusAll) ?? new BootstrapMenu[0]; + + /// + /// 通过当前用户名与指定菜单路径获取此菜单下所有授权按钮集合 (userName, url, auths) => bool + /// + /// 当前操作用户名 + /// 资源按钮所属菜单 + /// 资源授权码 + /// + public static bool AuthorizateButtons(string userName, string url, string auths) => DbContextManager.Create()?.AuthorizateButtons(userName, url, auths) ?? false; } } diff --git a/src/client/Bootstrap.Client.DataAccess/Menu.cs b/src/client/Bootstrap.Client.DataAccess/Menu.cs index 4290212a..98a9ad63 100644 --- a/src/client/Bootstrap.Client.DataAccess/Menu.cs +++ b/src/client/Bootstrap.Client.DataAccess/Menu.cs @@ -15,5 +15,18 @@ namespace Bootstrap.Client.DataAccess /// 当前登录的用户名 /// public virtual IEnumerable RetrieveAllMenus(string userName) => DbHelper.RetrieveAllMenus(userName); + + /// + /// 通过当前用户名与指定菜单路径获取此菜单下所有授权按钮集合 (userName, url, auths) => bool + /// + /// 当前操作用户名 + /// 资源按钮所属菜单 + /// 资源授权码 + /// + public virtual bool AuthorizateButtons(string userName, string url, string auths) + { + var menus = MenuHelper.RetrieveAllMenus(userName); + return DbHelper.AuthorizateButtons(menus, url, auths); + } } } diff --git a/src/client/Bootstrap.Client/Startup.cs b/src/client/Bootstrap.Client/Startup.cs index 097eae0d..49009d26 100644 --- a/src/client/Bootstrap.Client/Startup.cs +++ b/src/client/Bootstrap.Client/Startup.cs @@ -49,6 +49,7 @@ namespace Bootstrap.Client services.AddOnlineUsers(); services.AddBootstrapAdminAuthentication(Configuration); services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireBootstrapAdminAuthorizate().Build()); + services.AddButtonAuthorization(MenuHelper.AuthorizateButtons); services.AddControllersWithViews(options => {