当前位置: 首页 > 工具软件 > httpproxy > 使用案例 >

Electron http proxy

翟默
2023-12-01
function setProxy (mode, proxyServer) {
  mode = mode || store.get('enableProxy');
  switch (mode) {
    case 'custom': {
      const { host, port, protocol } = store.get('proxy');
      log('Custom proxy %s:%s.', host, port);
      proxyServer = protocol + host + ':' + port;

      log(proxyServer);
      mainWindow.webContents.session.setProxy({
        proxyRules: proxyServer
      });
      break;
    }
    case 'system': {
      log('Auto detect proxy');
      mainWindow.webContents.session.setProxy({ mode: 'system' });
      break;
    }
    case 'disable':
    default:
      log('Disable proxy');
      mainWindow.webContents.session.setProxy({ mode: 'direct' });
      break;
  }
}
 类似资料:

相关阅读

相关文章

相关问答