forked from vuejs/devtools-v6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.ts
More file actions
36 lines (33 loc) · 1.24 KB
/
env.ts
File metadata and controls
36 lines (33 loc) · 1.24 KB
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
export const isBrowser = typeof navigator !== 'undefined'
export const target: any = isBrowser
? window
: typeof global !== 'undefined'
? global
: {}
export const isChrome = typeof target.chrome !== 'undefined' && !!target.chrome.devtools
export const isFirefox = isBrowser && navigator.userAgent.indexOf('Firefox') > -1
export const isWindows = isBrowser && navigator.platform.indexOf('Win') === 0
export const isMac = isBrowser && navigator.platform === 'MacIntel'
export const isLinux = isBrowser && navigator.platform.indexOf('Linux') === 0
export const keys = {
ctrl: isMac ? '⌘' : 'Ctrl',
shift: 'Shift',
alt: isMac ? '⌥' : 'Alt',
del: 'Del',
enter: 'Enter',
esc: 'Esc',
}
export function initEnv (Vue) {
if (Vue.prototype.hasOwnProperty('$isChrome')) return
Object.defineProperties(Vue.prototype, {
$isChrome: { get: () => isChrome },
$isFirefox: { get: () => isFirefox },
$isWindows: { get: () => isWindows },
$isMac: { get: () => isMac },
$isLinux: { get: () => isLinux },
$keys: { get: () => keys },
})
if (isWindows) document.body.classList.add('platform-windows')
if (isMac) document.body.classList.add('platform-mac')
if (isLinux) document.body.classList.add('platform-linux')
}