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
8fa7fb3b
There was an error fetching the commit references. Please try again later.
Unverified
Commit
8fa7fb3b
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: refresh ui when hotkey clicked
parent
509d8336
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/core/hotkey.rs
+8
-12
8 additions, 12 deletions
src-tauri/src/core/hotkey.rs
src-tauri/src/core/mod.rs
+6
-0
6 additions, 0 deletions
src-tauri/src/core/mod.rs
src-tauri/src/feat.rs
+18
-0
18 additions, 0 deletions
src-tauri/src/feat.rs
with
32 additions
and
12 deletions
src-tauri/src/core/hotkey.rs
+
8
−
12
View file @
8fa7fb3b
...
@@ -4,12 +4,14 @@ use std::collections::HashMap;
...
@@ -4,12 +4,14 @@ use std::collections::HashMap;
use
tauri_hotkey
::{
parse_hotkey
,
HotkeyManager
};
use
tauri_hotkey
::{
parse_hotkey
,
HotkeyManager
};
pub
struct
Hotkey
{
pub
struct
Hotkey
{
current
:
Vec
<
String
>
,
// 保存当前的热键设置
manager
:
HotkeyManager
,
manager
:
HotkeyManager
,
}
}
impl
Hotkey
{
impl
Hotkey
{
pub
fn
new
()
->
Hotkey
{
pub
fn
new
()
->
Hotkey
{
Hotkey
{
Hotkey
{
current
:
Vec
::
new
(),
manager
:
HotkeyManager
::
new
(),
manager
:
HotkeyManager
::
new
(),
}
}
}
}
...
@@ -30,6 +32,7 @@ impl Hotkey {
...
@@ -30,6 +32,7 @@ impl Hotkey {
log
::
error!
(
target
:
"app"
,
"invalid hotkey
\"
{}
\"
:
\"
{}
\"
"
,
func
.unwrap_or
(
"None"
),
key
.unwrap_or
(
"None"
));
log
::
error!
(
target
:
"app"
,
"invalid hotkey
\"
{}
\"
:
\"
{}
\"
"
,
func
.unwrap_or
(
"None"
),
key
.unwrap_or
(
"None"
));
}
}
}
}
self
.current
=
hotkeys
.clone
();
}
}
Ok
(())
Ok
(())
...
@@ -58,23 +61,20 @@ impl Hotkey {
...
@@ -58,23 +61,20 @@ impl Hotkey {
};
};
self
.manager
.register
(
hotkey
,
f
)
?
;
self
.manager
.register
(
hotkey
,
f
)
?
;
log
::
info!
(
target
:
"app"
,
"register hotkey {func} {key}"
);
Ok
(())
Ok
(())
}
}
fn
unregister
(
&
mut
self
,
key
:
&
str
)
->
Result
<
()
>
{
fn
unregister
(
&
mut
self
,
key
:
&
str
)
->
Result
<
()
>
{
let
hotkey
=
parse_hotkey
(
key
.trim
())
?
;
let
hotkey
=
parse_hotkey
(
key
.trim
())
?
;
self
.manager
.unregister
(
&
hotkey
)
?
;
self
.manager
.unregister
(
&
hotkey
)
?
;
log
::
info!
(
target
:
"app"
,
"unregister hotkey {key}"
);
Ok
(())
Ok
(())
}
}
pub
fn
update
(
&
mut
self
,
new_hotkeys
:
Vec
<
String
>
)
->
Result
<
()
>
{
pub
fn
update
(
&
mut
self
,
new_hotkeys
:
Vec
<
String
>
)
->
Result
<
()
>
{
let
data
=
Data
::
global
();
let
current
=
self
.current
.to_owned
();
let
mut
verge
=
data
.verge
.lock
();
let
old_map
=
Self
::
get_map_from_vec
(
&
current
);
let
default
=
Vec
::
new
();
let
old_hotkeys
=
verge
.hotkeys
.as_ref
()
.unwrap_or
(
&
default
);
let
old_map
=
Self
::
get_map_from_vec
(
old_hotkeys
);
let
new_map
=
Self
::
get_map_from_vec
(
&
new_hotkeys
);
let
new_map
=
Self
::
get_map_from_vec
(
&
new_hotkeys
);
for
diff
in
Self
::
get_diff
(
old_map
,
new_map
)
.iter
()
{
for
diff
in
Self
::
get_diff
(
old_map
,
new_map
)
.iter
()
{
...
@@ -92,11 +92,7 @@ impl Hotkey {
...
@@ -92,11 +92,7 @@ impl Hotkey {
}
}
}
}
verge
.patch_config
(
Verge
{
self
.current
=
new_hotkeys
;
hotkeys
:
Some
(
new_hotkeys
),
..
Verge
::
default
()
})
?
;
Ok
(())
Ok
(())
}
}
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/core/mod.rs
+
6
−
0
View file @
8fa7fb3b
...
@@ -202,6 +202,11 @@ impl Core {
...
@@ -202,6 +202,11 @@ impl Core {
handle
.update_systray
()
?
;
handle
.update_systray
()
?
;
}
}
if
patch
.hotkeys
.is_some
()
{
let
mut
hotkey
=
self
.hotkey
.lock
();
hotkey
.update
(
patch
.hotkeys
.unwrap
())
?
;
}
Ok
(())
Ok
(())
}
}
...
@@ -225,6 +230,7 @@ impl Core {
...
@@ -225,6 +230,7 @@ impl Core {
// update tray
// update tray
let
handle
=
self
.handle
.lock
();
let
handle
=
self
.handle
.lock
();
handle
.refresh_clash
();
handle
.update_systray_clash
()
?
;
handle
.update_systray_clash
()
?
;
Ok
(())
Ok
(())
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/feat.rs
+
18
−
0
View file @
8fa7fb3b
...
@@ -21,6 +21,9 @@ pub fn toggle_system_proxy() {
...
@@ -21,6 +21,9 @@ pub fn toggle_system_proxy() {
enable_system_proxy
:
Some
(
enable
),
enable_system_proxy
:
Some
(
enable
),
..
Verge
::
default
()
..
Verge
::
default
()
}));
}));
let
handle
=
core
.handle
.lock
();
let
_
=
handle
.refresh_verge
();
}
}
// 打开系统代理
// 打开系统代理
...
@@ -30,6 +33,9 @@ pub fn enable_system_proxy() {
...
@@ -30,6 +33,9 @@ pub fn enable_system_proxy() {
enable_system_proxy
:
Some
(
true
),
enable_system_proxy
:
Some
(
true
),
..
Verge
::
default
()
..
Verge
::
default
()
}));
}));
let
handle
=
core
.handle
.lock
();
let
_
=
handle
.refresh_verge
();
}
}
// 关闭系统代理
// 关闭系统代理
...
@@ -39,6 +45,9 @@ pub fn disable_system_proxy() {
...
@@ -39,6 +45,9 @@ pub fn disable_system_proxy() {
enable_system_proxy
:
Some
(
false
),
enable_system_proxy
:
Some
(
false
),
..
Verge
::
default
()
..
Verge
::
default
()
}));
}));
let
handle
=
core
.handle
.lock
();
let
_
=
handle
.refresh_verge
();
}
}
// 切换tun模式
// 切换tun模式
...
@@ -54,6 +63,9 @@ pub fn toggle_tun_mode() {
...
@@ -54,6 +63,9 @@ pub fn toggle_tun_mode() {
enable_tun_mode
:
Some
(
enable
),
enable_tun_mode
:
Some
(
enable
),
..
Verge
::
default
()
..
Verge
::
default
()
}));
}));
let
handle
=
core
.handle
.lock
();
let
_
=
handle
.refresh_verge
();
}
}
// 打开tun模式
// 打开tun模式
...
@@ -63,6 +75,9 @@ pub fn enable_tun_mode() {
...
@@ -63,6 +75,9 @@ pub fn enable_tun_mode() {
enable_tun_mode
:
Some
(
true
),
enable_tun_mode
:
Some
(
true
),
..
Verge
::
default
()
..
Verge
::
default
()
}));
}));
let
handle
=
core
.handle
.lock
();
let
_
=
handle
.refresh_verge
();
}
}
// 关闭tun模式
// 关闭tun模式
...
@@ -72,4 +87,7 @@ pub fn disable_tun_mode() {
...
@@ -72,4 +87,7 @@ pub fn disable_tun_mode() {
enable_tun_mode
:
Some
(
false
),
enable_tun_mode
:
Some
(
false
),
..
Verge
::
default
()
..
Verge
::
default
()
}));
}));
let
handle
=
core
.handle
.lock
();
let
_
=
handle
.refresh_verge
();
}
}
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