feat: 更新网站设置前台应用配置功能
This commit is contained in:
parent
e6d5cacefa
commit
1bf2e4141c
|
@ -153,68 +153,6 @@ public class AppInfo
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
[Required(ErrorMessage = "{0}不可为空")]
|
||||||
public int IPCacheExpired { get; set; }
|
public int IPCacheExpired { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
public Dictionary<string, string>? FrontApp { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Display(Name = "应用ID")]
|
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
|
||||||
public string? AppID { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Display(Name = "应用名称")]
|
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
|
||||||
public string? AppName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Display(Name = "应用首页")]
|
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
|
||||||
public string? Home { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Display(Name = "网站标题")]
|
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
|
||||||
public string? WebTitle { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Display(Name = "网站页脚")]
|
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
|
||||||
public string? WebFooter { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Display(Name = "网站图标")]
|
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
|
||||||
public string? WebIcon { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Display(Name = "Favicon")]
|
|
||||||
[Required(ErrorMessage = "{0}不可为空")]
|
|
||||||
public string? Favicon { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,98 +1,40 @@
|
||||||
@using BootstrapAdmin.Web.Core;
|
<ValidateForm OnValidSubmit="OnSaveCleint" Model="Value">
|
||||||
@using BootstrapAdmin.Web.Validators;
|
|
||||||
|
|
||||||
<ValidateForm OnValidSubmit="OnSaveCleint" Model="Value">
|
|
||||||
<div class="row g-3 form-inline">
|
<div class="row g-3 form-inline">
|
||||||
<div class="col-6 col-sm-6">
|
<div class="col-6 col-sm-6">
|
||||||
<BootstrapInput @bind-Value="Value.AppID" placeholder="不可为空,50字以内" Readonly="Value.AppID!=null" ValidateRules="@Validators"></BootstrapInput>
|
<BootstrapInput @bind-Value="Value.AppId" placeholder="不可为空,50字以内" Readonly="Value.AppId != null" ValidateRules="@Validators"></BootstrapInput>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 col-sm-6">
|
<div class="col-6 col-sm-6">
|
||||||
<BootstrapInput @bind-Value="Value.AppName" placeholder="不可为空,50字以内" Readonly="Value.AppName!=null"></BootstrapInput>
|
<BootstrapInput @bind-Value="Value.AppName" placeholder="不可为空,50字以内" Readonly="Value.AppName != null"></BootstrapInput>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-12">
|
<div class="col-12 col-sm-12">
|
||||||
<BootstrapInput @bind-Value="Value.Home" placeholder="不可为空,50字以内"></BootstrapInput>
|
<BootstrapInput @bind-Value="Value.HomeUrl" placeholder="不可为空,50字以内"></BootstrapInput>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-12">
|
<div class="col-12 col-sm-12">
|
||||||
<BootstrapInput @bind-Value="Value.WebTitle" placeholder="不可为空,50字以内"></BootstrapInput>
|
<BootstrapInput @bind-Value="Value.ProfileUrl" placeholder="不可为空,50字以内"></BootstrapInput>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-12">
|
<div class="col-12 col-sm-12">
|
||||||
<BootstrapInput @bind-Value="Value.WebFooter" placeholder="不可为空,50字以内"></BootstrapInput>
|
<BootstrapInput @bind-Value="Value.SettingsUrl" placeholder="不可为空,50字以内"></BootstrapInput>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-12">
|
<div class="col-12 col-sm-12">
|
||||||
<BootstrapInput @bind-Value="Value.WebIcon" placeholder="不可为空,2000字以内"></BootstrapInput>
|
<BootstrapInput @bind-Value="Value.NotificationUrl" placeholder="不可为空,50字以内"></BootstrapInput>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-12">
|
||||||
|
<BootstrapInput @bind-Value="Value.Title" placeholder="不可为空,50字以内"></BootstrapInput>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-12">
|
||||||
|
<BootstrapInput @bind-Value="Value.Footer" placeholder="不可为空,50字以内"></BootstrapInput>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-12">
|
||||||
|
<BootstrapInput @bind-Value="Value.Icon" placeholder="不可为空,2000字以内"></BootstrapInput>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-12">
|
<div class="col-12 col-sm-12">
|
||||||
<BootstrapInput @bind-Value="Value.Favicon" placeholder="不可为空,2000字以内"></BootstrapInput>
|
<BootstrapInput @bind-Value="Value.Favicon" placeholder="不可为空,2000字以内"></BootstrapInput>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-12 text-end">
|
<div class="col-12 col-sm-12">
|
||||||
<Button ButtonType="ButtonType.Submit" Text="保存" Icon="fa fa-save"></Button>
|
<div class="table-modal-footer text-end">
|
||||||
<Button ButtonType="ButtonType.Button" Text="关闭" Icon="fa fa-close" Color="Color.Secondary" OnClick="() => OnClose()"></Button>
|
<Button ButtonType="ButtonType.Button" Text="关闭" Icon="fa fa-close" Color="Color.Secondary" OnClick="OnClickClose"></Button>
|
||||||
|
<Button ButtonType="ButtonType.Submit" Text="保存" Icon="fa fa-save"></Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ValidateForm>
|
</ValidateForm>
|
||||||
|
|
||||||
@code{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
[Parameter]
|
|
||||||
public AppInfo? Value { get; set; } = new();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Parameter]
|
|
||||||
public EventCallback<AppInfo>? ValueChanged { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Parameter]
|
|
||||||
public Func<AppInfo, Task>? OnSaveComplete { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Parameter]
|
|
||||||
[NotNull]
|
|
||||||
public Func<Task>? OnClose { get; set; }
|
|
||||||
|
|
||||||
[NotNull]
|
|
||||||
[Inject]
|
|
||||||
private IDict? DictService { get; set; }
|
|
||||||
|
|
||||||
private List<IValidator> Validators = new List<IValidator>();
|
|
||||||
|
|
||||||
protected override void OnInitialized()
|
|
||||||
{
|
|
||||||
base.OnInitialized();
|
|
||||||
if (Value?.AppID == null)
|
|
||||||
{
|
|
||||||
Validators.Add(new AppIdValidator(DictService));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task OnSaveCleint(EditContext context)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (OnSaveComplete != null)
|
|
||||||
{
|
|
||||||
OnSaveComplete(Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task OnCloseDialog(EditContext context)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (OnClose != null)
|
|
||||||
{
|
|
||||||
OnClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
using BootstrapAdmin.Web.Core;
|
||||||
|
using BootstrapAdmin.Web.Validators;
|
||||||
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
|
||||||
|
namespace BootstrapAdmin.Web.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public partial class ClientDialog
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
[NotNull]
|
||||||
|
public ClientApp? Value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<ClientApp> ValueChanged { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public Func<ClientApp, Task>? OnSave { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
[NotNull]
|
||||||
|
public Func<Task>? OnClose { get; set; }
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
[NotNull]
|
||||||
|
private IDict? DictService { get; set; }
|
||||||
|
|
||||||
|
[NotNull]
|
||||||
|
private List<IValidator>? Validators { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
base.OnInitialized();
|
||||||
|
|
||||||
|
Validators = new List<IValidator>();
|
||||||
|
if (Value.AppId == null)
|
||||||
|
{
|
||||||
|
Validators.Add(new AppIdValidator(DictService));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task OnSaveCleint(EditContext context)
|
||||||
|
{
|
||||||
|
if (OnSave != null)
|
||||||
|
{
|
||||||
|
OnSave(Value);
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnClickClose()
|
||||||
|
{
|
||||||
|
if (OnClose != null)
|
||||||
|
{
|
||||||
|
await OnClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +1,15 @@
|
||||||
|
<div class="row g-3 form-inline">
|
||||||
<div class="row g-3 form-inline">
|
@foreach (var item in Clients)
|
||||||
@if (Client != null)
|
|
||||||
{
|
{
|
||||||
foreach (var item in Client)
|
var value = DictService.GetClientUrl(item.Value);
|
||||||
{
|
<div class="col-12 col-sm-12">
|
||||||
var value = DictService.GetClientUrl(item.Value);
|
<BootstrapInputGroup>
|
||||||
<div class="col-12 col-sm-12">
|
<BootstrapInputGroupLabel Text="@item.Key"></BootstrapInputGroupLabel>
|
||||||
<BootstrapInputGroup>
|
<BootstrapInput Value="value" Readonly="true"></BootstrapInput>
|
||||||
<BootstrapInputGroupLabel Text="@item.Key"></BootstrapInputGroupLabel>
|
<PopConfirmButton Placement="Placement.Top" Color="Color.Danger" Icon="fa fa-trash-o" ConfirmIcon="fa fa-exclamation-circle text-danger" ConfirmButtonColor="Color.Danger" Text="删除" Content="确定删除当前应用吗?" OnConfirm="() => OnDeleteClient(item.Value)" />
|
||||||
<BootstrapInput Value="value"></BootstrapInput>
|
<Button Icon="fa fa-edit" Text="编辑" OnClickWithoutRender="() => OnEditClient(item.Value)" />
|
||||||
<PopConfirmButton Placement="Placement.Top" Color="Color.Danger" Icon="fa fa-trash-o" ConfirmIcon="fa fa-exclamation-circle text-danger" ConfirmButtonColor="Color.Danger" Text="删除" Content="确定删除当前应用吗?" OnConfirm="() => OnDeleteClient(item.Value,item.Key)" />
|
</BootstrapInputGroup>
|
||||||
<Button Icon="fa fa-edit" Text="编辑" OnClickWithoutRender="() => OnEditClient(item.Value,item.Key)" />
|
</div>
|
||||||
</BootstrapInputGroup>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
<div class="col-12 col-sm-12 text-end">
|
<div class="col-12 col-sm-12 text-end">
|
||||||
<Button ButtonType="ButtonType.Button" Icon="fa fa-plus" Text="新增" OnClickWithoutRender="@OnSaveClient" />
|
<Button ButtonType="ButtonType.Button" Icon="fa fa-plus" Text="新增" OnClickWithoutRender="@OnSaveClient" />
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using BootstrapAdmin.DataAccess.Models;
|
using BootstrapAdmin.Web.Core;
|
||||||
using BootstrapAdmin.Web.Core;
|
|
||||||
|
|
||||||
namespace BootstrapAdmin.Web.Components;
|
namespace BootstrapAdmin.Web.Components;
|
||||||
|
|
||||||
|
@ -9,7 +8,7 @@ namespace BootstrapAdmin.Web.Components;
|
||||||
public partial class ClientList
|
public partial class ClientList
|
||||||
{
|
{
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private Dictionary<string, string>? Client { get; set; }
|
private Dictionary<string, string>? Clients { get; set; }
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
[NotNull]
|
[NotNull]
|
||||||
|
@ -28,7 +27,7 @@ public partial class ClientList
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
Client = DictService.GetClients();
|
Clients = DictService.GetClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnSaveClient()
|
private async Task OnSaveClient()
|
||||||
|
@ -36,47 +35,36 @@ public partial class ClientList
|
||||||
Option = new DialogOption
|
Option = new DialogOption
|
||||||
{
|
{
|
||||||
Title = "添加前台应用",
|
Title = "添加前台应用",
|
||||||
BodyTemplate = BootstrapDynamicComponent.CreateComponent<ClientDialog>(new Dictionary<string, object?>
|
Component = BootstrapDynamicComponent.CreateComponent<ClientDialog>(new Dictionary<string, object?>
|
||||||
{
|
{
|
||||||
[nameof(ClientDialog.OnSaveComplete)] = new Func<AppInfo, Task>(e => OnSave(e)),
|
[nameof(ClientDialog.OnSave)] = new Func<ClientApp, Task>(app => OnSave(app)),
|
||||||
[nameof(ClientDialog.OnClose)] = new Func<Task>(() => OnClose())
|
[nameof(ClientDialog.OnClose)] = new Func<Task>(() => OnClose())
|
||||||
}).Render(),
|
}),
|
||||||
ShowFooter = false,
|
ShowFooter = false,
|
||||||
};
|
};
|
||||||
await DialogService.Show(Option);
|
await DialogService.Show(Option);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnEditClient(string appID, string appName)
|
private async Task OnEditClient(string appId)
|
||||||
{
|
{
|
||||||
var frontapp = DictService.GetClientSettings(appID, appName);
|
var client = DictService.GetClient(appId);
|
||||||
var appInfo = new AppInfo()
|
|
||||||
{
|
|
||||||
AppID = appID,
|
|
||||||
AppName = appName,
|
|
||||||
Home = frontapp.homeurl,
|
|
||||||
WebTitle = frontapp.title,
|
|
||||||
WebFooter = frontapp.footer,
|
|
||||||
WebIcon = frontapp.icon,
|
|
||||||
Favicon = frontapp.favicon,
|
|
||||||
};
|
|
||||||
|
|
||||||
Option = new DialogOption
|
Option = new DialogOption
|
||||||
{
|
{
|
||||||
Title = "编辑前台应用",
|
Title = "编辑前台应用",
|
||||||
BodyTemplate = BootstrapDynamicComponent.CreateComponent<ClientDialog>(new Dictionary<string, object?>
|
Component = BootstrapDynamicComponent.CreateComponent<ClientDialog>(new Dictionary<string, object?>
|
||||||
{
|
{
|
||||||
[nameof(ClientDialog.Value)] = appInfo,
|
[nameof(ClientDialog.Value)] = client,
|
||||||
[nameof(ClientDialog.OnSaveComplete)] = new Func<AppInfo, Task>(e => OnSave(e)),
|
[nameof(ClientDialog.OnSave)] = new Func<ClientApp, Task>(app => OnSave(app)),
|
||||||
[nameof(ClientDialog.OnClose)] = new Func<Task>(() => OnClose())
|
[nameof(ClientDialog.OnClose)] = new Func<Task>(() => OnClose())
|
||||||
}).Render(),
|
}),
|
||||||
ShowFooter = false,
|
ShowFooter = false,
|
||||||
};
|
};
|
||||||
await DialogService.Show(Option);
|
await DialogService.Show(Option);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task OnDeleteClient(string appID, string appName)
|
private Task OnDeleteClient(string appId)
|
||||||
{
|
{
|
||||||
DictService.DeleteClient(appID, appName);
|
DictService.DeleteClient(appId);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +73,9 @@ public partial class ClientList
|
||||||
await Option.Dialog.Close();
|
await Option.Dialog.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnSave(AppInfo Value)
|
private async Task OnSave(ClientApp app)
|
||||||
{
|
{
|
||||||
DictService.SaveClient(Value.AppID, Value.AppName, Value.Home, Value.WebTitle, Value.WebFooter, Value.WebIcon, Value.Favicon);
|
DictService.SaveClient(app);
|
||||||
await Option.Dialog.Close();
|
await Option.Dialog.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
</AdminCard>
|
</AdminCard>
|
||||||
|
|
||||||
<AdminCard HeaderText="前台应用设置" AuthorizeKey="SaveFrontApp">
|
<AdminCard HeaderText="前台应用设置" AuthorizeKey="SaveFrontApp">
|
||||||
|
<AdminAlert Text="演示系统禁止更改前台应用设置" IsShow="IsDemo" />
|
||||||
<ClientList />
|
<ClientList />
|
||||||
</AdminCard>
|
</AdminCard>
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,9 @@ public partial class Settings
|
||||||
AppInfo = new()
|
AppInfo = new()
|
||||||
{
|
{
|
||||||
IsDemo = IsDemo,
|
IsDemo = IsDemo,
|
||||||
|
#if DEBUG
|
||||||
AuthCode = "123789",
|
AuthCode = "123789",
|
||||||
|
#endif
|
||||||
Title = DictService.GetWebTitle(),
|
Title = DictService.GetWebTitle(),
|
||||||
Footer = DictService.GetWebFooter(),
|
Footer = DictService.GetWebFooter(),
|
||||||
Login = DictService.GetCurrentLogin(),
|
Login = DictService.GetCurrentLogin(),
|
||||||
|
|
Loading…
Reference in New Issue