Support setting proxy URL

This commit is contained in:
Tw93
2025-08-13 20:25:52 +08:00
parent c2bc1c2028
commit 24b824b23b
6 changed files with 15 additions and 11 deletions

View File

@@ -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](<https://github.com/tw93/Pake/wiki/Online-Compilation-(used-by-ordinary-users)>) for more information.

5
bin/README.md vendored
View File

@@ -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 <url>
--proxy-url http://127.0.0.1:7890
--proxy-url socks5://127.0.0.1:7891
```
#### [debug]

5
bin/README_CN.md vendored
View File

@@ -261,10 +261,11 @@ pake [url] [options]
#### [proxy-url]
假如你由于某些缘故需要代理请求,你可以通过 `proxy-url` 选项来设置代理地址
为所有网络请求设置代理服务器。支持 HTTP、HTTPS 和 SOCKS5
```shell
--proxy-url <url>
--proxy-url http://127.0.0.1:7890
--proxy-url socks5://127.0.0.1:7891
```
#### [debug]

2
bin/cli.ts vendored
View File

@@ -68,7 +68,7 @@ program
)
.option('--debug', 'Debug build and more output', DEFAULT.debug)
.addOption(
new Option('--proxy-url <url>', 'Proxy URL for all network requests')
new Option('--proxy-url <url>', 'Proxy URL for all network requests (http://, https://, socks5://)')
.default(DEFAULT_PAKE_OPTIONS.proxyUrl)
.hideHelp(),
)

View File

@@ -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,

View File

@@ -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")]