Skip to content

#4839:为桌面端新增网络代理模式设置,#6785

Draft
ljluestc wants to merge 2 commits into
ChatGPTNextWeb:mainfrom
ljluestc:private/fix-issue-4839-proxy-setting
Draft

#4839:为桌面端新增网络代理模式设置,#6785
ljluestc wants to merge 2 commits into
ChatGPTNextWeb:mainfrom
ljluestc:private/fix-issue-4839-proxy-setting

Conversation

@ljluestc
Copy link
Copy Markdown

close #4839

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

本 PR 实现了 #4839:为桌面端新增网络代理模式设置,支持用户在 systemhttpsocks5 三种模式间切换,解决仅依赖系统代理时无法灵活选择 HTTP/SOCKS5 的问题。

背景与目标

  • 在桌面环境(尤其 Windows)下,用户经常需要明确指定代理协议类型。
  • 原有链路缺少完整的“前端设置 → Tauri 调用 → Rust 请求客户端”代理模式透传能力。

主要改动

  1. 设置页新增代理模式配置

    • 新增 Network Proxy Mode 选择项:system / http / socks5
    • 在非 system 模式下,展示并保存 Proxy HostProxy Port 输入项。
    • 默认值:127.0.0.1:7890
  2. 前端状态扩展

    • 在访问配置中新增:
      • proxyMode
      • proxyHost
      • proxyPort
    • 新增 PROXY_MODESProxyMode 类型定义,保证模式值可控。
  3. 桌面流式请求链路接入代理 URL

    • app/utils/stream.ts 中根据模式与 host/port 生成 proxy_url
    • system 模式不传代理;http/socks5 模式构造对应协议 URL。
    • 调用 Tauri stream_fetch 时新增 proxy_url 参数透传。
  4. Rust 后端支持代理模式

    • src-tauri/src/stream.rsstream_fetch 增加 proxy_url: Option<String>
    • proxy_url 有效时,通过 reqwest::Proxy::all(...) 注入代理。
    • 通过 no_proxy().proxy(...) 显式应用用户配置代理。
  5. 依赖能力补齐

    • src-tauri/Cargo.toml 中为 reqwest 启用 socks feature,确保 SOCKS5 可用。

涉及文件

  • app/components/settings.tsx
  • app/store/access.ts
  • app/utils/stream.ts
  • src-tauri/src/stream.rs
  • src-tauri/Cargo.toml

最终效果

  • system:使用系统默认代理行为(不强制覆盖)。
  • http:桌面请求走 http://<host>:<port>
  • socks5:桌面请求走 socks5://<host>:<port>

📝 补充信息 | Additional Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add a network setting of proxy, which let user to choose the HTTP or SOCKS5

1 participant