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
2d2fdf0b
There was an error fetching the commit references. Please try again later.
Unverified
Commit
2d2fdf0b
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
fix: handle is none
parent
cf966222
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/handle.rs
+2
-2
2 additions, 2 deletions
src-tauri/src/core/handle.rs
src-tauri/src/core/mod.rs
+23
-10
23 additions, 10 deletions
src-tauri/src/core/mod.rs
src-tauri/src/utils/resolve.rs
+1
-1
1 addition, 1 deletion
src-tauri/src/utils/resolve.rs
with
26 additions
and
13 deletions
src-tauri/src/core/handle.rs
+
2
−
2
View file @
2d2fdf0b
...
...
@@ -10,8 +10,8 @@ pub struct Handle {
}
impl
Handle
{
pub
fn
from
(
app_handle
:
Option
<
AppHandle
>
)
->
Handle
{
Handle
{
app_handle
}
pub
fn
set_inner
(
&
mut
self
,
app_handle
:
AppHandle
)
{
self
.app_handle
=
Some
(
app_handle
);
}
pub
fn
get_window
(
&
self
)
->
Option
<
Window
>
{
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/core/mod.rs
+
23
−
10
View file @
2d2fdf0b
...
...
@@ -22,7 +22,7 @@ static CORE: Lazy<Core> = Lazy::new(|| Core {
sysopt
:
Arc
::
new
(
Mutex
::
new
(
Sysopt
::
new
())),
timer
:
Arc
::
new
(
Mutex
::
new
(
Timer
::
new
())),
runtime
:
Arc
::
new
(
Mutex
::
new
(
RuntimeResult
::
default
())),
handle
:
Handle
::
default
(),
handle
:
Arc
::
new
(
Mutex
::
new
(
Handle
::
default
()
))
,
});
#[derive(Clone)]
...
...
@@ -31,7 +31,7 @@ pub struct Core {
pub
sysopt
:
Arc
<
Mutex
<
Sysopt
>>
,
pub
timer
:
Arc
<
Mutex
<
Timer
>>
,
pub
runtime
:
Arc
<
Mutex
<
RuntimeResult
>>
,
pub
handle
:
Handle
,
pub
handle
:
Arc
<
Mutex
<
Handle
>>
,
}
impl
Core
{
...
...
@@ -40,10 +40,14 @@ impl Core {
}
/// initialize the core state
pub
fn
init
(
&
mut
self
,
app_handle
:
tauri
::
AppHandle
)
{
pub
fn
init
(
&
self
,
app_handle
:
tauri
::
AppHandle
)
{
// kill old clash process
Service
::
kill_old_clash
();
self
.handle
=
Handle
::
from
(
Some
(
app_handle
));
{
let
mut
handle
=
self
.handle
.lock
();
handle
.set_inner
(
app_handle
);
}
{
let
mut
service
=
self
.service
.lock
();
...
...
@@ -58,8 +62,11 @@ impl Core {
log_if_err!
(
sysopt
.init_sysproxy
());
}
log_if_err!
(
self
.handle
.update_systray
());
log_if_err!
(
self
.handle
.update_systray_clash
());
{
let
handle
=
self
.handle
.lock
();
log_if_err!
(
handle
.update_systray
());
log_if_err!
(
handle
.update_systray_clash
());
}
// timer initialize
let
mut
timer
=
self
.timer
.lock
();
...
...
@@ -124,7 +131,8 @@ impl Core {
}
if
has_mode
{
self
.handle
.update_systray_clash
()
?
;
let
handle
=
self
.handle
.lock
();
handle
.update_systray_clash
()
?
;
}
Ok
(())
...
...
@@ -186,7 +194,8 @@ impl Core {
}
if
system_proxy
.is_some
()
||
tun_mode
.is_some
()
{
self
.handle
.update_systray
()
?
;
let
handle
=
self
.handle
.lock
();
handle
.update_systray
()
?
;
}
Ok
(())
...
...
@@ -211,7 +220,8 @@ impl Core {
});
// update tray
self
.handle
.update_systray_clash
()
?
;
let
handle
=
self
.handle
.lock
();
handle
.update_systray_clash
()
?
;
Ok
(())
}
...
...
@@ -260,7 +270,10 @@ impl Core {
let
handle
=
self
.handle
.clone
();
tauri
::
async_runtime
::
spawn
(
async
move
{
match
Service
::
set_config
(
clash_info
,
config
)
.await
{
Ok
(
_
)
=>
handle
.refresh_clash
(),
Ok
(
_
)
=>
{
let
handle
=
handle
.lock
();
handle
.refresh_clash
()
}
Err
(
err
)
=>
log
::
error!
(
target
:
"app"
,
"{err}"
),
}
});
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/utils/resolve.rs
+
1
−
1
View file @
2d2fdf0b
...
...
@@ -16,7 +16,7 @@ pub fn resolve_setup(app: &App) {
}
// core should be initialized after init_app fix #122
let
mut
core
=
Core
::
global
();
let
core
=
Core
::
global
();
core
.init
(
app
.app_handle
());
resolve_window
(
app
);
...
...
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