diff --git a/public/scripts/controllers/bookmarks-controller.js b/public/scripts/controllers/bookmarks-controller.js index 9942c20..558ddda 100644 --- a/public/scripts/controllers/bookmarks-controller.js +++ b/public/scripts/controllers/bookmarks-controller.js @@ -1,5 +1,11 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) { console.log("Hello bookmarksCtr...", $stateParams); + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + $window.location = "http://m.mybookmark.cn/#/tags"; + return; + } + $scope.bookmarks = []; // 书签数据 $scope.showSearch = false; // 搜索对话框 $scope.bookmarkNormalHover = false; diff --git a/public/scripts/controllers/home-controller.js b/public/scripts/controllers/home-controller.js index b9fae95..801efeb 100644 --- a/public/scripts/controllers/home-controller.js +++ b/public/scripts/controllers/home-controller.js @@ -1,6 +1,12 @@ app.controller('homeCtr', ['$scope', '$stateParams', '$filter', '$state', '$window', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $stateParams, $filter, $state, $window, bookmarkService, pubSubService, dataService) { console.log('Hello homeCtr......'); - + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + toastr.success(JSON.stringify(browser), "提示"); + $window.location = "http://m.mybookmark.cn"; + return; + } + toastr.success(12345678, "提示"); bookmarkService.autoLogin() .then((data) => { if (data.logined) { diff --git a/public/scripts/controllers/hot-controller.js b/public/scripts/controllers/hot-controller.js index 6cf8755..2665f69 100644 --- a/public/scripts/controllers/hot-controller.js +++ b/public/scripts/controllers/hot-controller.js @@ -1,6 +1,10 @@ app.controller('hotCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) { console.log("Hello hotCtr..."); - + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + $window.location = "http://m.mybookmark.cn/#/tags"; + return; + } $scope.hoverBookmark = null; $scope.bookmarks = []; // 书签数据 $scope.bookmarkNormalHover = false; diff --git a/public/scripts/controllers/login-controller.js b/public/scripts/controllers/login-controller.js index cbfe347..18a231d 100644 --- a/public/scripts/controllers/login-controller.js +++ b/public/scripts/controllers/login-controller.js @@ -1,5 +1,10 @@ -app.controller('loginCtr', ['$scope', '$filter', '$state', '$cookieStore', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $filter, $state, $cookieStore, bookmarkService, pubSubService, dataService) { +app.controller('loginCtr', ['$scope', '$filter', '$state', '$cookieStore', '$window', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $filter, $state, $cookieStore, $window, bookmarkService, pubSubService, dataService) { console.log("Hello loginCtr...", $cookieStore.get("username")); + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + $window.location = "http://m.mybookmark.cn/#/login"; + return; + } pubSubService.publish('Common.menuActive', { login: false, diff --git a/public/scripts/controllers/note-controller.js b/public/scripts/controllers/note-controller.js index 210069e..b1cca1f 100644 --- a/public/scripts/controllers/note-controller.js +++ b/public/scripts/controllers/note-controller.js @@ -1,5 +1,10 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) { console.log("Hello noteCtr...", $stateParams); + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + $window.location = "http://m.mybookmark.cn/#/note"; + return; + } const perPageItems = 35; var dialog = null; diff --git a/public/scripts/controllers/search-controller.js b/public/scripts/controllers/search-controller.js index 0c115e8..0bb477c 100644 --- a/public/scripts/controllers/search-controller.js +++ b/public/scripts/controllers/search-controller.js @@ -1,5 +1,11 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) { console.log("Hello searchCtr...", $stateParams); + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + $window.location = "http://m.mybookmark.cn/#/search"; + return; + } + const perPageItems = 20; var dialog = null; $scope.hoverBookmark = null; diff --git a/public/scripts/controllers/settings-controller.js b/public/scripts/controllers/settings-controller.js index f15dc62..1304f65 100644 --- a/public/scripts/controllers/settings-controller.js +++ b/public/scripts/controllers/settings-controller.js @@ -1,5 +1,10 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$window', '$timeout', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $stateParams, $filter, $state, $window, $timeout, bookmarkService, pubSubService, dataService) { console.log('Hello settingsCtr......', $stateParams); + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + $window.location = "http://m.mybookmark.cn/#/settings"; + return; + } $scope.forbidQuickKey = dataService.forbidQuickKey $scope.form = [false, false, false, false, false, false]; diff --git a/public/scripts/controllers/tags-controller.js b/public/scripts/controllers/tags-controller.js index 0c8990b..61145b0 100644 --- a/public/scripts/controllers/tags-controller.js +++ b/public/scripts/controllers/tags-controller.js @@ -1,5 +1,11 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $filter, $window, $stateParams, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) { console.log("Hello tagsCtr...", $stateParams); + var browser = dataService.browser(); + if(browser.mobile && !browser.iPad){ + $window.location = "http://m.mybookmark.cn/#/tags"; + return; + } + getTags({}); var perPageItems = 20; diff --git a/public/scripts/services/data-service.js b/public/scripts/services/data-service.js index bb11045..7b0ebaa 100644 --- a/public/scripts/services/data-service.js +++ b/public/scripts/services/data-service.js @@ -129,6 +129,22 @@ app.factory('dataService', [function() { clipboard: function(text) { $("#clipboard").attr("data-clipboard-text", text); document.getElementById("clipboard").click(); + }, + browser: function() { + var u = navigator.userAgent, + app = navigator.appVersion; + return { //移动终端浏览器版本信息 + trident: u.indexOf('Trident') > -1, //IE内核 + presto: u.indexOf('Presto') > -1, //opera内核 + webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核 + mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 + android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器 + iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器 + iPad: u.indexOf('iPad') > -1, //是否iPad + webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部 + }; } };