!82 增加功能:合并分支到 master

Merge pull request !82 from Argo/dev
This commit is contained in:
Argo 2020-03-20 10:48:30 +08:00 committed by Gitee
commit 2422950925
5 changed files with 127 additions and 0 deletions

View File

@ -44,6 +44,73 @@
</div>
</div>
</ConditionComponent>
<div class="card">
<div class="card-header"><label class="control-label" data-toggle="lgbinfo" data-content="通过此功能进行整个网站的登录界面设置">后台管理登录地址设置</label></div>
<div class="card-body">
<div class="form-group">
<div class="form-group text-right">
<div class="btn-group" role="group">
<Dropdown @bind-Value="@Model.SelectedLogin" Items="@Model.Logins"></Dropdown>
<button class="btn btn-secondary" type="button">保存</button>
</div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header"><label class="control-label" data-toggle="lgbinfo" data-content="此功能给前台网站拼接后台功能菜单时使用">后台管理地址设置</label></div>
<div class="card-body" data-toggle="LgbValidate" data-valid-button="[data-method='appPath']">
<ConditionComponent>
<div class="alert alert-danger" role="alert">
<span>演示系统禁止更改后台管理地址</span>
</div>
</ConditionComponent>
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control flex-fill" placeholder="请输入后台管理地址2000字以内" value="@Model.AdminPathBase" maxlength="2000" data-valid="true" />
<ConditionComponent Inverse="true">
<div class="input-group-append">
<button class="btn btn-secondary" type="button" data-method="appPath">保存</button>
</div>
</ConditionComponent>
</div>
</div>
</div>
</div>
<div class="card" asp-auth="app">
<div class="card-header">前台应用设置</div>
<div class="card-body">
<ConditionComponent>
<div class="alert alert-danger" role="alert">
<span>演示系统禁止更改前台应用设置</span>
</div>
</ConditionComponent>
<div class="form-inline">
<div class="row" id="appList">
@foreach (var app in Model.Apps)
{
<div class="form-group col-12 app" data-key="@app.Key">
<label class="control-label" for="@app.Key">@app.Name</label>
<div class="input-group flex-fill">
<input id="@app.Key" class="form-control" value="@app.Url" readonly />
<ConditionComponent Inverse="true">
<div class="input-group-append">
<button class="btn btn-danger" type="button" data-key="@app.Key" data-method="delApp"><i class="fa fa-trash-o"></i><span>删除</span></button>
<button class="btn btn-primary" type="button" data-key="@app.Key" data-method="editApp"><i class="fa fa fa-pencil"></i><span>编辑</span></button>
</div>
</ConditionComponent>
</div>
</div>
}
</div>
</div>
</div>
<ConditionComponent Inverse="true">
<div class="card-footer text-right">
<button class="btn btn-secondary" type="button" data-method="addApp"><i class="fa fa-plus"></i><span>新增</span></button>
</div>
</ConditionComponent>
</div>
<ConditionComponent AuthKey="saveTheme">
<div class="card">
<div class="card-header">网站样式设置</div>

View File

@ -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);
});
}
/// <summary>
@ -380,6 +397,26 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
/// 获得 系统是否允许健康检查
/// </summary>
public bool EnableHealth { get; set; }
/// <summary>
/// 获得/设置 字典表中登录首页集合
/// </summary>
public IEnumerable<SelectedItem> Logins { get; set; } = new SelectedItem[0];
/// <summary>
/// 获得/设置 登录视图名称 默认是 Login
/// </summary>
public SelectedItem SelectedLogin { get; set; } = new SelectedItem();
/// <summary>
/// 获得/设置 后台管理网站地址
/// </summary>
public string AdminPathBase { get; set; } = "";
/// <summary>
/// 获得/设置 系统应用程序集合
/// </summary>
public IEnumerable<(string Key, string Name, string Url)> Apps { get; set; } = new List<(string, string, string)>();
}
}
}

View File

@ -37,5 +37,14 @@ namespace Bootstrap.Client.DataAccess
/// <param name="userName"></param>
/// <returns></returns>
public static IEnumerable<BootstrapMenu> RetrieveAllMenus(string userName) => CacheManager.GetOrAdd($"{RetrieveMenusAll}-{userName}", key => DbContextManager.Create<Menu>()?.RetrieveAllMenus(userName), RetrieveMenusAll) ?? new BootstrapMenu[0];
/// <summary>
/// 通过当前用户名与指定菜单路径获取此菜单下所有授权按钮集合 (userName, url, auths) => bool
/// </summary>
/// <param name="userName">当前操作用户名</param>
/// <param name="url">资源按钮所属菜单</param>
/// <param name="auths">资源授权码</param>
/// <returns></returns>
public static bool AuthorizateButtons(string userName, string url, string auths) => DbContextManager.Create<Menu>()?.AuthorizateButtons(userName, url, auths) ?? false;
}
}

View File

@ -15,5 +15,18 @@ namespace Bootstrap.Client.DataAccess
/// <param name="userName">当前登录的用户名</param>
/// <returns></returns>
public virtual IEnumerable<BootstrapMenu> RetrieveAllMenus(string userName) => DbHelper.RetrieveAllMenus(userName);
/// <summary>
/// 通过当前用户名与指定菜单路径获取此菜单下所有授权按钮集合 (userName, url, auths) => bool
/// </summary>
/// <param name="userName">当前操作用户名</param>
/// <param name="url">资源按钮所属菜单</param>
/// <param name="auths">资源授权码</param>
/// <returns></returns>
public virtual bool AuthorizateButtons(string userName, string url, string auths)
{
var menus = MenuHelper.RetrieveAllMenus(userName);
return DbHelper.AuthorizateButtons(menus, url, auths);
}
}
}

View File

@ -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 =>
{