diff --git a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj index b7fd7374..49055a8c 100644 --- a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/admin/Bootstrap.Admin/Controllers/AccountController.cs b/src/admin/Bootstrap.Admin/Controllers/AccountController.cs index 5ef4b84d..e81a8dc1 100644 --- a/src/admin/Bootstrap.Admin/Controllers/AccountController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/AccountController.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Configuration; using System; using System.Linq; @@ -67,16 +68,17 @@ namespace Bootstrap.Admin.Controllers /// /// 系统登录方法 /// + /// /// [HttpGet] - public ActionResult Login() + public ActionResult Login([FromQuery] string appId = "0") { if (DictHelper.RetrieveSystemModel()) { ViewBag.UserName = "Admin"; ViewBag.Password = "123789"; } - return User.Identity.IsAuthenticated ? (ActionResult)Redirect("~/Home/Index") : View("Login", new LoginModel()); + return User.Identity.IsAuthenticated ? (ActionResult)Redirect("~/Home/Index") : View("Login", new LoginModel(appId)); } /// @@ -125,12 +127,13 @@ namespace Bootstrap.Admin.Controllers /// User name. /// Password. /// Remember. + /// [HttpPost] - public async Task Login(string userName, string password, string remember) + public async Task Login(string userName, string password, string remember, string appId = "0") { var auth = UserHelper.Authenticate(userName, password); HttpContext.Log(userName, auth); - return auth ? await SignInAsync(userName, remember == "true") : View("Login", new LoginModel() { AuthFailed = true }); + return auth ? await SignInAsync(userName, remember == "true") : View("Login", new LoginModel(appId) { AuthFailed = true }); } private async Task SignInAsync(string userName, bool persistent, string authenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme) @@ -163,12 +166,13 @@ namespace Bootstrap.Admin.Controllers /// /// Logout this instance. /// + /// /// The logout. [HttpGet] - public async Task Logout() + public async Task Logout([FromQuery]string appId = "0") { await HttpContext.SignOutAsync(); - return Redirect(Request.PathBase + CookieAuthenticationDefaults.LoginPath); + return Redirect(QueryHelpers.AddQueryString(Request.PathBase + CookieAuthenticationDefaults.LoginPath, "AppId", appId)); } /// diff --git a/src/admin/Bootstrap.Admin/Controllers/HomeController.cs b/src/admin/Bootstrap.Admin/Controllers/HomeController.cs index ae9b5843..be2e6c84 100644 --- a/src/admin/Bootstrap.Admin/Controllers/HomeController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/HomeController.cs @@ -19,7 +19,7 @@ namespace Bootstrap.Admin.Controllers { var model = new HeaderBarModel(User.Identity); if (string.IsNullOrEmpty(model.UserName)) return Redirect(Request.PathBase + CookieAuthenticationDefaults.LogoutPath); - var url = DictHelper.RetrieveHomeUrl(model.AppCode); + var url = DictHelper.RetrieveHomeUrl(model.AppId); return url.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (IActionResult)View(model) : Redirect(url); } diff --git a/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs b/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs index aeab1773..925b99f6 100644 --- a/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -21,9 +21,13 @@ namespace Bootstrap.Admin.Models Icon = user.Icon.Contains("://", StringComparison.OrdinalIgnoreCase) ? user.Icon : string.Format("{0}{1}", DictHelper.RetrieveIconFolderPath(), user.Icon); DisplayName = user.DisplayName; UserName = user.UserName; - AppCode = user.App; + AppId = user.App; Css = user.Css; ActiveCss = string.IsNullOrEmpty(Css) ? Theme : Css; + + // 通过 AppCode 获取用户默认应用的标题 + Title = DictHelper.RetrieveWebTitle(AppId); + Footer = DictHelper.RetrieveWebFooter(AppId); } } @@ -50,7 +54,7 @@ namespace Bootstrap.Admin.Models /// /// 获得 当前设置的默认应用 /// - public string AppCode { get; } + public string AppId { get; } /// /// 获得 当前样式 diff --git a/src/admin/Bootstrap.Admin/Models/LoginModel.cs b/src/admin/Bootstrap.Admin/Models/LoginModel.cs index 2db09765..1870ba6c 100644 --- a/src/admin/Bootstrap.Admin/Models/LoginModel.cs +++ b/src/admin/Bootstrap.Admin/Models/LoginModel.cs @@ -10,7 +10,8 @@ namespace Bootstrap.Admin.Models /// /// 默认构造函数 /// - public LoginModel() + /// + public LoginModel(string appId = "0") : base(appId) { ImageLibUrl = DictHelper.RetrieveImagesLibUrl(); } diff --git a/src/admin/Bootstrap.Admin/Models/ModelBase.cs b/src/admin/Bootstrap.Admin/Models/ModelBase.cs index cb445d5f..8f5da079 100644 --- a/src/admin/Bootstrap.Admin/Models/ModelBase.cs +++ b/src/admin/Bootstrap.Admin/Models/ModelBase.cs @@ -10,10 +10,11 @@ namespace Bootstrap.Admin.Models /// /// 默认构造函数 /// - public ModelBase() + /// + public ModelBase(string appId = "0") { - Title = DictHelper.RetrieveWebTitle(); - Footer = DictHelper.RetrieveWebFooter(); + Title = DictHelper.RetrieveWebTitle(appId); + Footer = DictHelper.RetrieveWebFooter(appId); Theme = DictHelper.RetrieveActiveTheme(); IsDemo = DictHelper.RetrieveSystemModel(); ShowCardTitle = DictHelper.RetrieveCardTitleStatus() ? "" : "no-card-header"; @@ -26,15 +27,23 @@ namespace Bootstrap.Admin.Models EnableAutoLockScreen = DictHelper.RetrieveAutoLockScreen(); } + /// + /// 默认构造函数 + /// + public ModelBase() : this("0") + { + + } + /// /// 获取 网站标题 /// - public string Title { get; private set; } + public string Title { get; protected set; } /// /// 获取 网站页脚 /// - public string Footer { get; private set; } + public string Footer { get; protected set; } /// /// 网站样式全局设置 diff --git a/src/admin/Bootstrap.Admin/Views/Admin/Profiles.cshtml b/src/admin/Bootstrap.Admin/Views/Admin/Profiles.cshtml index 20d02f35..e57c1493 100644 --- a/src/admin/Bootstrap.Admin/Views/Admin/Profiles.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Admin/Profiles.cshtml @@ -87,7 +87,7 @@
- +
diff --git a/src/admin/Bootstrap.DataAccess.MongoDB/Dict.cs b/src/admin/Bootstrap.DataAccess.MongoDB/Dict.cs index 1f067f5a..b5d131a1 100644 --- a/src/admin/Bootstrap.DataAccess.MongoDB/Dict.cs +++ b/src/admin/Bootstrap.DataAccess.MongoDB/Dict.cs @@ -74,21 +74,23 @@ namespace Bootstrap.DataAccess.MongoDB } /// - /// + /// 获得网站标题设置 /// + /// /// - public override string RetrieveWebTitle() + public override string RetrieveWebTitle(string appId = "0") { - var code = RetrieveAppName("网站标题"); + var code = RetrieveAppName("网站标题", appId); if (code == "网站标题未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统"; return code; } /// - /// + /// 获得网站页脚设置 /// + /// /// - public override string RetrieveWebFooter() + public override string RetrieveWebFooter(string appId = "0") { var code = RetrieveAppName("网站页脚"); if (code == "网站页脚未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统"; diff --git a/src/admin/Bootstrap.DataAccess/Dict.cs b/src/admin/Bootstrap.DataAccess/Dict.cs index a28b9e27..66de0427 100644 --- a/src/admin/Bootstrap.DataAccess/Dict.cs +++ b/src/admin/Bootstrap.DataAccess/Dict.cs @@ -63,11 +63,13 @@ namespace Bootstrap.DataAccess /// /// 获取系统网站标题 /// + /// /// - public virtual string RetrieveWebTitle() + public virtual string RetrieveWebTitle(string appId = "0") { // 优先查找配置的应用程序网站标题 - var code = DbHelper.RetrieveTitle(); + var code = DbHelper.RetrieveTitle(appId); + if (code == "网站标题未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统"; return code; } @@ -75,11 +77,12 @@ namespace Bootstrap.DataAccess /// /// 获取系统网站页脚 /// + /// /// - public virtual string RetrieveWebFooter() + public virtual string RetrieveWebFooter(string appId = "0") { // 优先查找配置的应用程序网站标题 - var code = DbHelper.RetrieveFooter(); + var code = DbHelper.RetrieveFooter(appId); if (code == "网站页脚未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统"; return code; } diff --git a/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs index ca3e2465..7ba70dc8 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs @@ -98,14 +98,16 @@ namespace Bootstrap.DataAccess /// /// 获取站点 Title 配置信息 /// + /// /// - public static string RetrieveWebTitle() => DbContextManager.Create().RetrieveWebTitle(); + public static string RetrieveWebTitle(string appId = "0") => DbContextManager.Create().RetrieveWebTitle(appId); /// /// 获取站点 Footer 配置信息 /// + /// /// - public static string RetrieveWebFooter() => DbContextManager.Create().RetrieveWebFooter(); + public static string RetrieveWebFooter(string appId = "0") => DbContextManager.Create().RetrieveWebFooter(appId); /// /// 获得系统中配置的可以使用的网站样式 diff --git a/src/client/Bootstrap.Client/Bootstrap.Client.csproj b/src/client/Bootstrap.Client/Bootstrap.Client.csproj index 7cc814af..921aa772 100644 --- a/src/client/Bootstrap.Client/Bootstrap.Client.csproj +++ b/src/client/Bootstrap.Client/Bootstrap.Client.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/client/Bootstrap.Client/Models/HeaderBarModel.cs b/src/client/Bootstrap.Client/Models/HeaderBarModel.cs index 4873c4ee..419d6a08 100644 --- a/src/client/Bootstrap.Client/Models/HeaderBarModel.cs +++ b/src/client/Bootstrap.Client/Models/HeaderBarModel.cs @@ -29,6 +29,7 @@ namespace Bootstrap.Client.Models var authHost = ConfigurationManager.Get().AuthHost; var uriBuilder = new UriBuilder(authHost); uriBuilder.Path = uriBuilder.Path == "/" ? CookieAuthenticationDefaults.LogoutPath.Value : $"{uriBuilder.Path.TrimEnd('/')}{CookieAuthenticationDefaults.LogoutPath.Value}"; + uriBuilder.Query = $"AppId={AppId}"; LogoutUrl = uriBuilder.ToString(); // set Icon diff --git a/src/client/Bootstrap.Client/Startup.cs b/src/client/Bootstrap.Client/Startup.cs index c81ae680..b5180699 100644 --- a/src/client/Bootstrap.Client/Startup.cs +++ b/src/client/Bootstrap.Client/Startup.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting;