-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
77 lines (62 loc) · 1.78 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
const { app, BrowserWindow } = require('electron');
const path = require('path');
const { title } = require('process');
function createWindow() {
const win = new BrowserWindow({
width: 1920,
height: 1640,
movable: true,
// frame: false,
icon: path.join(__dirname, 'assets/icon.png'),
zoomToPageWidth: true,
title: 'LLM Parameter Playground',
minWidth: 1660,
minHeight: 1080,
roundedCorners: true,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
nodeIntegrationInWorker: true,
contextIsolation: true,
webSecurity: true
}
});
const startUrl = `file://${path.join(app.getAppPath(), 'out/index.html')}`;
win.loadURL(startUrl);
// Enable devtools
// win.webContents.openDevTools();
win.once('ready-to-show', () => {
win.show()
})
}
const { session } = require('electron')
app.whenReady().then(() => {
// allow all cors
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders['Origin'] = '*';
callback({ requestHeaders: details.requestHeaders });
});
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
if (details.responseHeaders) {
details.responseHeaders['Access-Control-Allow-Origin'] = ['*'];
}
callback({ responseHeaders: details.responseHeaders });
});
createWindow();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
// improve performance of first launch by caching the app
app.commandLine.appendSwitch('js-flags', '--no-lazy');
//hot reload
try {
require('electron-reloader')(module)
} catch (_) { }