feat: 增加网站设置
This commit is contained in:
parent
d517d57163
commit
083bd15d91
|
@ -0,0 +1,42 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BootstrapAdmin.DataAccess.Models;
|
||||
|
||||
public class AppInfo
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Display(Name = "系统名称")]
|
||||
[Required(ErrorMessage = "{0}不可为空")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Display(Name = "网站页脚")]
|
||||
[Required(ErrorMessage = "{0}不可为空")]
|
||||
public string? Footer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Display(Name = "登录地址")]
|
||||
public string? Login { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Display(Name = "后台地址")]
|
||||
public string? AuthUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string? Theme { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool IsDemo { get; set; }
|
||||
}
|
|
@ -1 +1,93 @@
|
|||
@page "/Admin/Settings"
|
||||
|
||||
<div class="tab-scroll-body">
|
||||
<AdminCard HeaderText="系统名称设置" AuthorizeKey="SaveTitle">
|
||||
<AdminAlert Text="演示系统禁止更改系统名称" IsShow="IsDemo" />
|
||||
<ValidateForm OnValidSubmit="OnSaveTitle" Model="AppInfo">
|
||||
<div class="row g-3 form-inline">
|
||||
<div class="col-12 col-sm-6">
|
||||
<BootstrapInput @bind-Value="@AppInfo.Title" Readonly="IsDemo" />
|
||||
</div>
|
||||
<Block Condition="!IsDemo">
|
||||
<div class="col-12 col-sm-6 text-end">
|
||||
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
|
||||
</div>
|
||||
</Block>
|
||||
</div>
|
||||
</ValidateForm>
|
||||
</AdminCard>
|
||||
|
||||
<AdminCard HeaderText="网站页脚设置" AuthorizeKey="SaveFooter">
|
||||
<AdminAlert Text="演示系统禁止更改网站页脚" IsShow="IsDemo" />
|
||||
<ValidateForm OnValidSubmit="OnSaveFooter" Model="AppInfo">
|
||||
<div class="row g-3 form-inline">
|
||||
<div class="col-12 col-sm-6">
|
||||
<BootstrapInput @bind-Value="@AppInfo.Footer" Readonly="IsDemo" />
|
||||
</div>
|
||||
<Block Condition="!IsDemo">
|
||||
<div class="col-12 col-sm-6 text-end">
|
||||
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
|
||||
</div>
|
||||
</Block>
|
||||
</div>
|
||||
</ValidateForm>
|
||||
</AdminCard>
|
||||
|
||||
<AdminCard HeaderText="后台管理登录地址设置" AuthorizeKey="SaveLogin">
|
||||
<AdminAlert Text="通过此功能进行整个网站的登录界面设置" Color="Color.Info" />
|
||||
<ValidateForm OnValidSubmit="OnSaveLogin" Model="AppInfo">
|
||||
<div class="row g-3 form-inline">
|
||||
<div class="col-12 col-sm-6">
|
||||
<Dropdown Items="Logins" @bind-Value="AppInfo.Login" />
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 text-end">
|
||||
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
|
||||
</div>
|
||||
</div>
|
||||
</ValidateForm>
|
||||
</AdminCard>
|
||||
|
||||
<AdminCard HeaderText="后台管理地址设置" AuthorizeKey="SaveLogin">
|
||||
<AdminAlert Text="此功能给前台网站拼接后台功能菜单时使用" Color="Color.Info" />
|
||||
<ValidateForm OnValidSubmit="OnSaveAuthUrl" Model="AppInfo">
|
||||
<div class="row g-3 form-inline">
|
||||
<div class="col-12 col-sm-6">
|
||||
<BootstrapInput @bind-Value="@AppInfo.AuthUrl" Readonly="IsDemo" />
|
||||
</div>
|
||||
<Block Condition="!IsDemo">
|
||||
<div class="col-12 col-sm-6 text-end">
|
||||
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
|
||||
</div>
|
||||
</Block>
|
||||
</div>
|
||||
</ValidateForm>
|
||||
</AdminCard>
|
||||
|
||||
<AdminCard HeaderText="网站样式设置" AuthorizeKey="SaveTheme">
|
||||
<AdminAlert Color="Color.Info">
|
||||
<span>注意:本设置将覆盖 <b><TabLink Url="/Admin/Profiles" Text="个人中心" Icon="fa fa-fa">个人中心</TabLink></b> 中设置的网站样式覆盖本设置</span>
|
||||
</AdminAlert>
|
||||
|
||||
<ValidateForm OnValidSubmit="OnSaveTheme" Model="AppInfo">
|
||||
<div class="row g-3 form-inline">
|
||||
<div class="col-12 col-sm-6">
|
||||
<Dropdown Items="Themes" @bind-Value="AppInfo.Theme" />
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 text-end">
|
||||
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
|
||||
</div>
|
||||
</div>
|
||||
</ValidateForm>
|
||||
</AdminCard>
|
||||
|
||||
<AdminCard HeaderText="系统演示设置" AuthorizeKey="SaveDemo">
|
||||
<div class="row g-3 form-inline">
|
||||
<div class="col-12 col-sm-6">
|
||||
<Toggle @bind-Value="AppInfo.IsDemo" OnText="启用" OffText="关闭" />
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 text-end">
|
||||
<Button Icon="fa fa-save" Text="保存" OnClick="OnSaveDemo" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
</div>
|
|
@ -1,6 +1,72 @@
|
|||
namespace BootstrapAdmin.Web.Pages.Admin
|
||||
using BootstrapAdmin.DataAccess.Models;
|
||||
using BootstrapAdmin.Web.Core;
|
||||
using BootstrapAdmin.Web.Extensions;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
|
||||
namespace BootstrapAdmin.Web.Pages.Admin
|
||||
{
|
||||
public partial class Settings
|
||||
{
|
||||
private bool IsDemo { get; set; }
|
||||
|
||||
[NotNull]
|
||||
private AppInfo? AppInfo { get; set; }
|
||||
|
||||
[NotNull]
|
||||
private List<SelectedItem>? Logins { get; set; }
|
||||
|
||||
[NotNull]
|
||||
private List<SelectedItem>? Themes { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IDict? DictService { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IUser? UserService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
IsDemo = DictService.IsDemo();
|
||||
Logins = DictService.GetLogins().ToSelectedItemList();
|
||||
Themes = DictService.GetThemes().ToSelectedItemList();
|
||||
AppInfo = new();
|
||||
}
|
||||
|
||||
private Task OnSaveTitle(EditContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task OnSaveFooter(EditContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task OnSaveLogin(EditContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task OnSaveAuthUrl(EditContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task OnSaveTheme(EditContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnSaveDemo()
|
||||
{
|
||||
IsDemo = AppInfo.IsDemo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue