Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
02ba04b5
There was an error fetching the commit references. Please try again later.
Unverified
Commit
02ba04b5
authored
1 year ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: support copy environment variable
parent
4f158a48
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src-tauri/src/core/tray.rs
+75
-60
75 additions, 60 deletions
src-tauri/src/core/tray.rs
src-tauri/src/feat.rs
+10
-0
10 additions, 0 deletions
src-tauri/src/feat.rs
with
85 additions
and
60 deletions
src-tauri/src/core/tray.rs
+
75
−
60
View file @
02ba04b5
...
@@ -13,67 +13,81 @@ impl Tray {
...
@@ -13,67 +13,81 @@ impl Tray {
let
version
=
app_handle
.package_info
()
.version
.to_string
();
let
version
=
app_handle
.package_info
()
.version
.to_string
();
if
zh
{
macro_rules!
t
{
SystemTrayMenu
::
new
()
(
$en
:
expr
,
$zh
:
expr
)
=>
{
.add_item
(
CustomMenuItem
::
new
(
"open_window"
,
"打开面板"
))
if
zh
{
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
$zh
.add_item
(
CustomMenuItem
::
new
(
"rule_mode"
,
"规则模式"
))
}
else
{
.add_item
(
CustomMenuItem
::
new
(
"global_mode"
,
"全局模式"
))
$en
.add_item
(
CustomMenuItem
::
new
(
"direct_mode"
,
"直连模式"
))
}
.add_item
(
CustomMenuItem
::
new
(
"script_mode"
,
"脚本模式"
))
};
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"system_proxy"
,
"系统代理"
))
.add_item
(
CustomMenuItem
::
new
(
"tun_mode"
,
"TUN 模式"
))
.add_submenu
(
SystemTraySubmenu
::
new
(
"打开目录"
,
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"open_app_dir"
,
"应用目录"
))
.add_item
(
CustomMenuItem
::
new
(
"open_core_dir"
,
"内核目录"
))
.add_item
(
CustomMenuItem
::
new
(
"open_logs_dir"
,
"日志目录"
)),
))
.add_submenu
(
SystemTraySubmenu
::
new
(
"更多"
,
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"restart_clash"
,
"重启 Clash"
))
.add_item
(
CustomMenuItem
::
new
(
"restart_app"
,
"重启应用"
))
.add_item
(
CustomMenuItem
::
new
(
"app_version"
,
format!
(
"Version {version}"
))
.disabled
(),
),
))
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"quit"
,
"退出"
)
.accelerator
(
"CmdOrControl+Q"
))
}
else
{
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"open_window"
,
"Dashboard"
))
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"rule_mode"
,
"Rule Mode"
))
.add_item
(
CustomMenuItem
::
new
(
"global_mode"
,
"Global Mode"
))
.add_item
(
CustomMenuItem
::
new
(
"direct_mode"
,
"Direct Mode"
))
.add_item
(
CustomMenuItem
::
new
(
"script_mode"
,
"Script Mode"
))
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"system_proxy"
,
"System Proxy"
))
.add_item
(
CustomMenuItem
::
new
(
"tun_mode"
,
"Tun Mode"
))
.add_submenu
(
SystemTraySubmenu
::
new
(
"Open Dir"
,
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"open_app_dir"
,
"App Dir"
))
.add_item
(
CustomMenuItem
::
new
(
"open_core_dir"
,
"Core Dir"
))
.add_item
(
CustomMenuItem
::
new
(
"open_logs_dir"
,
"Logs Dir"
)),
))
.add_submenu
(
SystemTraySubmenu
::
new
(
"More"
,
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"restart_clash"
,
"Restart Clash"
))
.add_item
(
CustomMenuItem
::
new
(
"restart_app"
,
"Restart App"
))
.add_item
(
CustomMenuItem
::
new
(
"app_version"
,
format!
(
"Version {version}"
))
.disabled
(),
),
))
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"quit"
,
"Quit"
)
.accelerator
(
"CmdOrControl+Q"
))
}
}
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"open_window"
,
t!
(
"Dashboard"
,
"打开面板"
),
))
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"rule_mode"
,
t!
(
"Rule Mode"
,
"规则模式"
),
))
.add_item
(
CustomMenuItem
::
new
(
"global_mode"
,
t!
(
"Global Mode"
,
"全局模式"
),
))
.add_item
(
CustomMenuItem
::
new
(
"direct_mode"
,
t!
(
"Direct Mode"
,
"直连模式"
),
))
.add_item
(
CustomMenuItem
::
new
(
"script_mode"
,
t!
(
"Script Mode"
,
"脚本模式"
),
))
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"system_proxy"
,
t!
(
"System Proxy"
,
"系统代理"
),
))
.add_item
(
CustomMenuItem
::
new
(
"tun_mode"
,
t!
(
"TUN Mode"
,
"Tun 模式"
)))
.add_item
(
CustomMenuItem
::
new
(
"copy_env"
,
t!
(
"Copy Env"
,
"复制环境变量"
),
))
.add_submenu
(
SystemTraySubmenu
::
new
(
t!
(
"Open Dir"
,
"打开目录"
),
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"open_app_dir"
,
t!
(
"App Dir"
,
"应用目录"
),
))
.add_item
(
CustomMenuItem
::
new
(
"open_core_dir"
,
t!
(
"Core Dir"
,
"内核目录"
),
))
.add_item
(
CustomMenuItem
::
new
(
"open_logs_dir"
,
t!
(
"Logs Dir"
,
"日志目录"
),
)),
))
.add_submenu
(
SystemTraySubmenu
::
new
(
t!
(
"More"
,
"更多"
),
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"restart_clash"
,
t!
(
"Restart Clash"
,
"重启 Clash"
),
))
.add_item
(
CustomMenuItem
::
new
(
"restart_app"
,
t!
(
"Restart App"
,
"重启应用"
),
))
.add_item
(
CustomMenuItem
::
new
(
"app_version"
,
format!
(
"Version {version}"
))
.disabled
(),
),
))
.add_native_item
(
SystemTrayMenuItem
::
Separator
)
.add_item
(
CustomMenuItem
::
new
(
"quit"
,
t!
(
"Quit"
,
"退出"
))
.accelerator
(
"CmdOrControl+Q"
))
}
}
pub
fn
update_systray
(
app_handle
:
&
AppHandle
)
->
Result
<
()
>
{
pub
fn
update_systray
(
app_handle
:
&
AppHandle
)
->
Result
<
()
>
{
...
@@ -135,6 +149,7 @@ impl Tray {
...
@@ -135,6 +149,7 @@ impl Tray {
"open_window"
=>
resolve
::
create_window
(
app_handle
),
"open_window"
=>
resolve
::
create_window
(
app_handle
),
"system_proxy"
=>
feat
::
toggle_system_proxy
(),
"system_proxy"
=>
feat
::
toggle_system_proxy
(),
"tun_mode"
=>
feat
::
toggle_tun_mode
(),
"tun_mode"
=>
feat
::
toggle_tun_mode
(),
"copy_env"
=>
feat
::
copy_clash_env
(),
"open_app_dir"
=>
crate
::
log_err!
(
cmds
::
open_app_dir
()),
"open_app_dir"
=>
crate
::
log_err!
(
cmds
::
open_app_dir
()),
"open_core_dir"
=>
crate
::
log_err!
(
cmds
::
open_core_dir
()),
"open_core_dir"
=>
crate
::
log_err!
(
cmds
::
open_core_dir
()),
"open_logs_dir"
=>
crate
::
log_err!
(
cmds
::
open_logs_dir
()),
"open_logs_dir"
=>
crate
::
log_err!
(
cmds
::
open_logs_dir
()),
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/feat.rs
+
10
−
0
View file @
02ba04b5
...
@@ -9,6 +9,7 @@ use crate::core::*;
...
@@ -9,6 +9,7 @@ use crate::core::*;
use
crate
::
log_err
;
use
crate
::
log_err
;
use
anyhow
::{
bail
,
Result
};
use
anyhow
::{
bail
,
Result
};
use
serde_yaml
::{
Mapping
,
Value
};
use
serde_yaml
::{
Mapping
,
Value
};
use
wry
::
application
::
clipboard
::
Clipboard
;
// 重启clash
// 重启clash
pub
fn
restart_clash_core
()
{
pub
fn
restart_clash_core
()
{
...
@@ -319,3 +320,12 @@ async fn update_core_config() -> Result<()> {
...
@@ -319,3 +320,12 @@ async fn update_core_config() -> Result<()> {
}
}
}
}
}
}
/// copy env variable
pub
fn
copy_clash_env
()
{
let
port
=
{
Config
::
clash
()
.data
()
.get_client_info
()
.port
};
let
text
=
format!
(
"export https_proxy=http://127.0.0.1:{port} http_proxy=http://127.0.0.1:{port} all_proxy=socks5://127.0.0.1:{port}"
);
let
mut
cliboard
=
Clipboard
::
new
();
cliboard
.write_text
(
text
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment