代码拉取完成,页面将自动刷新
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();
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。