refactor: support proxy option
This commit is contained in:
1
bin/cli.ts
vendored
1
bin/cli.ts
vendored
@@ -33,6 +33,7 @@ program
|
||||
.option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT.multiArch)
|
||||
.option('--inject [injects...]', 'Injection of .js or .css Files', DEFAULT.inject)
|
||||
.option('--debug', 'Debug build and more output', DEFAULT.debug)
|
||||
.option('--proxy-url', "Proxy URL", DEFAULT.proxyUrl)
|
||||
.addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT.userAgent).hideHelp())
|
||||
.addOption(
|
||||
new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp(),
|
||||
|
||||
1
bin/defaults.ts
vendored
1
bin/defaults.ts
vendored
@@ -16,6 +16,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
||||
targets: 'deb',
|
||||
useLocalFile: false,
|
||||
systemTrayIcon: '',
|
||||
proxyUrl: "",
|
||||
debug: false,
|
||||
inject: [],
|
||||
safeDomain: [],
|
||||
|
||||
3
bin/helpers/merge.ts
vendored
3
bin/helpers/merge.ts
vendored
@@ -24,6 +24,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
||||
name,
|
||||
resizable = true,
|
||||
inject,
|
||||
proxyUrl,
|
||||
} = options;
|
||||
|
||||
const { platform } = process;
|
||||
@@ -189,6 +190,8 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
||||
await fsExtra.writeFile(injectFilePath, '');
|
||||
}
|
||||
|
||||
tauriConf.pake.proxy_url = proxyUrl || "";
|
||||
|
||||
// Save config file.
|
||||
const platformConfigPaths: PlatformMap = {
|
||||
win32: 'tauri.windows.conf.json',
|
||||
|
||||
3
bin/types.ts
vendored
3
bin/types.ts
vendored
@@ -59,6 +59,9 @@ export interface PakeCliOptions {
|
||||
|
||||
/* the domain that can use ipc or tauri javascript sdk */
|
||||
safeDomain: string[];
|
||||
|
||||
// Proxy
|
||||
proxyUrl: string;
|
||||
}
|
||||
|
||||
export interface PakeAppOptions extends PakeCliOptions {
|
||||
|
||||
@@ -21,7 +21,7 @@ tauri-build = { version = "2.0.0-beta", features = [] }
|
||||
[dependencies]
|
||||
serde_json = "1.0.116"
|
||||
serde = { version = "1.0.200", features = ["derive"] }
|
||||
tauri = { version = "2.0.0-beta.25", features = ["tray-icon", "image-ico", "image-png"] }
|
||||
tauri = { version = "2.0.0-beta.25", features = ["tray-icon", "image-ico", "image-png", "macos-proxy"] }
|
||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "v2" }
|
||||
tauri-plugin-clipboard-manager = "2.1.0-beta.6"
|
||||
|
||||
@@ -52,6 +52,7 @@ pub struct PakeConfig {
|
||||
pub user_agent: UserAgent,
|
||||
pub system_tray: FunctionON,
|
||||
pub system_tray_path: String,
|
||||
pub proxy_url: String
|
||||
}
|
||||
|
||||
impl PakeConfig {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::app::config::PakeConfig;
|
||||
use std::path::PathBuf;
|
||||
use tauri::{App, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
use tauri::{App, Url, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::TitleBarStyle;
|
||||
@@ -40,6 +40,11 @@ pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> Web
|
||||
//This is necessary to allow for file injection by external developers for customization purposes.
|
||||
.initialization_script(include_str!("../inject/custom.js"));
|
||||
|
||||
if config.proxy_url != "" {
|
||||
println!("{}", &config.proxy_url);
|
||||
window_builder = window_builder.proxy_url(Url::from_str(&config.proxy_url.as_str()).unwrap());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let title_bar_style = if window_config.hide_title_bar {
|
||||
|
||||
Reference in New Issue
Block a user