1 Star 0 Fork 0

陈东宇/electron-session-proxy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.js 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
陈东宇 提交于 2025-04-09 13:36 +08:00 . 增加http代理使用说明
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();
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chen-dongyu123/electron-session-proxy.git
git@gitee.com:chen-dongyu123/electron-session-proxy.git
chen-dongyu123
electron-session-proxy
electron-session-proxy
master

搜索帮助