-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
171 lines (151 loc) · 3.83 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**
* https://gauriatiq.medium.com/electron-app-database-with-dexie-js-indexeddb-and-web-worker-570d9a66a47a
*
*
*/
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const Menu = electron.Menu;
const shell = electron.shell;
var mainWindow = null;
app.commandLine.appendSwitch('lang', 'pt-BR');
/********/
/********/
function createWindow() {
/*
* https://coursetro.com/posts/code/119/Working-with-Electron-Menus---Tutorial
*/
var menu = Menu.buildFromTemplate([
{
label: 'Menu',
submenu: [
{
label: 'Informação',
click() {
//mainWindow.webContents.executeJavaScript('alert(document.getElementById("campo").value)')
mainWindow.webContents.executeJavaScript('alert("Controle de monitoração diário")');
//mainWindow.webContents.executeJavaScript('vapp.appF7.methods.dialogInforma("Controle de monitoração diário")');
}
},
{type: 'separator'}, // Add this
{
label: 'Sair',
click() {
app.quit();
}
}
]
},
{
label: 'Zoom',
submenu: [
{
label: '+',
click() {
if (contents) {
zoomF += 0.1;
contents.setZoomFactor(zoomF);
} else {
mainWindow.webContents.executeJavaScript('console.log("não tem contents")');
}
},
accelerator: 'CmdOrCtrl+Up'
},
{
label: '-',
click() {
if (contents) {
zoomF -= 0.1;
contents.setZoomFactor(zoomF);
} else {
mainWindow.webContents.executeJavaScript('console.log("não tem contents")');
}
},
accelerator: 'CmdOrCtrl+Down'
}
]
},
/*{
label: 'Procurar',
click() {
//mainWindow.webContents.executeJavaScript('window.find()');
mainWindow.webContents.findInPage();
},
accelerator: 'CmdOrCtrl+F'
},*/
{
label: 'Dados',
submenu: [
{
label: 'Exportar dados',
click() {
mainWindow.webContents.executeJavaScript('exportar();');
}
},
{
label: 'Importar dados',
click() {
mainWindow.webContents.executeJavaScript('importar();');
}
}
]
},
{
label: 'Site do desenvolvedor',
click() {
shell.openExternal('http://romulodouro.com');
},
accelerator: 'CmdOrCtrl+Shift+S'
}
]);
Menu.setApplicationMenu(menu);
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
//preload: path.join(__dirname, 'sources/preload.js')
contextIsolation: false, //padrão para node 12 + isso é para poder usar o nodeIntegration
nodeIntegration: true, //enables node.js in renderer processes
nodeIntegrationInWorker: true //enables node.js in web workers
},
icon: __dirname + '/sources/resources/img/appIcon.png',
//titleBarStyle: 'hidden',
show: false // don't show the main window
});
mainWindow.loadFile(__dirname + '/sources/index.html');
//mainWindow.loadURL('file://' + __dirname + '/sources/index.html');
//mainWindow.openDevTools();
//mainWindow.removeMenu();
mainWindow.on('closed', function () {
//mainWindow = null;
});
mainWindow.maximize();
const contents = mainWindow.webContents;
var zoomF = contents.getZoomFactor();
var splash = new BrowserWindow({width: 500, height: 300, transparent: false, frame: false, alwaysOnTop: true});
splash.loadURL(`file://${__dirname}/sources/splash.html`);
//splash.loadFile(__dirname + '/sources/splash.html');
splash.removeMenu();
mainWindow.once('ready-to-show', () => {
setTimeout(function () {
//splash.close();
splash.destroy();
mainWindow.show();
}, 2000);
});
}
app.whenReady().then(() => {
createWindow();
/*app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});*/
});
app.on('window-all-closed', function () {
if (process.platform != 'darwin') {
app.quit();
}
});