-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
87 lines (71 loc) · 2.56 KB
/
main.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
85
86
87
const { app, BrowserWindow, autoUpdater } = require('electron');
const path = require('path')
const url = require('url')
const isDev = require('electron-is-dev'); // this is required to check if the app is running in development mode
global.application_root = 'dada';
global.doc_root = '';
const check_first_run = require('./electron-src/file-operations');
console.log('01')
let win
function createWindow() {
win = new BrowserWindow({
width: 1000,
height: 700,
minWidth: 1000,
minHeight: 700,
backgroundColor: '#ffffff',
show: false,
center: true,
autoHideMenuBar: true,
icon: path.join(__dirname, 'build/icon.png')
})
// mainWindow = new BrowserWindow({width: 800, height: 600, icon: path.join(__dirname, 'resources/img/typewriter.png') }) // window data
// background-color: rgb(207, 172, 126);
win.once('ready-to-show', () => {
win.show();
})
// load the dist folder from Angular
win.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true
}))
// Open the DevTools optionally:
// win.webContents.openDevTools()
win.on('closed', () => {
win = null
})
// Build the menu
require('./electron-src/main-menu');
const userDataPath = app.getPath('userData');
const userDocPath = app.getPath('documents');
console.log('000 userDataPath is', userDataPath);
// We'll use the `configName` property to set the file name and path.join to bring it all together as a string
global.application_root = path.join(userDataPath, '/') + 'data/';
console.log('global.application_root is ' + global.application_root);
global.doc_root = path.join(userDocPath, '/');
// Now that application_root is set, check if it is first run or not
check_first_run(global.application_root);
// about to call auto-update function
const page = win.webContents;
// This function is called when page is loaded
page.once('did-frame-finish-load', () => {
console.log('Main Page loaded');
// add more options here
});
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
// Funtion to check the current OS. As of now there is no proper method to add auto-updates to linux platform.
function isWindowsOrmacOS() {
return process.platform === 'darwin' || process.platform === 'win32';
}