mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 03:43:44 +08:00
feat: fish env export support
This commit is contained in:
parent
181fce16b1
commit
c957ea7b24
@ -57,13 +57,6 @@ pub fn copy_clash_env() {
|
|||||||
let http_proxy = format!("http://{clash_verge_rev_ip}:{}", port);
|
let http_proxy = format!("http://{clash_verge_rev_ip}:{}", port);
|
||||||
let socks5_proxy = format!("socks5://{clash_verge_rev_ip}:{}", port);
|
let socks5_proxy = format!("socks5://{clash_verge_rev_ip}:{}", port);
|
||||||
|
|
||||||
let sh =
|
|
||||||
format!("export https_proxy={http_proxy} http_proxy={http_proxy} all_proxy={socks5_proxy}");
|
|
||||||
let cmd: String = format!("set http_proxy={http_proxy}\r\nset https_proxy={http_proxy}");
|
|
||||||
let ps: String = format!("$env:HTTP_PROXY=\"{http_proxy}\"; $env:HTTPS_PROXY=\"{http_proxy}\"");
|
|
||||||
let nu: String =
|
|
||||||
format!("load-env {{ http_proxy: \"{http_proxy}\", https_proxy: \"{http_proxy}\" }}");
|
|
||||||
|
|
||||||
let cliboard = app_handle.clipboard();
|
let cliboard = app_handle.clipboard();
|
||||||
let env_type = { Config::verge().latest().env_type.clone() };
|
let env_type = { Config::verge().latest().env_type.clone() };
|
||||||
let env_type = match env_type {
|
let env_type = match env_type {
|
||||||
@ -77,11 +70,20 @@ pub fn copy_clash_env() {
|
|||||||
default.to_string()
|
default.to_string()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match env_type.as_str() {
|
|
||||||
"bash" => cliboard.write_text(sh).unwrap_or_default(),
|
let export_text = match env_type.as_str() {
|
||||||
"cmd" => cliboard.write_text(cmd).unwrap_or_default(),
|
"bash" => format!("export https_proxy={http_proxy} http_proxy={http_proxy} all_proxy={socks5_proxy}"),
|
||||||
"powershell" => cliboard.write_text(ps).unwrap_or_default(),
|
"cmd" => format!("set http_proxy={http_proxy}\r\nset https_proxy={http_proxy}"),
|
||||||
"nushell" => cliboard.write_text(nu).unwrap_or_default(),
|
"powershell" => format!("$env:HTTP_PROXY=\"{http_proxy}\"; $env:HTTPS_PROXY=\"{http_proxy}\""),
|
||||||
_ => log::error!(target: "app", "copy_clash_env: Invalid env type! {env_type}"),
|
"nushell" => format!("load-env {{ http_proxy: \"{http_proxy}\", https_proxy: \"{http_proxy}\" }}"),
|
||||||
|
"fish" => format!("set -x http_proxy {http_proxy}; set -x https_proxy {http_proxy}"),
|
||||||
|
_ => {
|
||||||
|
log::error!(target: "app", "copy_clash_env: Invalid env type! {env_type}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Err(_) = cliboard.write_text(export_text) {
|
||||||
|
log::error!(target: "app", "Failed to write to clipboard");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,8 +142,9 @@ const SettingVergeBasic = ({ onError }: Props) => {
|
|||||||
>
|
>
|
||||||
<Select size="small" sx={{ width: 140, "> div": { py: "7.5px" } }}>
|
<Select size="small" sx={{ width: 140, "> div": { py: "7.5px" } }}>
|
||||||
<MenuItem value="bash">Bash</MenuItem>
|
<MenuItem value="bash">Bash</MenuItem>
|
||||||
<MenuItem value="cmd">CMD</MenuItem>
|
<MenuItem value="fish">Fish</MenuItem>
|
||||||
<MenuItem value="nushell">Nushell</MenuItem>
|
<MenuItem value="nushell">Nushell</MenuItem>
|
||||||
|
<MenuItem value="cmd">CMD</MenuItem>
|
||||||
<MenuItem value="powershell">PowerShell</MenuItem>
|
<MenuItem value="powershell">PowerShell</MenuItem>
|
||||||
</Select>
|
</Select>
|
||||||
</GuardState>
|
</GuardState>
|
||||||
|
2
src/services/types.d.ts
vendored
2
src/services/types.d.ts
vendored
@ -694,7 +694,7 @@ interface IVergeConfig {
|
|||||||
app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string;
|
app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string;
|
||||||
language?: string;
|
language?: string;
|
||||||
tray_event?: "main_window" | "system_proxy" | "tun_mode" | string;
|
tray_event?: "main_window" | "system_proxy" | "tun_mode" | string;
|
||||||
env_type?: "bash" | "cmd" | "powershell" | string;
|
env_type?: "bash" | "cmd" | "powershell" | "fish" | string;
|
||||||
startup_script?: string;
|
startup_script?: string;
|
||||||
start_page?: string;
|
start_page?: string;
|
||||||
clash_core?: string;
|
clash_core?: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user