From 24b824b23b409dc1b5d29b0296e96c4bcae74769 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Wed, 13 Aug 2025 20:25:52 +0800 Subject: [PATCH] :sparkles: Support setting proxy URL --- README.md | 4 ---- bin/README.md | 5 +++-- bin/README_CN.md | 5 +++-- bin/cli.ts | 2 +- bin/options/index.ts | 2 ++ src-tauri/src/app/window.rs | 8 ++++++-- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 85db8ea..2767c5e 100644 --- a/README.md +++ b/README.md @@ -172,10 +172,6 @@ pake url [OPTIONS]... # Feel free to play with Pake! It might take a while to prepare the environment the first time you launch Pake. pake https://weekly.tw93.fun --name Weekly --hide-title-bar - -# Also supports names with spaces (cross-platform compatible) -pake https://translate.google.com --name "Google Translate" --hide-title-bar - ``` If you are new to the command line, you can compile packages online with _GitHub Actions_. See the [Tutorial]() for more information. diff --git a/bin/README.md b/bin/README.md index e69c5aa..e737e35 100644 --- a/bin/README.md +++ b/bin/README.md @@ -259,10 +259,11 @@ Supports both comma-separated and multiple option formats: #### [proxy-url] -If you need to proxy requests for some reason, you can set the proxy address using the `proxy-url` option. +Set proxy server for all network requests. Supports HTTP, HTTPS, and SOCKS5. ```shell ---proxy-url +--proxy-url http://127.0.0.1:7890 +--proxy-url socks5://127.0.0.1:7891 ``` #### [debug] diff --git a/bin/README_CN.md b/bin/README_CN.md index 80a502e..8386002 100644 --- a/bin/README_CN.md +++ b/bin/README_CN.md @@ -261,10 +261,11 @@ pake [url] [options] #### [proxy-url] -假如你由于某些缘故需要代理请求,你可以通过 `proxy-url` 选项来设置代理地址。 +为所有网络请求设置代理服务器。支持 HTTP、HTTPS 和 SOCKS5。 ```shell ---proxy-url +--proxy-url http://127.0.0.1:7890 +--proxy-url socks5://127.0.0.1:7891 ``` #### [debug] diff --git a/bin/cli.ts b/bin/cli.ts index 3b8d86c..555f208 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -68,7 +68,7 @@ program ) .option('--debug', 'Debug build and more output', DEFAULT.debug) .addOption( - new Option('--proxy-url ', 'Proxy URL for all network requests') + new Option('--proxy-url ', 'Proxy URL for all network requests (http://, https://, socks5://)') .default(DEFAULT_PAKE_OPTIONS.proxyUrl) .hideHelp(), ) diff --git a/bin/options/index.ts b/bin/options/index.ts index 564ac0c..1beb863 100644 --- a/bin/options/index.ts +++ b/bin/options/index.ts @@ -20,6 +20,7 @@ function isValidName(name: string, platform: NodeJS.Platform): boolean { return !!name && reg.test(name); } + export default async function handleOptions( options: PakeCliOptions, url: string, @@ -56,6 +57,7 @@ export default async function handleOptions( } } + const appOptions: PakeAppOptions = { ...options, name, diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs index 9e24a68..5302e1b 100644 --- a/src-tauri/src/app/window.rs +++ b/src-tauri/src/app/window.rs @@ -46,9 +46,13 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) -> .initialization_script(include_str!("../inject/style.js")) .initialization_script(include_str!("../inject/custom.js")); + // Configure proxy if specified if !config.proxy_url.is_empty() { - window_builder = - window_builder.proxy_url(Url::from_str(config.proxy_url.as_str()).unwrap()); + if let Ok(proxy_url) = Url::from_str(&config.proxy_url) { + window_builder = window_builder.proxy_url(proxy_url); + #[cfg(debug_assertions)] + println!("Proxy configured: {}", config.proxy_url); + } } #[cfg(target_os = "macos")]