-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
41 lines (33 loc) · 1.24 KB
/
main.js
File metadata and controls
41 lines (33 loc) · 1.24 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
const { app, BrowserWindow } = require('electron');
const path = require('path');
const { session } = require("electron");
const { sockProxyRules } = require('./proxy/socksProxy/socksProxy');
// const { httpProxyRules } = require('./proxy/httpProxy/httpProxy');
let mainWindow;
async function createWindow() {
const ses = session.defaultSession;
const proxyRules = await sockProxyRules("[socks4/5]://[userId]:[password]@[host]:[port]");
// const proxyRules = await httpProxyRules("[http/https]://[userId]:[password]@[host]:[port]");
ses.setProxy({ proxyRules: proxyRules.url });
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false, // 禁用 Node.js 在渲染进程
contextIsolation: true, // 安全隔离
webviewTag: true,
},
});
mainWindow.loadFile(path.join(__dirname, 'main.html'));
mainWindow.on('closed', () => {
mainWindow = null;
});
}
app.commandLine.appendSwitch('ignore-certificate-errors');
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', () => {
if (mainWindow === null) createWindow();
});