From ec1da85efd9122ae771071b23a9901346b6d80aa Mon Sep 17 00:00:00 2001 From: luchenqun Date: Thu, 30 Nov 2017 17:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E7=B1=BB=E5=AE=9A?= =?UTF-8?q?=E5=88=B6=E7=9A=84=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/scripts/app-angular.js | 1 + .../scripts/controllers/menus-controller.js | 62 +++++++++++-------- public/scripts/controllers/tags-controller.js | 3 +- public/scripts/services/data-service.js | 3 + 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/public/scripts/app-angular.js b/public/scripts/app-angular.js index a13061d..f4450b6 100644 --- a/public/scripts/app-angular.js +++ b/public/scripts/app-angular.js @@ -46,6 +46,7 @@ app.config(function($stateProvider, $urlRouterProvider, $httpProvider) { templateUrl: '/views/tags.html', params: { tagId: null, + orderIndex: null, }, controller: 'tagsCtr' }) diff --git a/public/scripts/controllers/menus-controller.js b/public/scripts/controllers/menus-controller.js index c364844..bbf794b 100644 --- a/public/scripts/controllers/menus-controller.js +++ b/public/scripts/controllers/menus-controller.js @@ -1,4 +1,4 @@ -app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$timeout', '$document', 'pubSubService', 'bookmarkService', 'dataService', function($scope, $stateParams, $state, $window, $timeout, $document, pubSubService, bookmarkService, dataService) { +app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$timeout', '$document', 'pubSubService', 'bookmarkService', 'dataService', function ($scope, $stateParams, $state, $window, $timeout, $document, pubSubService, bookmarkService, dataService) { console.log("Hello menuCtr") $scope.login = false; /**< 是否登陆 */ $scope.selectLoginIndex = 0; /**< 默认登陆之后的选择的菜单索引,下表从 0 开始 */ @@ -11,14 +11,14 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time $scope.longPress = false; // 防止在登陆的情况下,在浏览器里面直接输入url,这时候要更新菜单选项 - pubSubService.subscribe('Common.menuActive', $scope, function(event, params) { + pubSubService.subscribe('Common.menuActive', $scope, function (event, params) { console.log("subscribe Common.menuActive, login = " + params.login + ", index = " + params.index); $scope.login = (params && params.login) || false; var index = $scope.login ? ($scope.selectLoginIndex = (params && params.index) || 0) : ($scope.selectNotLoginIndex = (params && params.index) || 0); updateMenuActive(index); }); - pubSubService.subscribe('Settings.quickUrl', $scope, function(event, params) { + pubSubService.subscribe('Settings.quickUrl', $scope, function (event, params) { $scope.quickUrl = params.quickUrl; }); @@ -29,7 +29,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time * @func * @desc 点击搜索按钮搜索书签 */ - $scope.search = function(searchWord) { + $scope.search = function (searchWord) { console.log('search......', searchWord); $scope.login = true; @@ -38,8 +38,8 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time $state.go('search', { searchWord: searchWord, }, { - reload: true, - }) + reload: true, + }) updateMenuActive($scope.selectLoginIndex = 0); } else if (searchOption == 1) { $window.open('https://www.google.com.hk/#newwindow=1&safe=strict&q=' + encodeURIComponent(searchWord), '_blank'); @@ -54,8 +54,8 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time $state.go('note', { searchWord: searchWord, }, { - reload: true, - }) + reload: true, + }) updateMenuActive($scope.selectLoginIndex = dataService.LoginIndexNote); } @@ -84,7 +84,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time } } - $scope.searchByHistory = function(type, data) { + $scope.searchByHistory = function (type, data) { $scope.searchWord = data; $('.search-item').val($scope.searchWord); @@ -98,7 +98,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time $scope.search(data); } - $scope.delHistory = function(type, data) { + $scope.delHistory = function (type, data) { var delIndex = -1; $scope.searchHistory.forEach((item, index) => { if (index >= 1 && item.t == type && item.d == data) { @@ -109,28 +109,28 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time $scope.searchHistory.splice(delIndex, 1); } saveHistory(); - $timeout(function() { + $timeout(function () { $('.js-history-popup').removeClass('hidden').addClass('visible'); }, 500) } - $scope.updateShowStyle = function(showStyle) { + $scope.updateShowStyle = function (showStyle) { console.log('updateShowStyle', showStyle); $scope.showStyle = showStyle; $('.js-radio-' + showStyle).checkbox('set checked'); $state.go('bookmarks', { showStyle: showStyle, }, { - reload: true, - }) + reload: true, + }) } - $scope.showAddBookmarkMoadl = function() { + $scope.showAddBookmarkMoadl = function () { pubSubService.publish('MenuCtr.showAddBookmarkMoadl', { 'action': 'add' }); } - $scope.logout = function() { + $scope.logout = function () { bookmarkService.logout({}) .then((data) => { console.log('logout..........', data) @@ -186,7 +186,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time $scope.searchHistory = JSON.parse(user.search_history || '[]'); $scope.quickUrl = JSON.parse(user.quick_url || '{}'); - $timeout(function() { + $timeout(function () { var showStyle = (user && user.show_style) || 'navigate'; if (showStyle) { $('.js-bookmark-dropdown' + ' .radio.checkbox').checkbox('set unchecked'); @@ -201,7 +201,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time // toastr.error('获取信息失败。错误信息:' + JSON.stringify(err), "错误"); }); - $timeout(function() { + $timeout(function () { $('.suggest') .popup({ title: '操作提示', @@ -212,8 +212,8 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time }, 1000) // 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键 - $document.bind("keydown", function(event) { - $scope.$apply(function() { + $document.bind("keydown", function (event) { + $scope.$apply(function () { var key = event.key.toUpperCase(); if (key == 'CONTROL' || key == 'SHIFT' || key == 'ALT') { $scope.longPress = true; @@ -225,14 +225,22 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time if (key == 'A') { if ($scope.selectLoginIndex !== dataService.LoginIndexNote) { updateMenuActive($scope.selectLoginIndex = dataService.LoginIndexNote); - $state.go('note', { - key: key, - }, { - reload: true, - }) + $state.go('note', { key: key }, { reload: true }) } } + if (key == ',' || key == '.' || key == '/') { + pubSubService.publish('Common.menuActive', { + login: $scope.login, + index: dataService.LoginIndexTags + }); + var stateParams = { + tagId: -1, + orderIndex: (key == ',' ? 0 : (key == '.' ? 1 : 2)), + } + $state.go(dataService.loginMenus[dataService.LoginIndexTags].uiSref, stateParams, { reload: true, }) + } + // 数字键用来切换菜单 if (!isNaN(key)) { var num = parseInt(key); @@ -254,8 +262,8 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time }); // 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键 - $document.bind("keyup", function(event) { - $scope.$apply(function() { + $document.bind("keyup", function (event) { + $scope.$apply(function () { var key = event.key.toUpperCase(); // console.log('keyup key = ', key); if (key == 'CONTROL' || key == 'SHIFT' || key == 'ALT') { diff --git a/public/scripts/controllers/tags-controller.js b/public/scripts/controllers/tags-controller.js index 265282c..c74a9fe 100644 --- a/public/scripts/controllers/tags-controller.js +++ b/public/scripts/controllers/tags-controller.js @@ -78,6 +78,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim } $scope.getBookmarks = function(tagId, currentPage) { + console.log(tagId, currentPage) $scope.bookmarkClicked = true; $scope.currentTagId = tagId; $scope.currentPage = currentPage; @@ -473,7 +474,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim find = true; // 如果是删了分类返回来,那么要重新默认选中第一个分类 } }) - if (!find) $scope.currentTagId = null; + if (!find && $scope.currentTagId !== -1) $scope.currentTagId = null; if (!$scope.currentTagId && $scope.tags.length > 0) { $scope.currentTagId = $scope.tags[0].id; $scope.tags[0].bookmarkClicked = true; diff --git a/public/scripts/services/data-service.js b/public/scripts/services/data-service.js index 8c49660..2094463 100644 --- a/public/scripts/services/data-service.js +++ b/public/scripts/services/data-service.js @@ -91,6 +91,9 @@ app.factory('dataService', [function() { 'R': '在热门收藏界面,已用作随机查看热门收藏', 'INSERT': '全局页面,已用做添加书签', 'ESC': '全局页面,已用做退出弹窗', + ',': '跳转到分类定制点击次数', + '.': '跳转到分类定制添加日期', + '/': '跳转到分类定制最后点击', }, keyShortcuts: function() { // 判断快捷方式是否生效 var ret = true;