mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
move the function of switching desktop/mobile page to frontend
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import uaParser from 'ua-parser-js';
|
||||
|
||||
function isMobileDevice() {
|
||||
if (!navigator.userAgent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uaParseRet = uaParser(navigator.userAgent);
|
||||
|
||||
if (!uaParseRet || !uaParseRet.device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const device = uaParseRet.device;
|
||||
|
||||
if (device.type === 'mobile' || device.type === 'tablet' || device.type === 'wearable' || device.type === 'embedded') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function navigate(type) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
window.location.replace(`${type}/`);
|
||||
} else {
|
||||
window.location.replace(`${type}.html`);
|
||||
}
|
||||
}
|
||||
|
||||
if (isMobileDevice()) {
|
||||
navigate('mobile');
|
||||
} else {
|
||||
navigate('desktop');
|
||||
}
|
||||
Reference in New Issue
Block a user