From 14f2730d17bf31493c83dc40f7d7b8ff47a84cdd Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 6 Oct 2019 10:58:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(#I12YHP):=20Error=20=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #I12YHP #Issue link #I12YHP #I12VKZ --- .../Bootstrap.Admin/Models/AdminModel.cs | 90 +++++++++++++++++++ .../Bootstrap.Admin/Models/ErrorModel.cs | 2 +- .../Bootstrap.Admin/Models/HeaderBarModel.cs | 2 +- .../Bootstrap.Admin/Models/LoginModel.cs | 2 +- src/admin/Bootstrap.Admin/Models/ModelBase.cs | 86 +----------------- .../Views/Shared/Footer.cshtml | 2 +- .../Views/Shared/_Admin.cshtml | 2 +- 7 files changed, 97 insertions(+), 89 deletions(-) create mode 100644 src/admin/Bootstrap.Admin/Models/AdminModel.cs diff --git a/src/admin/Bootstrap.Admin/Models/AdminModel.cs b/src/admin/Bootstrap.Admin/Models/AdminModel.cs new file mode 100644 index 00000000..b15f5e87 --- /dev/null +++ b/src/admin/Bootstrap.Admin/Models/AdminModel.cs @@ -0,0 +1,90 @@ +using Bootstrap.DataAccess; + +namespace Bootstrap.Admin.Models +{ + /// + /// AdminModel 实体类 + /// + public class AdminModel : ModelBase + { + /// + /// 默认构造函数 + /// + /// + public AdminModel(string appId = "0") + { + Title = DictHelper.RetrieveWebTitle(appId); + Footer = DictHelper.RetrieveWebFooter(appId); + Theme = DictHelper.RetrieveActiveTheme(); + IsDemo = DictHelper.RetrieveSystemModel(); + ShowCardTitle = DictHelper.RetrieveCardTitleStatus() ? "" : "no-card-header"; + ShowSideBar = DictHelper.RetrieveSidebarStatus() ? "" : "collapsed"; + AllowMobile = DictHelper.RetrieveMobileLogin(); + AllowOAuth = DictHelper.RetrieveOAuthLogin(); + ShowMobile = AllowMobile ? "" : "mobile"; + ShowOAuth = AllowOAuth ? "" : "oauth"; + LockScreenPeriod = DictHelper.RetrieveAutoLockScreenPeriod(); + EnableAutoLockScreen = DictHelper.RetrieveAutoLockScreen(); + } + + /// + /// 获取 网站标题 + /// + public string Title { get; protected set; } + + /// + /// 获取 网站页脚 + /// + public string Footer { get; protected set; } + + /// + /// 网站样式全局设置 + /// + public string Theme { get; protected set; } + + /// + /// 是否为演示系统 + /// + public bool IsDemo { get; protected set; } + + /// + /// 是否显示卡片标题 + /// + public string ShowCardTitle { get; protected set; } + + /// + /// 是否收缩侧边栏 + /// + public string ShowSideBar { get; protected set; } + + /// + /// 获得 是否允许短信验证码登录 + /// + public bool AllowMobile { get; } + + /// + /// 获得 是否允许第三方 OAuth 认证登录 + /// + public bool AllowOAuth { get; } + + /// + /// 获得 是否允许短信验证码登录 + /// + public string ShowMobile { get; } + + /// + /// 获得 是否允许第三方 OAuth 认证登录 + /// + public string ShowOAuth { get; } + + /// + /// 获得 自动锁屏时长 默认 1 分钟 字典表中配置 + /// + public int LockScreenPeriod { get; } + + /// + /// 获得 自动锁屏功能是否自动开启 默认关闭 + /// + public bool EnableAutoLockScreen { get; } + } +} diff --git a/src/admin/Bootstrap.Admin/Models/ErrorModel.cs b/src/admin/Bootstrap.Admin/Models/ErrorModel.cs index 219026a8..cff7c322 100644 --- a/src/admin/Bootstrap.Admin/Models/ErrorModel.cs +++ b/src/admin/Bootstrap.Admin/Models/ErrorModel.cs @@ -3,7 +3,7 @@ /// /// /// - public class ErrorModel + public class ErrorModel : ModelBase { /// /// diff --git a/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs b/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs index 724168bc..57e3a41b 100644 --- a/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/src/admin/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -7,7 +7,7 @@ namespace Bootstrap.Admin.Models /// /// /// - public class HeaderBarModel : ModelBase + public class HeaderBarModel : AdminModel { /// /// diff --git a/src/admin/Bootstrap.Admin/Models/LoginModel.cs b/src/admin/Bootstrap.Admin/Models/LoginModel.cs index 1870ba6c..0bf4bb48 100644 --- a/src/admin/Bootstrap.Admin/Models/LoginModel.cs +++ b/src/admin/Bootstrap.Admin/Models/LoginModel.cs @@ -5,7 +5,7 @@ namespace Bootstrap.Admin.Models /// /// 登陆页面 Model /// - public class LoginModel : ModelBase + public class LoginModel : AdminModel { /// /// 默认构造函数 diff --git a/src/admin/Bootstrap.Admin/Models/ModelBase.cs b/src/admin/Bootstrap.Admin/Models/ModelBase.cs index 9defc37c..11aaf5da 100644 --- a/src/admin/Bootstrap.Admin/Models/ModelBase.cs +++ b/src/admin/Bootstrap.Admin/Models/ModelBase.cs @@ -1,95 +1,13 @@ -using Bootstrap.DataAccess; - -namespace Bootstrap.Admin.Models +namespace Bootstrap.Admin.Models { /// - /// ModelBase 基础类 + /// /// public class ModelBase { - /// - /// 默认构造函数 - /// - /// - public ModelBase(string appId = "0") - { - Title = DictHelper.RetrieveWebTitle(appId); - Footer = DictHelper.RetrieveWebFooter(appId); - Theme = DictHelper.RetrieveActiveTheme(); - IsDemo = DictHelper.RetrieveSystemModel(); - ShowCardTitle = DictHelper.RetrieveCardTitleStatus() ? "" : "no-card-header"; - ShowSideBar = DictHelper.RetrieveSidebarStatus() ? "" : "collapsed"; - AllowMobile = DictHelper.RetrieveMobileLogin(); - AllowOAuth = DictHelper.RetrieveOAuthLogin(); - ShowMobile = AllowMobile ? "" : "mobile"; - ShowOAuth = AllowOAuth ? "" : "oauth"; - LockScreenPeriod = DictHelper.RetrieveAutoLockScreenPeriod(); - EnableAutoLockScreen = DictHelper.RetrieveAutoLockScreen(); - } - /// /// 获取 网站 logo 小图标 /// public string WebSiteLogo { get; protected set; } = "~/favicon.ico"; - - /// - /// 获取 网站标题 - /// - public string Title { get; protected set; } - - /// - /// 获取 网站页脚 - /// - public string Footer { get; protected set; } - - /// - /// 网站样式全局设置 - /// - public string Theme { get; protected set; } - - /// - /// 是否为演示系统 - /// - public bool IsDemo { get; protected set; } - - /// - /// 是否显示卡片标题 - /// - public string ShowCardTitle { get; protected set; } - - /// - /// 是否收缩侧边栏 - /// - public string ShowSideBar { get; protected set; } - - /// - /// 获得 是否允许短信验证码登录 - /// - public bool AllowMobile { get; } - - /// - /// 获得 是否允许第三方 OAuth 认证登录 - /// - public bool AllowOAuth { get; } - - /// - /// 获得 是否允许短信验证码登录 - /// - public string ShowMobile { get; } - - /// - /// 获得 是否允许第三方 OAuth 认证登录 - /// - public string ShowOAuth { get; } - - /// - /// 获得 自动锁屏时长 默认 1 分钟 字典表中配置 - /// - public int LockScreenPeriod { get; } - - /// - /// 获得 自动锁屏功能是否自动开启 默认关闭 - /// - public bool EnableAutoLockScreen { get; } } } diff --git a/src/admin/Bootstrap.Admin/Views/Shared/Footer.cshtml b/src/admin/Bootstrap.Admin/Views/Shared/Footer.cshtml index 396d3687..7ee059d8 100644 --- a/src/admin/Bootstrap.Admin/Views/Shared/Footer.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Shared/Footer.cshtml @@ -1,4 +1,4 @@ -@model ModelBase +@model AdminModel