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
47155a4a
There was an error fetching the commit references. Please try again later.
Unverified
Commit
47155a4a
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: change system porxy when changed port
parent
d0b87fd7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src-tauri/src/cmds.rs
+3
-1
3 additions, 1 deletion
src-tauri/src/cmds.rs
src-tauri/src/core/clash.rs
+17
-3
17 additions, 3 deletions
src-tauri/src/core/clash.rs
src-tauri/src/core/verge.rs
+18
-0
18 additions, 0 deletions
src-tauri/src/core/verge.rs
with
38 additions
and
4 deletions
src-tauri/src/cmds.rs
+
3
−
1
View file @
47155a4a
...
...
@@ -202,11 +202,13 @@ pub fn get_clash_info(clash_state: State<'_, ClashState>) -> Result<ClashInfo, S
pub
fn
patch_clash_config
(
payload
:
Mapping
,
clash_state
:
State
<
'_
,
ClashState
>
,
verge_state
:
State
<
'_
,
VergeState
>
,
profiles_state
:
State
<
'_
,
ProfilesState
>
,
)
->
Result
<
(),
String
>
{
let
mut
clash
=
clash_state
.0
.lock
()
.unwrap
();
let
mut
verge
=
verge_state
.0
.lock
()
.unwrap
();
let
mut
profiles
=
profiles_state
.0
.lock
()
.unwrap
();
clash
.patch_config
(
payload
,
&
mut
profiles
)
clash
.patch_config
(
payload
,
&
mut
verge
,
&
mut
profiles
)
}
/// get the system proxy
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/core/clash.rs
+
17
−
3
View file @
47155a4a
use
super
::
ProfilesConfig
;
use
super
::
{
ProfilesConfig
,
Verge
}
;
use
crate
::
utils
::{
config
,
dirs
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde_yaml
::{
Mapping
,
Value
};
...
...
@@ -170,6 +170,7 @@ impl Clash {
pub
fn
patch_config
(
&
mut
self
,
patch
:
Mapping
,
verge
:
&
mut
Verge
,
profiles
:
&
mut
ProfilesConfig
,
)
->
Result
<
(),
String
>
{
for
(
key
,
value
)
in
patch
.iter
()
{
...
...
@@ -179,12 +180,25 @@ impl Clash {
// restart the clash
if
key_str
==
"mixed-port"
{
self
.restart_sidecar
(
profiles
)
?
;
let
port
=
if
value
.is_number
()
{
match
value
.as_i64
()
.clone
()
{
Some
(
num
)
=>
Some
(
format!
(
"{num}"
)),
None
=>
None
,
}
}
else
{
match
value
.as_str
()
.clone
()
{
Some
(
num
)
=>
Some
(
num
.into
()),
None
=>
None
,
}
};
verge
.init_sysproxy
(
port
);
}
if
self
.config
.contains_key
(
key
)
{
self
.config
[
key
]
=
value
.clone
()
;
self
.config
[
key
]
=
value
;
}
else
{
self
.config
.insert
(
key
.clone
(),
value
.clone
()
);
self
.config
.insert
(
key
.clone
(),
value
);
}
}
self
.save_config
()
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/core/verge.rs
+
18
−
0
View file @
47155a4a
...
...
@@ -161,6 +161,24 @@ impl Verge {
}
}
// fn guard_thread(&mut self) -> Result<(), String> {
// let sysproxy = self.cur_sysproxy.clone();
// use std::{thread, time};
// tauri::async_runtime::spawn(async move {
// if let Some(sysproxy) = sysproxy {
// sysproxy.set_sys();
// }
// let ten_millis = time::Duration::from_millis(10);
// let now = time::Instant::now();
// thread::sleep(ten_millis);
// });
// Ok(())
// }
/// patch verge config
/// There should be only one update at a time here
/// so call the save_file at the end is savely
...
...
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