feat: 前台应用配置增加了网站图标与 Icon 的设置

This commit is contained in:
Argo Zhang 2020-03-13 10:59:16 +08:00
parent 4de4630dbc
commit f27843d493
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
5 changed files with 80 additions and 33 deletions

View File

@ -1,12 +1,10 @@
using Bootstrap.Admin.Query; using Bootstrap.DataAccess;
using Bootstrap.DataAccess;
using Bootstrap.Security; using Bootstrap.Security;
using Longbow.Cache; using Longbow.Cache;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Admin.Controllers.Api namespace Bootstrap.Admin.Controllers.Api
{ {

View File

@ -352,6 +352,14 @@
<label class="control-label" for="appFooter">网站页脚</label> <label class="control-label" for="appFooter">网站页脚</label>
<input type="text" class="form-control flex-fill" id="appFooter" placeholder="不可为空50字以内" maxlength="50" data-valid="true" /> <input type="text" class="form-control flex-fill" id="appFooter" placeholder="不可为空50字以内" maxlength="50" data-valid="true" />
</div> </div>
<div class="form-group col-sm-12">
<label class="control-label" for="appIcon">网站图标</label>
<input type="text" class="form-control flex-fill" id="appIcon" placeholder="不可为空2000字以内" maxlength="2000" data-valid="true" />
</div>
<div class="form-group col-sm-12">
<label class="control-label" for="appFavicon">favicon</label>
<input type="text" class="form-control flex-fill" id="appFavicon" placeholder="不可为空2000字以内" maxlength="2000" data-valid="true" />
</div>
</div> </div>
</form> </form>
</div> </div>

View File

@ -166,6 +166,8 @@ $(function () {
$('#appUrl').val(''); $('#appUrl').val('');
$('#appTitle').val(''); $('#appTitle').val('');
$('#appFooter').val(''); $('#appFooter').val('');
$('#appIcon').val('');
$('#appFavicon').val('');
$('#appId').val('new'); $('#appId').val('new');
$dialog.modal('show'); $dialog.modal('show');
break; break;
@ -176,8 +178,10 @@ $(function () {
var appTitle = $('#appTitle').val(); var appTitle = $('#appTitle').val();
var appFooter = $('#appFooter').val(); var appFooter = $('#appFooter').val();
var appId = $('#appId').val(); var appId = $('#appId').val();
var appIcon = $('#appIcon').val();
var appFavicon = $('#appFavicon').val();
$.bc({ $.bc({
url: Settings.url, data: { AppName: appName, AppCode: appKey, AppUrl: appPath, AppTitle: appTitle, AppFooter: appFooter, AppId: appId }, title: "保存" + appName, method: "put", url: Settings.url, data: { AppIcon: appIcon, AppFavicon: appFavicon, AppName: appName, AppCode: appKey, AppUrl: appPath, AppTitle: appTitle, AppFooter: appFooter, AppId: appId }, title: "保存" + appName, method: "put",
callback: function (result) { callback: function (result) {
if (result) { if (result) {
$dialog.modal('hide'); $dialog.modal('hide');
@ -211,6 +215,8 @@ $(function () {
$('#appName').val(result.AppName); $('#appName').val(result.AppName);
$('#appTitle').val(result.AppTitle); $('#appTitle').val(result.AppTitle);
$('#appFooter').val(result.AppFooter); $('#appFooter').val(result.AppFooter);
$('#appIcon').val(result.AppIcon);
$('#appFavicon').val(result.AppFavicon);
$dialog.modal('show'); $dialog.modal('show');
} }
} }

View File

@ -394,44 +394,55 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 保存前台应用配置信息 /// 保存前台应用配置信息
/// </summary> /// </summary>
/// <param name="appKey"></param> /// <param name="option"></param>
/// <param name="appName"></param>
/// <param name="appUrl"></param>
/// <param name="appTitle"></param>
/// <param name="appFooter"></param>
/// <param name="update"></param>
/// <returns></returns> /// <returns></returns>
public static bool SaveAppSettings(string appKey, string appName, string appUrl, string appTitle, string appFooter, bool update) public static bool SaveAppSettings(QueryAppOption option)
{ {
bool update = option.AppId == "edit";
// dict define == 1 时为新建前台应用 // dict define == 1 时为新建前台应用
bool ret; bool ret;
// 前台网站配置地址 不允许以 / 结尾 // 前台网站配置地址 不允许以 / 结尾
appUrl = appUrl.TrimEnd('/'); option.AppUrl = option.AppUrl.TrimEnd('/');
if (update) if (update)
{ {
// Update // Update
ret = SaveSettings(new BootstrapDict[] { ret = SaveSettings(new BootstrapDict[] {
new BootstrapDict() new BootstrapDict()
{ {
Category = appName, Category = option.AppName,
Name = "网站标题", Name = "网站标题",
Code = appTitle, Code = option.AppTitle,
Define = 1 Define = 1
}, },
new BootstrapDict() new BootstrapDict()
{ {
Category = appName, Category = option.AppName,
Name = "网站页脚", Name = "网站页脚",
Code = appFooter, Code = option.AppFooter,
Define = 1 Define = 1
}, },
new BootstrapDict() new BootstrapDict()
{ {
Category = "应用首页", Category = "应用首页",
Name = appKey, Name = option.AppCode,
Code = appUrl, Code = option.AppUrl,
Define = 0 Define = 0
},
new BootstrapDict()
{
Category = option.AppName,
Name = "网站图标",
Code = option.AppFavicon,
Define = 1
},
new BootstrapDict()
{
Category = option.AppName,
Name = "favicon",
Code = option.AppIcon,
Define = 1
} }
}); });
} }
@ -440,52 +451,66 @@ namespace Bootstrap.DataAccess
ret = Save(new BootstrapDict() ret = Save(new BootstrapDict()
{ {
Category = "应用程序", Category = "应用程序",
Name = appName, Name = option.AppName,
Code = appKey, Code = option.AppCode,
Define = 0 Define = 0
}); });
if (ret) ret = Save(new BootstrapDict() if (ret) ret = Save(new BootstrapDict()
{ {
Category = "应用首页", Category = "应用首页",
Name = appKey, Name = option.AppCode,
Code = appUrl, Code = option.AppUrl,
Define = 0 Define = 0
}); });
if (ret) ret = Save(new BootstrapDict() if (ret) ret = Save(new BootstrapDict()
{ {
Category = appName, Category = option.AppName,
Name = "网站标题", Name = "网站标题",
Code = appTitle, Code = option.AppTitle,
Define = 1 Define = 1
}); });
if (ret) ret = Save(new BootstrapDict() if (ret) ret = Save(new BootstrapDict()
{ {
Category = appName, Category = option.AppName,
Name = "网站页脚", Name = "网站页脚",
Code = appFooter, Code = option.AppFooter,
Define = 1 Define = 1
}); });
if (ret) ret = Save(new BootstrapDict() if (ret) ret = Save(new BootstrapDict()
{ {
Category = appName, Category = option.AppName,
Name = "个人中心地址", Name = "个人中心地址",
Code = "/Admin/Profiles", Code = "/Admin/Profiles",
Define = 1 Define = 1
}); });
if (ret) ret = Save(new BootstrapDict() if (ret) ret = Save(new BootstrapDict()
{ {
Category = appName, Category = option.AppName,
Name = "系统设置地址", Name = "系统设置地址",
Code = "/Admin/Index", Code = "/Admin/Index",
Define = 1 Define = 1
}); });
if (ret) ret = Save(new BootstrapDict() if (ret) ret = Save(new BootstrapDict()
{ {
Category = appName, Category = option.AppName,
Name = "系统通知地址", Name = "系统通知地址",
Code = "/Admin/Notifications", Code = "/Admin/Notifications",
Define = 1 Define = 1
}); });
if (ret) ret = Save(new BootstrapDict()
{
Category = option.AppName,
Name = "网站图标",
Code = option.AppFavicon,
Define = 1
});
if (ret) ret = Save(new BootstrapDict()
{
Category = option.AppName,
Name = "favicon",
Code = option.AppIcon,
Define = 1
});
} }
return ret; return ret;
} }

View File

@ -1,7 +1,6 @@
using System.Linq; using System.Linq;
using Bootstrap.DataAccess;
namespace Bootstrap.Admin.Query namespace Bootstrap.DataAccess
{ {
/// <summary> /// <summary>
/// 前台应用查询类 /// 前台应用查询类
@ -11,7 +10,6 @@ namespace Bootstrap.Admin.Query
/// <summary> /// <summary>
/// 应用操作 new 为新建 edit 为保存 /// 应用操作 new 为新建 edit 为保存
/// </summary> /// </summary>
/// <value></value>
public string AppId { get; set; } = "edit"; public string AppId { get; set; } = "edit";
/// <summary> /// <summary>
@ -39,13 +37,23 @@ namespace Bootstrap.Admin.Query
/// </summary> /// </summary>
public string AppFooter { get; set; } = "未设置"; public string AppFooter { get; set; } = "未设置";
/// <summary>
/// 前台应用图标
/// </summary>
public string AppIcon { get; set; } = "/favicon.ico";
/// <summary>
/// 前台应用收藏图标
/// </summary>
public string AppFavicon { get; set; } = "/favicon.png";
/// <summary> /// <summary>
/// 保存前台应用方法 /// 保存前台应用方法
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public bool Save() public bool Save()
{ {
var ret = DictHelper.SaveAppSettings(AppCode, AppName, AppUrl, AppTitle, AppFooter, AppId == "edit"); var ret = DictHelper.SaveAppSettings(this);
return true; return true;
} }
@ -62,6 +70,8 @@ namespace Bootstrap.Admin.Query
ret.AppUrl = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == key).Code ?? ""; ret.AppUrl = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == key).Code ?? "";
ret.AppTitle = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站标题").Code ?? ""; ret.AppTitle = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站标题").Code ?? "";
ret.AppFooter = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站页脚").Code ?? ""; ret.AppFooter = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站页脚").Code ?? "";
ret.AppFavicon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站图标").Code ?? "";
ret.AppIcon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "favicon").Code ?? "";
return ret; return ret;
} }
} }