diff --git a/README.zh-CN.md b/README.zh-CN.md index ef2c8bca..8837d6d9 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -118,9 +118,7 @@ 2. 安装 Visual Studio 2019 以上 [官方网址](https://visualstudio.microsoft.com/vs/getting-started/) 3. 获取本项目代码 [BootstrapAdmin](https://gitee.com/LongbowEnterprise/BootstrapAdmin) -*注意* -master 分支为 NETCore 3.0 框架 必须使用 Visual Studio 2019 (v16.3) -netcore-2.2 分支为 NETCore 2.2 框架支持 Visual Studio 2017 (v15.9+) +环境搭建教程 [详细说明](https://gitee.com/LongbowEnterprise/BootstrapAdmin/wikis/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B?sort_id=1333477) ### 安装数据库 diff --git a/appveyor.yml b/appveyor.yml index 388eced8..6b684e57 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.0.{build} +version: 3.1.{build} branches: only: - release diff --git a/db/MongoDB/Dicts.js b/db/MongoDB/Dicts.js index fbcf46e9..e2a6858d 100644 --- a/db/MongoDB/Dicts.js +++ b/db/MongoDB/Dicts.js @@ -282,6 +282,12 @@ "Code": "0", "Define": NumberInt(0) }, + { + "Category": "系统设置", + "Name": "默认应用程序", + "Code": "0", + "Define": NumberInt(0) + }, { "Category": "测试平台", "Name": "favicon", diff --git a/db/MongoDB/Navigations.js b/db/MongoDB/Navigations.js index 8a5cf67e..fb2c5454 100644 --- a/db/MongoDB/Navigations.js +++ b/db/MongoDB/Navigations.js @@ -215,6 +215,18 @@ "IsResource": NumberInt(2), "Application": "BA" }, + { + "_id": ObjectId("5bd7b8445fa31256f77e4b08"), + "ParentId": "5bd7b8445fa31256f77e4b93", + "Name": "默认应用", + "Order": NumberInt(80), + "Icon": "fa fa-fa", + "Url": "defaultApp", + "Category": "0", + "Target": "_self", + "IsResource": NumberInt(2), + "Application": "BA" + }, { "_id": ObjectId("5bd7b8445fa31256f77e4b94"), "ParentId": "0", diff --git a/db/MySQL/initData.sql b/db/MySQL/initData.sql index 406b14c2..c5cc1483 100644 --- a/db/MySQL/initData.sql +++ b/db/MySQL/initData.sql @@ -53,11 +53,14 @@ INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', 'Cookie INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', 'IP地理位置接口', 'None', 0); INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', 'BaiDuIPSvr', 'http://api.map.baidu.com/location/ip?ak=6lvVPMDlm2gjLpU0aiqPsHXi2OiwGQRj&ip=', 0); INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', 'JuheIPSvr', 'http://apis.juhe.cn/ip/ipNew?key=f57102d1b9fadd3f4a1c29072d0c0206&ip=', 0); + -- 时长单位 分钟 INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', 'IP请求缓存时长', '10', 0); INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', '演示系统', '0', 0); INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', '验证码图床', 'http://imgs.sdgxgz.com/images/', 0); +INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', '默认应用程序', '0', 0); + DELETE FROM Navigations Where Category = '0'; INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category) VALUES (0, '后台管理', 10, 'fa fa-gear', '~/Admin/Index', '0'); INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category) VALUES (0, '个人中心', 20, 'fa fa-suitcase', '~/Admin/Profiles', '0'); @@ -77,6 +80,7 @@ INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category, IsResourc INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category, IsResource) VALUES (@@identity - 4, '清理全部缓存', 50, 'fa fa-fa', 'clearAllCache', '0', 2); INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category, IsResource) VALUES (@@identity - 5, '登录设置', 60, 'fa fa-fa', 'loginSettings', '0', 2); INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category, IsResource) VALUES (@@identity - 6, '自动锁屏', 70, 'fa fa-fa', 'lockScreen', '0', 2); +INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category, IsResource) VALUES (@@identity - 7, '默认应用', 80, 'fa fa-fa', 'defaultApp', '0', 2); INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category) VALUES (0, '菜单管理', 50, 'fa fa-dashboard', '~/Admin/Menus', '0'); INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category, IsResource) VALUES (@@identity, '新增', 10, 'fa fa-fa', 'add', '0', 2); INSERT INTO Navigations (ParentId, Name, `Order`, Icon, Url, Category, IsResource) VALUES (@@identity - 1, '编辑', 20, 'fa fa-fa', 'edit', '0', 2); diff --git a/db/SQLite/InitData.sql b/db/SQLite/InitData.sql index b5b13e4c..f19655ee 100644 --- a/db/SQLite/InitData.sql +++ b/db/SQLite/InitData.sql @@ -53,11 +53,14 @@ INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置 INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', 'IP地理位置接口', 'None', 0); INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', 'BaiDuIPSvr', 'http://api.map.baidu.com/location/ip?ak=6lvVPMDlm2gjLpU0aiqPsHXi2OiwGQRj&ip=', 0); INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', 'JuheIPSvr', 'http://apis.juhe.cn/ip/ipNew?key=f57102d1b9fadd3f4a1c29072d0c0206&ip=', 0); + -- 时长单位 分钟 INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', 'IP请求缓存时长', '10', 0); INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', '演示系统', '0', 0); INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', '验证码图床', 'http://imgs.sdgxgz.com/images/', 0); +INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', '默认应用程序', '0', 0); + DELETE FROM Navigations Where Category = '0'; INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, '后台管理', 10, 'fa fa-gear', '~/Admin/Index', '0'); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, '个人中心', 20, 'fa fa-suitcase', '~/Admin/Profiles', '0'); @@ -77,6 +80,7 @@ INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (last_insert_rowid() - 4, '清理全部缓存', 50, 'fa fa-fa', 'clearAllCache', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (last_insert_rowid() - 5, '登录设置', 60, 'fa fa-fa', 'loginSettings', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (last_insert_rowid() - 6, '自动锁屏', 70, 'fa fa-fa', 'lockScreen', '0', 2); +INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (last_insert_rowid() - 7, '默认应用', 80, 'fa fa-fa', 'defaultApp', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, '菜单管理', 50, 'fa fa-dashboard', '~/Admin/Menus', '0'); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (last_insert_rowid(), '新增', 10, 'fa fa-fa', 'add', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (last_insert_rowid() - 1, '编辑', 20, 'fa fa-fa', 'edit', '0', 2); diff --git a/db/SqlServer/InitData.sql b/db/SqlServer/InitData.sql index 028a3a18..13cb07f8 100644 --- a/db/SqlServer/InitData.sql +++ b/db/SqlServer/InitData.sql @@ -56,11 +56,14 @@ INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设 INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'IP地理位置接口', 'None', 0) INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'BaiDuIPSvr', 'http://api.map.baidu.com/location/ip?ak=6lvVPMDlm2gjLpU0aiqPsHXi2OiwGQRj&ip=', 0) INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'JuheIPSvr', 'http://apis.juhe.cn/ip/ipNew?key=f57102d1b9fadd3f4a1c29072d0c0206&ip=', 0) + -- 时长单位 分钟 INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'IP请求缓存时长', '10', 0) INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'演示系统', '0', 0) INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'验证码图床', 'http://imgs.sdgxgz.com/images/', 0) +INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'默认应用程序', '0', 0) + DELETE FROM Navigations Where Category = N'0' INSERT [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, N'后台管理', 10, N'fa fa-gear', N'~/Admin/Index', N'0') INSERT [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, N'个人中心', 20, N'fa fa-suitcase', N'~/Admin/Profiles', N'0') @@ -80,6 +83,7 @@ INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (@@Identity - 4, N'清理全部缓存', 50, 'fa fa-fa', 'clearAllCache', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (@@Identity - 5, N'登录设置', 60, 'fa fa-fa', 'loginSettings', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (@@Identity - 6, N'自动锁屏', 70, 'fa fa-fa', 'lockScreen', '0', 2); +INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (@@Identity - 7, N'默认应用', 80, 'fa fa-fa', 'defaultApp', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, N'菜单管理', 50, N'fa fa-dashboard', N'~/Admin/Menus', N'0') INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (@@Identity, N'新增', 10, 'fa fa-fa', 'add', '0', 2); INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], IsResource) VALUES (@@Identity - 1, N'编辑', 20, 'fa fa-fa', 'edit', '0', 2); diff --git a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj index 7795847a..22dca41f 100644 --- a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -10,10 +10,10 @@ - - - - + + + + diff --git a/src/admin/Bootstrap.Admin/BootstrapAdmin.db b/src/admin/Bootstrap.Admin/BootstrapAdmin.db index c48b58a8..a7a310c5 100644 Binary files a/src/admin/Bootstrap.Admin/BootstrapAdmin.db and b/src/admin/Bootstrap.Admin/BootstrapAdmin.db differ diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs index ec0bb679..02f5b8bc 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs @@ -22,7 +22,7 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [HttpPost] - [ButtonAuthorize(Url = "~/Admin/Settings", Auth = "saveTitle,saveFooter,saveTheme,saveUISettings")] + [ButtonAuthorize(Url = "~/Admin/Settings", Auth = "saveTitle,saveFooter,saveTheme,saveUISettings,clearCache,clearAllCache,loginSettings,lockScreen,defaultApp")] public bool Post([FromBody]BootstrapDict value) => DictHelper.SaveSettings(value); /// diff --git a/src/admin/Bootstrap.Admin/Controllers/HomeController.cs b/src/admin/Bootstrap.Admin/Controllers/HomeController.cs index 39809ace..e0d94ba7 100644 --- a/src/admin/Bootstrap.Admin/Controllers/HomeController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/HomeController.cs @@ -20,7 +20,7 @@ namespace Bootstrap.Admin.Controllers public IActionResult Index([FromServices]IConfiguration configuration) { var model = new HeaderBarModel(User.Identity.Name); - var homeUrl = DictHelper.RetrieveHomeUrl(model.AppId); + var homeUrl = DictHelper.RetrieveHomeUrl(User.Identity.Name, model.AppId); var useBlazor = configuration.GetValue("UseBlazor", false); return homeUrl.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (useBlazor ? Redirect("~/Pages") : (IActionResult)View(model)) : Redirect(homeUrl); } diff --git a/src/admin/Bootstrap.Admin/Models/SettingsModel.cs b/src/admin/Bootstrap.Admin/Models/SettingsModel.cs index 5320637c..d6602ef3 100644 --- a/src/admin/Bootstrap.Admin/Models/SettingsModel.cs +++ b/src/admin/Bootstrap.Admin/Models/SettingsModel.cs @@ -18,6 +18,7 @@ namespace Bootstrap.Admin.Models { Themes = DictHelper.RetrieveThemes(); AutoLockScreen = EnableAutoLockScreen ? "" : "lockScreen"; + DefaultApp = DictHelper.RetrieveDefaultApp() ? "" : "defaultApp"; } /// @@ -27,6 +28,7 @@ namespace Bootstrap.Admin.Models { Themes = DictHelper.RetrieveThemes(); AutoLockScreen = EnableAutoLockScreen ? "" : "lockScreen"; + DefaultApp = DictHelper.RetrieveDefaultApp() ? "" : "defaultApp"; } /// @@ -38,5 +40,10 @@ namespace Bootstrap.Admin.Models /// 获得 是否开启自动锁屏 /// public string AutoLockScreen { get; } + + /// + /// 获得 是否开启自动锁屏 + /// + public string DefaultApp { get; } } } diff --git a/src/admin/Bootstrap.Admin/Views/Admin/Dicts.cshtml b/src/admin/Bootstrap.Admin/Views/Admin/Dicts.cshtml index 14af234d..bd9f773d 100644 --- a/src/admin/Bootstrap.Admin/Views/Admin/Dicts.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Admin/Dicts.cshtml @@ -19,14 +19,14 @@ @section query {
-
- - -
+
+ + +
diff --git a/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml b/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml index 3af6d769..fb64e909 100644 --- a/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml @@ -143,6 +143,22 @@
+
+
默认应用设置
+
+
+
+
+ + +
+
+
+ +
+
diff --git a/src/admin/Bootstrap.Admin/libman.json b/src/admin/Bootstrap.Admin/libman.json index afa12208..d754210d 100644 --- a/src/admin/Bootstrap.Admin/libman.json +++ b/src/admin/Bootstrap.Admin/libman.json @@ -97,19 +97,6 @@ "sweetalert2.min.css" ] }, - { - "library": "malihu-custom-scrollbar-plugin@3.1.5", - "destination": "wwwroot/lib/scrollbar/", - "files": [ - "jquery.mCustomScrollbar.concat.min.js", - "jquery.mCustomScrollbar.css", - "jquery.mCustomScrollbar.js", - "jquery.mCustomScrollbar.min.css", - "jquery.mCustomScrollbar.min.js", - "jquery.mCustomScrollbar.min.js.map", - "mCSB_buttons.png" - ] - }, { "library": "smalot-bootstrap-datetimepicker@2.4.4", "destination": "wwwroot/lib/datetimepicker", @@ -121,16 +108,6 @@ "js/bootstrap-datetimepicker.min.js" ] }, - { - "provider": "unpkg", - "library": "dcjqaccordion@2.7.1", - "destination": "wwwroot/lib/dcjqaccordion/", - "files": [ - "js/jquery.dcjqaccordion.2.7.js", - "js/jquery.dcjqaccordion.2.7.min.js", - "js/jquery.cookie.js" - ] - }, { "provider": "cdnjs", "library": "bootstrap-fileinput@4.5.1", diff --git a/src/admin/Bootstrap.Admin/wwwroot/css/blue.css b/src/admin/Bootstrap.Admin/wwwroot/css/blue.css index a8ff3064..0a2b06eb 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/css/blue.css +++ b/src/admin/Bootstrap.Admin/wwwroot/css/blue.css @@ -62,7 +62,7 @@ } .card:hover { - border-top-color: #337ab7; + border-top-color: #84bbe2; } .card .card-header, .modal-header { diff --git a/src/admin/Bootstrap.Admin/wwwroot/css/site.css b/src/admin/Bootstrap.Admin/wwwroot/css/site.css index c52cfa7f..716d28c7 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/css/site.css +++ b/src/admin/Bootstrap.Admin/wwwroot/css/site.css @@ -350,6 +350,10 @@ body.trans-mute * { } .dd3-content .menuType { + right: 100px; + } + + .dd3-content .menuApp { right: 45px; } diff --git a/src/admin/Bootstrap.Admin/wwwroot/css/theme.css b/src/admin/Bootstrap.Admin/wwwroot/css/theme.css index e25109b3..83a6bf09 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/css/theme.css +++ b/src/admin/Bootstrap.Admin/wwwroot/css/theme.css @@ -587,6 +587,10 @@ input.pending { margin-top: -10px; } +.card .modal-footer { + padding: 0.5rem 0rem; +} + .no-card-header .card-header { display: none; } diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js b/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js index 56c11cde..c797f52a 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/common-scripts.js @@ -1,4 +1,4 @@ -(function ($) { +(function ($) { $.fn.extend({ autoScrollSidebar: function (options) { var option = $.extend({ target: null, offsetTop: 0 }, options); @@ -127,14 +127,18 @@ return ret; }; + var formatApplicationName = function (app) { + return app; + } + 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), menu.IsResource); + html += $.format('
  • {5}{7}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, formatCategoryName(menu), menu.IsResource, formatApplicationName(menu.Application)); } else { - html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeMenu(menu.Menus), menu.Order, formatCategoryName(menu), menu.IsResource); + html += $.format('
  • {6}{8}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeMenu(menu.Menus), menu.Order, formatCategoryName(menu), menu.IsResource, formatApplicationName(menu.Application)); } }); return html; diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js index 070266d2..a2852a25 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/menus.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/menus.js @@ -67,6 +67,13 @@ $(function () { } }, callback: function (result) { + if (result.oper === "create") { + $('#app').lgbSelect('enable'); + } + if (result.oper === "edit") { + var valid = result.data && result.data.ParentId === "0" && hasNodes(result.data.Id); + $('#app').lgbSelect(valid ? 'enable' : 'disabled'); + } if (!result.success) return; if ((result.oper === "save") || result.oper === "del") { if (result.data.filter(function (element) { @@ -153,6 +160,13 @@ $(function () { } }); + var hasNodes = function (idValue) { + var nodes = $table.bootstrapTable('getData').filter(function (row, index, data) { + return idValue == row["ParentId"]; + }); + return nodes.length === 0; + }; + // validate $('#dataForm').on('click', '[data-method]', function () { var $this = $(this); @@ -160,6 +174,11 @@ $(function () { switch ($this.attr('data-method')) { case 'clear': $input.val(""); + if ($input.attr('id') === 'parentName') { + // 判断是否有子项 + var valid = hasNodes($("#menuID").val()); + $('#app').lgbSelect(valid ? 'enable' : 'disabled'); + } break; case 'sel': $input.select(); @@ -247,6 +266,7 @@ $(function () { if (check) { $parentMenuID.val(pId); $parentMenuName.val($('.dd3-content :radio:checked').next('span').text()); + $('#app').lgbSelect('disabled'); } else { return false; diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/settings.js b/src/admin/Bootstrap.Admin/wwwroot/js/settings.js index af739de1..33bd25dd 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/settings.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/settings.js @@ -76,6 +76,12 @@ $(function () { } }); break; + case 'saveDefaultApp': + var defaultApp = $('#defaultApp').prop('checked') ? "1" : "0"; + $.bc({ + url: Settings.url, data: { name: '默认应用程序', code: defaultApp, category: '系统设置' }, title: '保存默认应用程序设置', method: "post" + }); + break; } }); diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js index 1f385c8c..068d8b01 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js @@ -107,9 +107,6 @@ }); return source; }, - sendHealths: function (data) { - $.bc({ url: 'api/Interface/Healths', data: JSON.stringify(data), method: 'post' }); - }, copyText: function (ele) { if (typeof ele !== "string") return false; var input = document.createElement('input'); diff --git a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj index 52e05aae..e356a9eb 100644 --- a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj +++ b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj @@ -5,10 +5,10 @@ - + - + diff --git a/src/admin/Bootstrap.DataAccess/Dict.cs b/src/admin/Bootstrap.DataAccess/Dict.cs index f6db9fc4..d46c68d3 100644 --- a/src/admin/Bootstrap.DataAccess/Dict.cs +++ b/src/admin/Bootstrap.DataAccess/Dict.cs @@ -114,23 +114,56 @@ namespace Bootstrap.DataAccess /// /// 获得默认的前台首页地址,默认为~/Home/Index /// - /// + /// 登录用户名 + /// 默认应用程序编码 /// - public virtual string RetrieveHomeUrl(string appId) + public virtual string RetrieveHomeUrl(string? userName, string appId) { // https://gitee.com/LongbowEnterprise/dashboard/issues?id=IS0WK + // https://gitee.com/LongbowEnterprise/dashboard/issues?id=I17SD0 var url = "~/Home/Index"; var dicts = DictHelper.RetrieveDicts(); - if (!appId.IsNullOrEmpty()) + + if (appId.IsNullOrEmpty()) { - var appUrl = dicts.FirstOrDefault(d => d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Category == "应用首页" && d.Define == 0)?.Code; - if (!string.IsNullOrEmpty(appUrl)) return appUrl; + var defaultUrl = dicts.FirstOrDefault(d => d.Name == "前台首页" && d.Category == "网站设置" && d.Define == 0)?.Code; + if (!string.IsNullOrEmpty(defaultUrl)) url = defaultUrl; + } + else if (appId.Equals("BA", StringComparison.OrdinalIgnoreCase)) + { + // 使用配置项设置是否启用默认第一个应用是默认应用 + var defaultApp = (dicts.FirstOrDefault(d => d.Name == "默认应用程序" && d.Category == "系统设置" && d.Define == 0)?.Code ?? "0") == "1"; + if (defaultApp) + { + var app = AppHelper.RetrievesByUserName(userName).FirstOrDefault(key => !key.Equals("BA", StringComparison.OrdinalIgnoreCase)) ?? ""; + if (!string.IsNullOrEmpty(app)) + { + // 指定应用程序的首页 + var appUrl = RetrieveDefaultHomeUrlByApp(dicts, app); + if (!string.IsNullOrEmpty(appUrl)) url = appUrl; + } + } + } + else + { + // 指定应用程序的首页 + var appUrl = RetrieveDefaultHomeUrlByApp(dicts, appId); + if (!string.IsNullOrEmpty(appUrl)) url = appUrl; } - var defaultUrl = dicts.FirstOrDefault(d => d.Name == "前台首页" && d.Category == "网站设置" && d.Define == 0)?.Code; - if (!string.IsNullOrEmpty(defaultUrl)) url = defaultUrl; return url; } + /// + /// 通过 appId 获取应用首页配置值 + /// + /// + /// + /// + protected virtual string RetrieveDefaultHomeUrlByApp(IEnumerable dicts, string appId) + { + return dicts.FirstOrDefault(d => d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Category == "应用首页" && d.Define == 0)?.Code ?? ""; + } + /// /// 获得字典表中配置的所有应用程序 /// @@ -174,7 +207,7 @@ namespace Bootstrap.DataAccess public string RetrieveLocaleIPSvr() => DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "系统设置" && d.Name == "IP地理位置接口" && d.Define == 0)?.Code ?? string.Empty; /// - /// 获取 IP地址位置缓存时长 + /// 获得 IP请求缓存时长配置值 /// /// public int RetrieveLocaleIPSvrCachePeriod() @@ -245,5 +278,11 @@ namespace Bootstrap.DataAccess ///
    /// public bool RetrieveAutoLockScreen() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "自动锁屏" && d.Define == 0)?.Code ?? "0") == "1"; + + /// + /// 获得默认应用是否开启 默认关闭 + /// + /// + public bool RetrieveDefaultApp() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "系统设置" && d.Name == "默认应用程序" && d.Define == 0)?.Code ?? "0") == "1"; } } diff --git a/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs index d5fd7fdb..10b29c3a 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs @@ -156,9 +156,10 @@ namespace Bootstrap.DataAccess /// /// 获得默认的前台首页地址,默认为 ~/Home/Index /// - /// 应用程序编码 + /// 登录用户名 + /// 默认应用程序编码 /// - public static string RetrieveHomeUrl(string appId) => DbContextManager.Create()?.RetrieveHomeUrl(appId) ?? "~/Home/Index"; + public static string RetrieveHomeUrl(string? userName, string appId) => DbContextManager.Create()?.RetrieveHomeUrl(userName, appId) ?? "~/Home/Index"; /// /// 获取所有应用程序数据方法 @@ -262,5 +263,11 @@ namespace Bootstrap.DataAccess /// /// public static bool RetrieveAutoLockScreen() => DbContextManager.Create()?.RetrieveAutoLockScreen() ?? false; + + /// + /// 获得自动锁屏 默认关闭 + /// + /// + public static bool RetrieveDefaultApp() => DbContextManager.Create()?.RetrieveDefaultApp() ?? false; } } diff --git a/src/client/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj b/src/client/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj index 471ae3c4..2d7267c9 100644 --- a/src/client/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj +++ b/src/client/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj @@ -5,10 +5,10 @@ - + - + diff --git a/src/client/Bootstrap.Client/Bootstrap.Client.csproj b/src/client/Bootstrap.Client/Bootstrap.Client.csproj index f6693afd..cc52d302 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/libman.json b/src/client/Bootstrap.Client/libman.json index a2ef075c..47ead7d7 100644 --- a/src/client/Bootstrap.Client/libman.json +++ b/src/client/Bootstrap.Client/libman.json @@ -2,17 +2,6 @@ "version": "1.0", "defaultProvider": "cdnjs", "libraries": [ - { - "provider": "unpkg", - "library": "@aspnet/signalr@1.0.4", - "destination": "wwwroot/lib/signalr/", - "files": [ - "dist/browser/signalr.js", - "dist/browser/signalr.js.map", - "dist/browser/signalr.min.js", - "dist/browser/signalr.min.js.map" - ] - }, { "provider": "cdnjs", "library": "jquery@3.3.1", @@ -45,16 +34,6 @@ "toastr.min.css" ] }, - { - "provider": "cdnjs", - "library": "jquery-treegrid@0.2.0", - "destination": "wwwroot/lib/treegrid/", - "files": [ - "css/jquery.treegrid.css", - "js/jquery.treegrid.js", - "js/jquery.treegrid.min.js" - ] - }, { "provider": "cdnjs", "library": "twitter-bootstrap@4.3.1", @@ -86,30 +65,6 @@ "fonts/FontAwesome.otf" ] }, - { - "provider": "cdnjs", - "library": "limonte-sweetalert2@7.33.1", - "destination": "wwwroot/lib/sweetalert/", - "files": [ - "sweetalert2.js", - "sweetalert2.min.js", - "sweetalert2.css", - "sweetalert2.min.css" - ] - }, - { - "library": "malihu-custom-scrollbar-plugin@3.1.5", - "destination": "wwwroot/lib/scrollbar/", - "files": [ - "jquery.mCustomScrollbar.concat.min.js", - "jquery.mCustomScrollbar.css", - "jquery.mCustomScrollbar.js", - "jquery.mCustomScrollbar.min.css", - "jquery.mCustomScrollbar.min.js", - "jquery.mCustomScrollbar.min.js.map", - "mCSB_buttons.png" - ] - }, { "library": "smalot-bootstrap-datetimepicker@2.4.4", "destination": "wwwroot/lib/datetimepicker", @@ -120,54 +75,6 @@ "js/bootstrap-datetimepicker.js", "js/bootstrap-datetimepicker.min.js" ] - }, - { - "provider": "unpkg", - "library": "dcjqaccordion@2.7.1", - "destination": "wwwroot/lib/dcjqaccordion/", - "files": [ - "js/jquery.dcjqaccordion.2.7.js", - "js/jquery.dcjqaccordion.2.7.min.js", - "js/jquery.cookie.js" - ] - }, - { - "provider": "cdnjs", - "library": "countup.js@1.9.3", - "destination": "wwwroot/lib/countUp/", - "files": [ - "countUp.js", - "countUp.min.js" - ] - }, - { - "provider": "cdnjs", - "library": "radialIndicator@1.3.1", - "destination": "wwwroot/lib/radiaIndicator", - "files": [ - "radialIndicator.js", - "radialIndicator.min.js" - ] - }, - { - "provider": "unpkg" - "library": "highcharts@6.2.0", - "destination": "wwwroot/lib/highcharts/", - "files": [ - "highcharts.js", - "highcharts.src.js" - ] - }, - { - "provider": "unpkg", - "library": "bootstrap-toggle@2.2.2", - "destination": "wwwroot/lib/bootstrap-toggle/", - "files": [ - "css/bootstrap-toggle.css", - "css/bootstrap-toggle.min.css", - "js/bootstrap-toggle.js", - "js/bootstrap-toggle.min.js" - ] } ] } \ No newline at end of file diff --git a/test/UnitTest/Bootstrap.Admin/Api/AnalyseTest.cs b/test/UnitTest/Bootstrap.Admin/Api/AnalyseTest.cs index 961e03d1..298c9d5a 100644 --- a/test/UnitTest/Bootstrap.Admin/Api/AnalyseTest.cs +++ b/test/UnitTest/Bootstrap.Admin/Api/AnalyseTest.cs @@ -17,7 +17,6 @@ namespace Bootstrap.Admin.Api Assert.NotNull(cates); cates = await Client.GetAsJsonAsync("?logType=trace"); Assert.NotNull(cates); - } } } diff --git a/test/UnitTest/Bootstrap.DataAccess/RollbackTest.cs b/test/UnitTest/Bootstrap.DataAccess/RollbackTest.cs index e23f5e40..393505d4 100644 --- a/test/UnitTest/Bootstrap.DataAccess/RollbackTest.cs +++ b/test/UnitTest/Bootstrap.DataAccess/RollbackTest.cs @@ -2,7 +2,7 @@ using UnitTest; using Xunit; -namespace Bootstrap.DataAccess +namespace Bootstrap.DataAccess.SqlServer { [Collection("SQLServerContext")] public class RollbackTest diff --git a/test/UnitTest/Bootstrap.DataAccess/SQLite/DictsTest.cs b/test/UnitTest/Bootstrap.DataAccess/SQLite/DictsTest.cs index 27920d1c..f180aa92 100644 --- a/test/UnitTest/Bootstrap.DataAccess/SQLite/DictsTest.cs +++ b/test/UnitTest/Bootstrap.DataAccess/SQLite/DictsTest.cs @@ -1,4 +1,5 @@ -using Xunit; +using System.Linq; +using Xunit; namespace Bootstrap.DataAccess.SQLite { @@ -6,5 +7,21 @@ namespace Bootstrap.DataAccess.SQLite public class DictsTest : SqlServer.DictsTest { protected override string DatabaseName { get; set; } = "SQLite"; + + [Fact] + public void RetrieveHomeUrl_Ok() + { + Assert.Equal("~/Home/Index", DictHelper.RetrieveHomeUrl("Admin", "")); + + var dict = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "系统设置" && d.Name == "默认应用程序"); + Assert.NotNull(dict); + dict.Code = "1"; + DictHelper.Save(dict); + Assert.Equal("http://localhost:49185/", DictHelper.RetrieveHomeUrl("Admin", "BA")); + dict.Code = "0"; + DictHelper.Save(dict); + Assert.Equal("~/Home/Index", DictHelper.RetrieveHomeUrl("Admin", "BA")); + Assert.Equal("http://localhost:49185/", DictHelper.RetrieveHomeUrl("Admin", "Demo")); + } } } diff --git a/test/UnitTest/Bootstrap.DataAccess/SystemModeTest.cs b/test/UnitTest/Bootstrap.DataAccess/SystemModeTest.cs index 322450bc..003c6601 100644 --- a/test/UnitTest/Bootstrap.DataAccess/SystemModeTest.cs +++ b/test/UnitTest/Bootstrap.DataAccess/SystemModeTest.cs @@ -4,7 +4,7 @@ using Longbow.Web; using System.Linq; using Xunit; -namespace Bootstrap.DataAccess +namespace Bootstrap.DataAccess.SqlServer { [Collection("SQLServerContext")] [AutoRollback] @@ -145,8 +145,8 @@ namespace Bootstrap.DataAccess [Fact] public void RetrieveHomeUrl_Ok() { - Assert.Equal("~/Home/Index", DictHelper.RetrieveHomeUrl("BA")); - var url = DictHelper.RetrieveHomeUrl("Demo"); + Assert.Equal("~/Home/Index", DictHelper.RetrieveHomeUrl("Admin", "BA")); + var url = DictHelper.RetrieveHomeUrl("Admin", "Demo"); Assert.Equal("http://localhost:49185/", url); // INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('应用首页', 2, 'http://localhost:49185/', 0); @@ -154,11 +154,11 @@ namespace Bootstrap.DataAccess url = dict.Code; dict.Code = "BA"; Assert.True(DictHelper.Save(dict)); - Assert.Equal("BA", DictHelper.RetrieveHomeUrl("Demo")); + Assert.Equal("BA", DictHelper.RetrieveHomeUrl("Admin", "Demo")); dict.Code = url; Assert.True(DictHelper.Save(dict)); - Assert.Equal(url, DictHelper.RetrieveHomeUrl("Demo")); + Assert.Equal(url, DictHelper.RetrieveHomeUrl("Admin", "Demo")); } } } diff --git a/test/UnitTest/UnitTest.csproj b/test/UnitTest/UnitTest.csproj index 21672c48..08858b27 100644 --- a/test/UnitTest/UnitTest.csproj +++ b/test/UnitTest/UnitTest.csproj @@ -7,11 +7,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive