diff --git a/Bootstrap.Admin/wwwroot/js/common-scripts.js b/Bootstrap.Admin/wwwroot/js/common-scripts.js index 0e7dfb53..b493fa6d 100644 --- a/Bootstrap.Admin/wwwroot/js/common-scripts.js +++ b/Bootstrap.Admin/wwwroot/js/common-scripts.js @@ -1,53 +1,40 @@ (function ($) { - var formatCategoryName = function (menu) { - var ret = ""; - if (menu.IsResource === 2) ret = "按钮"; - else if (menu.IsResource === 1) ret = "资源"; - else ret = menu.CategoryName; - return ret; - }; + $.fn.extend({ + autoScrollSidebar: function (options) { + var option = $.extend({ target: null, offsetTop: 0 }, options); + var $navItem = option.target; + if ($navItem === null || $navItem.length === 0) return this; - var cascadeMenu = function (menus) { - var html = ""; - $.each(menus, function (index, menu) { - if (menu.Menus.length === 0) { - html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu)); + // sidebar scroll animate + var middle = this.outerHeight() / 2; + var top = $navItem.offset().top + option.offsetTop - this.offset().top; + var $scrollInstance = this[0]["__overlayScrollbars__"]; + if (top > middle) { + if ($scrollInstance) $scrollInstance.scroll({ x: 0, y: top - middle }, 500, "swing"); + else this.animate({ scrollTop: top - middle }); + } + return this; + }, + addNiceScroll: function () { + if (!$.browser.versions.ios && $(window).width() > 768) { + this.overlayScrollbars({ + className: 'os-theme-light', + scrollbars: { + autoHide: 'leave', + autoHideDelay: 100 + }, + overflowBehavior: { + x: "hidden", + y: "scroll" + } + }); } else { - html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu)); + this.css('overflow', 'auto'); } - }); - return html; - }; - - var cascadeSubMenu = function (menus) { - var html = ""; - $.each(menus, function (index, menu) { - if (menu.Menus.length === 0) { - html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu)); - } - else { - html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu)); - } - }); - return html; - }; - - var setBadge = function (source) { - var data = $.extend({ - TasksCount: 0, - AppExceptionsCount: 0, - DbExceptionsCount: 0, - MessagesCount: 0, - NewUsersCount: 0 - }, source); - $('#msgHeaderTaskBadge').text(data.TasksCount === 0 ? "" : data.TasksCount); - $('#msgHeaderUserBadge').text(data.NewUsersCount === 0 ? "" : data.NewUsersCount); - $('#msgHeaderAppBadge').text(data.AppExceptionsCount === 0 ? "" : data.AppExceptionsCount); - $('#msgHeaderDbBadge').text(data.DbExceptionsCount === 0 ? "" : data.DbExceptionsCount); - $('#msgHeaderMsgBadge').text(data.MessagesCount === 0 ? "" : data.MessagesCount); - $('#logoutNoti').text(data.NewUsersCount === 0 ? "" : data.NewUsersCount); - }; + return this; + } + }); $.fn.extend({ nestMenu: function (callback) { @@ -127,6 +114,56 @@ return this; } }); + + var formatCategoryName = function (menu) { + var ret = ""; + if (menu.IsResource === 2) ret = "按钮"; + else if (menu.IsResource === 1) ret = "资源"; + else ret = menu.CategoryName; + return ret; + }; + + var cascadeMenu = function (menus) { + var html = ""; + $.each(menus, function (index, menu) { + if (menu.Menus.length === 0) { + html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu)); + } + else { + html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu)); + } + }); + return html; + }; + + var cascadeSubMenu = function (menus) { + var html = ""; + $.each(menus, function (index, menu) { + if (menu.Menus.length === 0) { + html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu)); + } + else { + html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, formatCategoryName(menu)); + } + }); + return html; + }; + + var setBadge = function (source) { + var data = $.extend({ + TasksCount: 0, + AppExceptionsCount: 0, + DbExceptionsCount: 0, + MessagesCount: 0, + NewUsersCount: 0 + }, source); + $('#msgHeaderTaskBadge').text(data.TasksCount === 0 ? "" : data.TasksCount); + $('#msgHeaderUserBadge').text(data.NewUsersCount === 0 ? "" : data.NewUsersCount); + $('#msgHeaderAppBadge').text(data.AppExceptionsCount === 0 ? "" : data.AppExceptionsCount); + $('#msgHeaderDbBadge').text(data.DbExceptionsCount === 0 ? "" : data.DbExceptionsCount); + $('#msgHeaderMsgBadge').text(data.MessagesCount === 0 ? "" : data.MessagesCount); + $('#logoutNoti').text(data.NewUsersCount === 0 ? "" : data.NewUsersCount); + }; })(jQuery); $(function () { @@ -137,43 +174,6 @@ $(function () { var arch = $sideMenu.find('a.active').last(); $breadNav.removeClass('d-none').text(arch.text() || $('title').text()); - $.fn.extend({ - autoScrollSidebar: function (options) { - var option = $.extend({ target: null, offsetTop: 0 }, options); - var $navItem = option.target; - if ($navItem === null || $navItem.length === 0) return this; - - // sidebar scroll animate - var middle = this.outerHeight() / 2; - var top = $navItem.offset().top + option.offsetTop - this.offset().top; - var $scrollInstance = this[0]["__overlayScrollbars__"]; - if (top > middle) { - if ($scrollInstance) $scrollInstance.scroll({ x: 0, y: top - middle }, 500, "swing"); - else this.animate({ scrollTop: top - middle }); - } - return this; - }, - addNiceScroll: function () { - if (!$.browser.versions.ios && $(window).width() > 768) { - this.overlayScrollbars({ - className: 'os-theme-light', - scrollbars: { - autoHide: 'leave', - autoHideDelay: 100 - }, - overflowBehavior: { - x: "hidden", - y: "scroll" - } - }); - } - else { - this.css('overflow', 'auto'); - } - return this; - } - }); - // custom scrollbar var $sidebar = $('.sidebar').addNiceScroll().autoScrollSidebar({ target: arch.parent(), offsetTop: arch.parent().innerHeight() / 2 }); diff --git a/Bootstrap.Client/Models/ModelBase.cs b/Bootstrap.Client/Models/ModelBase.cs index 2b76baf7..a628a623 100644 --- a/Bootstrap.Client/Models/ModelBase.cs +++ b/Bootstrap.Client/Models/ModelBase.cs @@ -3,12 +3,12 @@ namespace Bootstrap.Client.Models { /// - /// + /// ModelBase 基础类 /// public class ModelBase { /// - /// + /// 默认构造函数 /// public ModelBase() { @@ -16,17 +16,30 @@ namespace Bootstrap.Client.Models Footer = DbHelper.RetrieveFooter(); Theme = DbHelper.RetrieveActiveTheme(); } + /// - /// + /// 获取 网站标题 /// - public string Title { get; } + public string Title { get; private set; } + /// - /// + /// 获取 网站页脚 /// - public string Footer { get; } + public string Footer { get; private set; } + /// - /// + /// 网站样式全局设置 /// public string Theme { get; protected set; } + + /// + /// 是否显示卡片标题 + /// + public string ShowCardTitle { get; protected set; } = ""; + + /// + /// 是否收缩侧边栏 + /// + public string ShowSideBar { get; protected set; } = ""; } } diff --git a/Bootstrap.Client/Views/Shared/Header.cshtml b/Bootstrap.Client/Views/Shared/Header.cshtml index 45c4f376..ba2571f5 100644 --- a/Bootstrap.Client/Views/Shared/Header.cshtml +++ b/Bootstrap.Client/Views/Shared/Header.cshtml @@ -28,6 +28,15 @@ @Model.DisplayName