-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
71 lines (59 loc) · 2.06 KB
/
index.js
File metadata and controls
71 lines (59 loc) · 2.06 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
const path = require('path');
const fs = require('fs');
const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron');
const cachePath = path.join(__dirname, '/config/cache.json');
const { spawn } = require('child_process');
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
title: 'AbletonPatcherGUI',
width: 400,
height: 500,
minWidth: 400,
minHeight: 500,
transparent: true,
frame: false,
resizable: true,
vibrancy: 'fullscreen-ui', // on MacOS
backgroundMaterial: 'acrylic', // on Windows 11
webPreferences: {
preload: path.join(__dirname, './util/preload.js'),
nodeIntegration: false,
contextIsolation: true
},
titleBarStyle: 'hidden',
});
mainWindow.loadFile(path.join(__dirname, './renderer/index.html'));
//mainWindow.webContents.openDevTools();
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
ipcMain.handle('get-system-theme', () => {
return nativeTheme.shouldUseDarkColors;
});
});
let outputLogs = [];
ipcMain.on('form-veri-gonder', (event, formData) => {
if (formData.exit === true) {
app.quit();
return;
} else {
outputLogs = [];
fs.writeFileSync(cachePath, JSON.stringify(formData, null, 2), 'utf8')
const scriptPath = path.join(__dirname, 'util/patcher.js');
const child = spawn('node', [scriptPath]);
child.stdout.on('data', (data) => {
console.log(`${data}`);
outputLogs.push(data.toString());
event.sender.send('form-isleme-tamamlandi', { success: true, message: outputLogs.join('\n') });
});
child.stderr.on('data', (data) => {
console.log(`${data}`);
outputLogs.push(data.toString());
event.sender.send('form-isleme-tamamlandi', { success: false, message: outputLogs.join('\n') });
});
}
})