2018-09-16 19:33:56 +08:00
|
|
|
|
using Bootstrap.Security;
|
2018-10-28 23:35:23 +08:00
|
|
|
|
using Bootstrap.Security.DataAccess;
|
2018-10-28 21:05:22 +08:00
|
|
|
|
using Longbow.Cache;
|
2018-09-16 19:33:56 +08:00
|
|
|
|
using Longbow.Configuration;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Client.DataAccess
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class DictHelper
|
|
|
|
|
{
|
2018-10-28 21:05:22 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 缓存索引,BootstrapAdmin后台清理缓存时使用
|
|
|
|
|
/// </summary>
|
2019-05-02 00:03:07 +08:00
|
|
|
|
private const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts";
|
2019-03-18 17:26:12 +08:00
|
|
|
|
|
2018-09-16 19:33:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveProfilesUrl()
|
|
|
|
|
{
|
|
|
|
|
return RetrieveAppName("个人中心地址");
|
|
|
|
|
}
|
2019-03-18 17:26:12 +08:00
|
|
|
|
|
2018-09-16 19:33:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveSettingsUrl()
|
|
|
|
|
{
|
|
|
|
|
return RetrieveAppName("系统设置地址");
|
2019-05-01 16:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-05 16:14:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveNotisUrl()
|
|
|
|
|
{
|
|
|
|
|
return RetrieveAppName("系统通知地址");
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 19:33:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveTitle()
|
|
|
|
|
{
|
|
|
|
|
return RetrieveAppName("网站标题");
|
|
|
|
|
}
|
2019-03-18 17:26:12 +08:00
|
|
|
|
|
2018-09-16 19:33:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveFooter()
|
|
|
|
|
{
|
|
|
|
|
return RetrieveAppName("网站页脚");
|
|
|
|
|
}
|
2019-03-18 17:26:12 +08:00
|
|
|
|
|
2018-09-16 19:33:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-10-28 23:35:23 +08:00
|
|
|
|
private static IEnumerable<BootstrapDict> RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbHelper.RetrieveDicts());
|
2018-09-16 19:33:56 +08:00
|
|
|
|
|
|
|
|
|
private static string RetrieveAppName(string name, string defaultValue = "未设置")
|
|
|
|
|
{
|
2018-10-19 23:09:52 +08:00
|
|
|
|
var dicts = RetrieveDicts();
|
|
|
|
|
var platName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == ConfigurationManager.AppSettings["AppId"])?.Name;
|
2018-09-16 19:33:56 +08:00
|
|
|
|
return dicts.FirstOrDefault(d => d.Category == platName && d.Name == name)?.Code ?? $"{name}{defaultValue}";
|
|
|
|
|
}
|
2019-02-23 12:34:07 +08:00
|
|
|
|
|
2018-09-16 19:33:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得网站设置中的当前样式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveActiveTheme()
|
|
|
|
|
{
|
2018-10-19 23:09:52 +08:00
|
|
|
|
var theme = RetrieveDicts().Where(d => d.Name == "使用样式" && d.Category == "当前样式" && d.Define == 0).FirstOrDefault()?.Code;
|
|
|
|
|
return theme == null ? string.Empty : theme.Equals("site.css", StringComparison.OrdinalIgnoreCase) ? string.Empty : theme;
|
2018-09-16 19:33:56 +08:00
|
|
|
|
}
|
2019-02-23 12:34:07 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取头像路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveIconFolderPath() => (RetrieveDicts().FirstOrDefault(d => d.Name == "头像路径" && d.Category == "头像地址" && d.Define == 0) ?? new BootstrapDict() { Code = "~/images/uploader/" }).Code;
|
2019-04-13 16:01:06 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取验证码图床
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2019-04-30 14:45:47 +08:00
|
|
|
|
public static string RetrieveImagesLibUrl() => RetrieveDicts().FirstOrDefault(d => d.Name == "验证码图床" && d.Category == "系统设置" && d.Define == 0)?.Code ?? "http://images.sdgxgz.com/";
|
2018-09-16 19:33:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|