-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
103 lines (87 loc) · 2.36 KB
/
index.js
File metadata and controls
103 lines (87 loc) · 2.36 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
const electron = require('electron');
const app = electron.app;
const ipc = require('electron').ipcMain
//check if tmp is there, if so delete
var rimraf = require('rimraf');
rimraf(app.getPath('userData')+'/tmp', function () {
console.log('>> cleanup done');
});
// prevent window being garbage collected
let mainWindow;
var count = 0;
function onClosed() {
count = 0;
// dereference the window
mainWindow = null;
}
function createMainWindow() {
const win = new electron.BrowserWindow({
width: 400,
height: 400,
title: "ProFile",
resizable: false,
fullscreenable: false,
backgroundColor: '#f0f0f0',
icon: __dirname + '/assets/icons/win/icon.ico'
});
win.setTitle(require('./package.json').name);
win.loadURL(`file://${__dirname}/app/index.html`);
win.on('closed', onClosed);
return win;
}
app.on('window-all-closed', () => {
// if (process.platform !== 'darwin') {app.quit();}
var rimraf = require('rimraf');
rimraf(app.getPath('userData')+'/tmp', function () {
console.log('>> cleanup done');
app.quit();
});
});
app.on('activate', () => {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});
app.on('ready', () => {
mainWindow = createMainWindow();
});
//delete the temporary folder from ipc message
ipc.on('clear-tmp', function (event, arg) {
var rimraf = require('rimraf');
rimraf(app.getPath('userData')+'/tmp', function () {
console.log('>> cleanup done');
});
})
//receive the package from the render process and create modal
ipc.on('open-modal', function (event, arg) {
createModalWindow(arg);
})
//create new modals for each system profile
function createModalWindow(arg) {
var winMod = count*20
var path = require('path')
var modalPath = path.join('file://', __dirname, 'app/modal.html')
var modal = new electron.BrowserWindow({
width: 400,
height: 721,
'minWidth': 370,
'minHeight': 642,
'maxWidth': 700,
fullscreenable: false,
icon: __dirname + '/assets/icons/win/icon.ico'
});
modal.on('close', function () {
modal = null;
count = 0;
})
modal.loadURL(modalPath)
modal.setPosition(100+winMod, 50+winMod)
modal.show()
//pass argument values to the new modal
modal.webContents.on('did-finish-load', () => {
modal.webContents.send('profileObject', arg)
})
count++;
}
//require('electron-debug')({showDevTools: true});