检测到手机跳转到移动端

This commit is contained in:
luchenqun 2018-04-22 21:33:05 +08:00
parent 4675ced8e6
commit a3e10759b0
9 changed files with 62 additions and 3 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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];

View File

@ -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;

View File

@ -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应该程序没有头部与底部
};
}
};