✨ Support setting proxy URL
This commit is contained in:
@@ -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.
|
# 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
|
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.
|
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
5
bin/README.md
vendored
@@ -259,10 +259,11 @@ Supports both comma-separated and multiple option formats:
|
|||||||
|
|
||||||
#### [proxy-url]
|
#### [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
|
```shell
|
||||||
--proxy-url <url>
|
--proxy-url http://127.0.0.1:7890
|
||||||
|
--proxy-url socks5://127.0.0.1:7891
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [debug]
|
#### [debug]
|
||||||
|
|||||||
5
bin/README_CN.md
vendored
5
bin/README_CN.md
vendored
@@ -261,10 +261,11 @@ pake [url] [options]
|
|||||||
|
|
||||||
#### [proxy-url]
|
#### [proxy-url]
|
||||||
|
|
||||||
假如你由于某些缘故需要代理请求,你可以通过 `proxy-url` 选项来设置代理地址。
|
为所有网络请求设置代理服务器。支持 HTTP、HTTPS 和 SOCKS5。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--proxy-url <url>
|
--proxy-url http://127.0.0.1:7890
|
||||||
|
--proxy-url socks5://127.0.0.1:7891
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [debug]
|
#### [debug]
|
||||||
|
|||||||
2
bin/cli.ts
vendored
2
bin/cli.ts
vendored
@@ -68,7 +68,7 @@ program
|
|||||||
)
|
)
|
||||||
.option('--debug', 'Debug build and more output', DEFAULT.debug)
|
.option('--debug', 'Debug build and more output', DEFAULT.debug)
|
||||||
.addOption(
|
.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)
|
.default(DEFAULT_PAKE_OPTIONS.proxyUrl)
|
||||||
.hideHelp(),
|
.hideHelp(),
|
||||||
)
|
)
|
||||||
|
|||||||
2
bin/options/index.ts
vendored
2
bin/options/index.ts
vendored
@@ -20,6 +20,7 @@ function isValidName(name: string, platform: NodeJS.Platform): boolean {
|
|||||||
return !!name && reg.test(name);
|
return !!name && reg.test(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default async function handleOptions(
|
export default async function handleOptions(
|
||||||
options: PakeCliOptions,
|
options: PakeCliOptions,
|
||||||
url: string,
|
url: string,
|
||||||
@@ -56,6 +57,7 @@ export default async function handleOptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const appOptions: PakeAppOptions = {
|
const appOptions: PakeAppOptions = {
|
||||||
...options,
|
...options,
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -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/style.js"))
|
||||||
.initialization_script(include_str!("../inject/custom.js"));
|
.initialization_script(include_str!("../inject/custom.js"));
|
||||||
|
|
||||||
|
// Configure proxy if specified
|
||||||
if !config.proxy_url.is_empty() {
|
if !config.proxy_url.is_empty() {
|
||||||
window_builder =
|
if let Ok(proxy_url) = Url::from_str(&config.proxy_url) {
|
||||||
window_builder.proxy_url(Url::from_str(config.proxy_url.as_str()).unwrap());
|
window_builder = window_builder.proxy_url(proxy_url);
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
println!("Proxy configured: {}", config.proxy_url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
Reference in New Issue
Block a user