const ua = window.navigator.userAgent;
const system = {
IOS: /(iPhone|iPad|iPod|iOS)/gi.test(ua),
Android: /android|adr/gi.test(ua)
};
if(system.IOS) {
let self = this
let time = null;
(function fn(ctx) {
const handler =setTimeout(() => {
const now = new Date();
!time && (time = now);
const cost = now - time;
time = now;
if (cost > 3000) {
ctx.$toast('我回来了!');
ctx.socket.init();
ctx.$store.dispatch('setUserInfo')
};
fn(ctx)
}, 1000)
})(this);
} else {
function getHiddenProp() {
var prefixes = ['webkit', 'moz', 'ms', 'o'];
// if 'hidden' is natively supported just return it
if('hidden' in document) return 'hidden';
// otherwise loop over all the known prefixes until we find one
for(var i = 0; i < prefixes.length; i++) {
if((prefixes[i] + 'Hidden') in document)
return prefixes[i] + 'Hidden';
}
// otherwise it's not supported
return null;
}
function isHidden() {
var prop = getHiddenProp();
if(!prop) return false;
const ua = window.navigator.userAgent; const system = { IOS: /(iPhone|iPad|iPod|iOS)/gi.test(ua), Android: /android|adr/gi.test(ua) }; if(system.IOS) { let self = this let time = null; (function fn(ctx) { const handler =setTimeout(() => { const now = new Date(); !time && (time = now); const cost = now - time; time = now; if (cost > 3000) { ctx.$toast('我回来了!'); ctx.socket.init(); ctx.$store.dispatch('setUserInfo') }; fn(ctx) }, 1000) })(this); } else { function getHiddenProp() { var prefixes = ['webkit', 'moz', 'ms', 'o']; // if 'hidden' is natively supported just return it if('hidden' in document) return 'hidden'; // otherwise loop over all the known prefixes until we find one for(var i = 0; i < prefixes.length; i++) { if((prefixes[i] + 'Hidden') in document) return prefixes[i] + 'Hidden'; } // otherwise it's not supported return null; } function isHidden() { var prop = getHiddenProp(); if(!prop) return false;