-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
84 lines (68 loc) · 1.7 KB
/
index.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
'use strict'
const electron = require('electron')
const windowState = require('electron-window-state')
const BrowserWindow = electron.BrowserWindow
const app = electron.app
const path = require('path')
const shortcuts = electron.globalShortcut
const fs = require('fs')
const name = 'EyeAreSee'
const index = `file://${path.join(__dirname, 'views', 'index.html')}`
app.on('ready', setup)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
var mainWindow
function setup() {
setupHome()
shortcuts.unregister('ctrl+r')
const mainWindowState = windowState({
defaultWidth: 1200
, defaultHeight: 800
})
mainWindow = new BrowserWindow({
x: mainWindowState.x
, y: mainWindowState.y
, width: mainWindowState.width
, height: mainWindowState.height
, 'min-height': 400
, 'min-width': 600
, resizable: true
, titleBarStyle: 'hidden'
, center: true
, title: name
})
mainWindowState.manage(mainWindow)
const App = require('./lib/app')
App.create({
resourcePath: process.env.EYEARESEE_RESOURCE_PATH
, version: require('./package').version
, window: mainWindow
})
mainWindow.loadURL(index)
mainWindow.on('closed', () => {
mainWindow = null
})
if (process.env.DEV_MODE) {
mainWindow.once('show', () => {
console.log('opening dev tools')
mainWindow.openDevTools({
detach: true
})
})
}
}
function setupHome() {
const e = process.env.EYEARESEE_HOME
if (e) return
let home = path.join(app.getPath('home'), '.eyearesee')
try {
home = fs.realPathSync(home)
} catch (_) {
// ignore :/
}
process.env.EYEARESEE_HOME = home
process.env.EYEARESEE_RESOURCE_PATH = __dirname
}