-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstants.js
84 lines (71 loc) · 2.41 KB
/
Constants.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import UAParser from 'ua-parser-js';
const parsedUserAgent = new UAParser().getResult();
let IS_DEV = process.env.NODE_ENV === 'development';
const IS_WIN = parsedUserAgent.os.name === 'Windows';
const IS_MAC = parsedUserAgent.os.name === 'Macintosh' || parsedUserAgent.os.name === 'Mac OS';
// const IS_LINUX = parsedUserAgent.os.name === 'X11';
const IS_LINUX = !(IS_WIN || IS_MAC);
const IS_IOS = typeof navigator !== 'undefined' &&
(/iPad|iPhone|iPod/.test(navigator.userAgent || '') ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1));
const IS_MOBILE = typeof navigator !== 'undefined' && (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
let IS_ELECTRON = false;
// global variables
window.IS_DEV = IS_DEV;
window.IS_WIN = IS_WIN;
window.IS_MAC = IS_MAC;
window.IS_LINUX = IS_LINUX;
IS_ELECTRON = parsedUserAgent.ua.indexOf('Electron') !== -1;
window.IS_ELECTRON = IS_ELECTRON;
window.IS_IOS = IS_IOS;
window.IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
window.IS_MOBILE = IS_MOBILE;
if (IS_ELECTRON) {
let heykaStore;
try {
heykaStore = require('../renderer/store/localStore').heykaStore;
} catch (e) {
console.error(e);
}
const forceDevServer = heykaStore.getSync('devServer', false);
if (forceDevServer) {
IS_DEV = true;
window.IS_DEV = IS_DEV;
}
}
// Base urls
let API_URL;
let WEB_URL;
let COOKIE_URL;
if (IS_ELECTRON) {
API_URL = IS_DEV ? process.env.VUE_APP_API_DEV_URL : process.env.VUE_APP_API_PROD_URL;
WEB_URL = IS_DEV ? process.env.VUE_APP_WEB_DEV_URL : process.env.VUE_APP_WEB_PROD_URL;
} else if (typeof window !== 'undefined') {
if (window.location.hostname === 'heyka.app') {
API_URL = 'https://api.heyka.app';
WEB_URL = 'https://heyka.app';
} else if (window.location.hostname === 'localhost') {
API_URL = IS_DEV ? process.env.VUE_APP_API_DEV_URL : process.env.VUE_APP_API_PROD_URL;
WEB_URL = IS_DEV ? process.env.VUE_APP_WEB_DEV_URL : process.env.VUE_APP_WEB_PROD_URL;
} else {
// It's supposed, that the domain name is (back/web)-(dev/stage).dev.k8s.heyka.io
WEB_URL = window.location.origin;
API_URL = window.location.origin.replace('web', 'back');
}
}
if (API_URL) {
COOKIE_URL = '.' + API_URL.split('.').splice(-2)
.join('.');
}
export {
IS_DEV,
IS_WIN,
IS_MAC,
IS_LINUX,
IS_ELECTRON,
IS_IOS,
IS_MOBILE,
API_URL,
WEB_URL,
COOKIE_URL
};