屏蔽按Ctrl+c之类的快捷操作,误打开全局链接

This commit is contained in:
luchenqun 2017-05-18 11:04:35 +08:00
parent 26fe3af5ee
commit 91c998271b
2 changed files with 21 additions and 3 deletions

View File

@ -8,6 +8,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
$scope.searchHistory = [];
$scope.historyTypes = dataService.historyTypes;
$scope.quickUrl = { };
$scope.longPress = false;
// 防止在登陆的情况下在浏览器里面直接输入url这时候要更新菜单选项
pubSubService.subscribe('Common.menuActive', $scope, function(event, params) {
@ -193,9 +194,14 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function(event) {
$scope.$apply(function() {
if (dataService.keyShortcuts()) {
var key = event.key.toUpperCase();
if (key == 'CONTROL' || key == 'SHIFT' || key == 'ALT') {
$scope.longPress = true;
}
if (dataService.keyShortcuts()) {
// 全局处理添加备忘录
// console.log('keydown key = ', key);
if (key == 'A') {
if ($scope.selectLoginIndex !== dataService.LoginIndexNote) {
updateMenuActive($scope.selectLoginIndex = dataService.LoginIndexNote);
@ -215,4 +221,15 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
})
});
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$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') {
$scope.longPress = false;
}
})
});
}]);

View File

@ -71,9 +71,10 @@ app.factory('dataService', [function() {
keyShortcuts: function() { // 判断快捷方式是否生效
var ret = true;
var menusScope = $('div[ng-controller="menuCtr"]').scope();
var login = (menusScope && menusScope.login) || false;
var login = (menusScope && menusScope.login);
var longPress = (menusScope && menusScope.longPress);
if (login) {
if (login && (!longPress)) {
do {
// 如果有对话框(删除,备忘录详情等)
ret = $(".ngdialog").length == 0;