refactor: 更新客户端框架获取系统数据方法
This commit is contained in:
parent
ea670fc1bc
commit
632630e0e9
|
@ -1,5 +1,4 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Configuration;
|
||||
using MongoDB.Driver;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -16,30 +15,5 @@ namespace Bootstrap.Client.DataAccess.MongoDB
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override IEnumerable<BootstrapDict> RetrieveDicts() => DbManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList();
|
||||
|
||||
private static string RetrieveAppName(string name, string defaultValue = "未设置")
|
||||
{
|
||||
var dicts = DictHelper.RetrieveDicts();
|
||||
var platName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == ConfigurationManager.AppSettings["AppId"])?.Name;
|
||||
return dicts.FirstOrDefault(d => d.Category == platName && d.Name == name)?.Code ?? $"{name}{defaultValue}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得系统设置地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string RetrieveSettingsUrl() => RetrieveAppName("系统设置地址");
|
||||
|
||||
/// <summary>
|
||||
/// 获得系统个人中心地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string RetrieveProfilesUrl() => RetrieveAppName("个人中心地址");
|
||||
|
||||
/// <summary>
|
||||
/// 获得系统通知地址地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string RetrieveNotisUrl() => RetrieveAppName("系统通知地址");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.13-preview-1" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.13-preview-4" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.15" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.3.7" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.13" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.16" />
|
||||
|
|
|
@ -16,13 +16,13 @@ namespace Bootstrap.Client.DataAccess
|
|||
/// 获取系统网站标题
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string RetrieveWebTitle() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "后台管理系统" }).Code;
|
||||
public virtual string RetrieveWebTitle(string appId) => DbHelper.RetrieveTitle(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取系统网站页脚
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string RetrieveWebFooter() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "2016 © 通用后台管理系统" }).Code;
|
||||
public virtual string RetrieveWebFooter(string appId) => DbHelper.RetrieveFooter(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获得网站设置中的当前样式
|
||||
|
@ -93,18 +93,18 @@ namespace Bootstrap.Client.DataAccess
|
|||
/// 获得系统设置地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string RetrieveSettingsUrl() => DbHelper.RetrieveSettingsUrl();
|
||||
public virtual string RetrieveSettingsUrl(string appId) => DbHelper.RetrieveSettingsUrl(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获得系统个人中心地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string RetrieveProfilesUrl() => DbHelper.RetrieveProfilesUrl();
|
||||
public virtual string RetrieveProfilesUrl(string appId) => DbHelper.RetrieveProfilesUrl(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获得系统通知地址地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string RetrieveNotisUrl() => DbHelper.RetrieveNotisUrl();
|
||||
public virtual string RetrieveNotisUrl(string appId) => DbHelper.RetrieveNotisUrl(appId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,14 +27,16 @@ namespace Bootstrap.Client.DataAccess
|
|||
/// <summary>
|
||||
/// 获取站点 Title 配置信息
|
||||
/// </summary>
|
||||
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveWebTitle() => DbContextManager.Create<Dict>().RetrieveWebTitle();
|
||||
public static string RetrieveWebTitle(string appId) => DbContextManager.Create<Dict>().RetrieveWebTitle(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取站点 Footer 配置信息
|
||||
/// </summary>
|
||||
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveWebFooter() => DbContextManager.Create<Dict>().RetrieveWebFooter();
|
||||
public static string RetrieveWebFooter(string appId) => DbContextManager.Create<Dict>().RetrieveWebFooter(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获得网站设置中的当前样式
|
||||
|
@ -94,20 +96,23 @@ namespace Bootstrap.Client.DataAccess
|
|||
/// <summary>
|
||||
/// 获得系统设置地址
|
||||
/// </summary>
|
||||
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveSettingsUrl() => DbContextManager.Create<Dict>().RetrieveSettingsUrl();
|
||||
public static string RetrieveSettingsUrl(string appId) => DbContextManager.Create<Dict>().RetrieveSettingsUrl(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获得系统个人中心地址
|
||||
/// </summary>
|
||||
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveProfilesUrl() => DbContextManager.Create<Dict>().RetrieveProfilesUrl();
|
||||
public static string RetrieveProfilesUrl(string appId) => DbContextManager.Create<Dict>().RetrieveProfilesUrl(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 获得系统通知地址地址
|
||||
/// </summary>
|
||||
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveNotisUrl() => DbContextManager.Create<Dict>().RetrieveNotisUrl();
|
||||
public static string RetrieveNotisUrl(string appId) => DbContextManager.Create<Dict>().RetrieveNotisUrl(appId);
|
||||
|
||||
/// <summary>
|
||||
/// 配置 IP 地理位置查询配置项 注入方法调用此方法
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.16-preview-1" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.16-preview-2" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.13" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
|
|
|
@ -21,9 +21,9 @@ namespace Bootstrap.Client.Models
|
|||
var user = UserHelper.RetrieveUserByUserName(identity.Name);
|
||||
DisplayName = user.DisplayName;
|
||||
UserName = user.UserName;
|
||||
SettingsUrl = DictHelper.RetrieveSettingsUrl();
|
||||
ProfilesUrl = DictHelper.RetrieveProfilesUrl();
|
||||
NotisUrl = DictHelper.RetrieveNotisUrl();
|
||||
SettingsUrl = DictHelper.RetrieveSettingsUrl(AppId);
|
||||
ProfilesUrl = DictHelper.RetrieveProfilesUrl(AppId);
|
||||
NotisUrl = DictHelper.RetrieveNotisUrl(AppId);
|
||||
|
||||
// set LogoutUrl
|
||||
var authHost = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>().AuthHost;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Longbow.Configuration;
|
||||
|
||||
namespace Bootstrap.Client.Models
|
||||
{
|
||||
|
@ -12,11 +13,14 @@ namespace Bootstrap.Client.Models
|
|||
/// </summary>
|
||||
public ModelBase()
|
||||
{
|
||||
Title = DictHelper.RetrieveWebTitle();
|
||||
Footer = DictHelper.RetrieveWebFooter();
|
||||
AppId = ConfigurationManager.GetValue("AppId", "2");
|
||||
Title = DictHelper.RetrieveWebTitle(AppId);
|
||||
Footer = DictHelper.RetrieveWebFooter(AppId);
|
||||
Theme = DictHelper.RetrieveActiveTheme();
|
||||
}
|
||||
|
||||
public string AppId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取 网站标题
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue