From a930cb11b13b47fd514afbd27e6c2ca3cc6cdce4 Mon Sep 17 00:00:00 2001 From: luchenqun Date: Fri, 9 Jun 2017 21:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E5=AD=97=E9=94=AE?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + .../scripts/controllers/menus-controller.js | 20 ++++-- .../controllers/settings-controller.js | 9 +-- public/views/menus.html | 12 +--- public/views/settings.html | 68 +++++++++---------- 5 files changed, 58 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index f6e41a7..adc2b2f 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ - [x] 在热门标签里面,有在网上找的热门书签。可以转存收藏到自己书签里面,快捷键R随机查看热门书签。 - [x] 新增备忘录功能,有时候随手要做点纪录,就方便了。任意界面按快捷键A增加备忘录。双击备忘录可查看详情! - [x] 在设置的全局链接,可设置快捷键,用来在任何页面,快速打开设置的链接。 +- [ ] 适配手机平板。 4 主要用到的模块说明 ------------------ diff --git a/public/scripts/controllers/menus-controller.js b/public/scripts/controllers/menus-controller.js index 53b28a1..f96961e 100644 --- a/public/scripts/controllers/menus-controller.js +++ b/public/scripts/controllers/menus-controller.js @@ -7,7 +7,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time $scope.showStyle = null; $scope.searchHistory = []; $scope.historyTypes = dataService.historyTypes; - $scope.quickUrl = { }; + $scope.quickUrl = {}; $scope.longPress = false; // 防止在登陆的情况下,在浏览器里面直接输入url,这时候要更新菜单选项 @@ -213,9 +213,21 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time } } - var url = $scope.quickUrl[key]; - if (url) { - $window.open(url, '_blank'); + // 数字键用来切换菜单 + if (!isNaN(key)) { + var num = parseInt(key); + pubSubService.publish('Common.menuActive', { + login: $scope.login, + index: num - 1 + }); + $state.go(dataService.loginMenus[num - 1].uiSref, {}, { + reload: true, + }) + } else { + var url = $scope.quickUrl[key]; + if (url) { + $window.open(url, '_blank'); + } } } }) diff --git a/public/scripts/controllers/settings-controller.js b/public/scripts/controllers/settings-controller.js index 0d6a496..959e79a 100644 --- a/public/scripts/controllers/settings-controller.js +++ b/public/scripts/controllers/settings-controller.js @@ -116,16 +116,16 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$ $scope.quickKey = function(key) { key = key.toUpperCase(); console.log('key = ', key); - if (!((key >= 'A' && key <= 'Z') || (key >= '1' && key <= '9'))) { + if (!(key >= 'A' && key <= 'Z')) { key = ''; - toastr.warning('快捷键只能是数字1 ~ 9或者字母a ~ z,字母不区分大小写。', "警告"); + toastr.warning('快捷键只能是字母a ~ z,字母不区分大小写。', "警告"); } $timeout(function() { $scope.key = key; }); } - $scope.addQuickUrl = function(){ + $scope.addQuickUrl = function() { if ($scope.url == '' || $scope.key == '') { toastr.warning('快捷键或者网站地址为空!', "警告"); } @@ -136,7 +136,7 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$ return; } if (!(($scope.key >= 'A' && $scope.key <= 'Z') || ($scope.key >= 'a' && $scope.key <= 'z') || ($scope.key >= '1' && $scope.key <= '9'))) { - toastr.warning('快捷键只能是数字1 ~ 9或者字母a ~ z,字母不区分大小写。', "警告"); + toastr.warning('快捷键只能是字母a ~ z,字母不区分大小写。', "警告"); $scope.key = ''; return; } @@ -227,6 +227,7 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$ } transition(); + function transition() { var className = 'js-segment-settings'; $('.' + className).transition('hide'); diff --git a/public/views/menus.html b/public/views/menus.html index c242c5e..56ff318 100644 --- a/public/views/menus.html +++ b/public/views/menus.html @@ -46,15 +46,7 @@ - +