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
2f5b8d9a
There was an error fetching the commit references. Please try again later.
Commit
2f5b8d9a
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of github.com:zzzgydi/clash-verge
parents
db324f54
3242efb1
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/mod.rs
+1
-1
1 addition, 1 deletion
src-tauri/src/core/mod.rs
src-tauri/src/core/profiles.rs
+3
-3
3 additions, 3 deletions
src-tauri/src/core/profiles.rs
src-tauri/src/core/timer.rs
+29
-0
29 additions, 0 deletions
src-tauri/src/core/timer.rs
with
33 additions
and
4 deletions
src-tauri/src/core/mod.rs
+
1
−
1
View file @
2f5b8d9a
...
@@ -91,7 +91,7 @@ impl Core {
...
@@ -91,7 +91,7 @@ impl Core {
// timer initialize
// timer initialize
let
mut
timer
=
self
.timer
.lock
();
let
mut
timer
=
self
.timer
.lock
();
timer
.set_core
(
self
.clone
());
timer
.set_core
(
self
.clone
());
log_if_err!
(
timer
.re
fresh
());
log_if_err!
(
timer
.re
store
());
}
}
/// save the window instance
/// save the window instance
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/core/profiles.rs
+
3
−
3
View file @
2f5b8d9a
...
@@ -121,7 +121,7 @@ impl Profiles {
...
@@ -121,7 +121,7 @@ impl Profiles {
}
}
}
}
bail!
(
"failed to get the
item by
\"
{}
\"
"
,
uid
);
bail!
(
"failed to get the
profile item
\"
uid:{uid}
\"
"
);
}
}
/// append new item
/// append new item
...
@@ -178,7 +178,7 @@ impl Profiles {
...
@@ -178,7 +178,7 @@ impl Profiles {
}
}
self
.items
=
Some
(
items
);
self
.items
=
Some
(
items
);
bail!
(
"failed to f
ou
nd the
uid
\"
{uid}
\"
"
)
bail!
(
"failed to f
i
nd the
profile item
\"
uid:
{uid}
\"
"
)
}
}
/// be used to update the remote item
/// be used to update the remote item
...
@@ -286,7 +286,7 @@ impl Profiles {
...
@@ -286,7 +286,7 @@ impl Profiles {
return
Ok
(
config
::
read_yaml
::
<
Mapping
>
(
file_path
.clone
()));
return
Ok
(
config
::
read_yaml
::
<
Mapping
>
(
file_path
.clone
()));
}
}
}
}
bail!
(
"failed to f
ou
nd
the uid
\"
{current}
\"
"
);
bail!
(
"failed to f
i
nd
current profile
\"
uid:
{current}
\"
"
);
}
}
/// generate the data for activate clash config
/// generate the data for activate clash config
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/core/timer.rs
+
29
−
0
View file @
2f5b8d9a
use
super
::
Core
;
use
super
::
Core
;
use
crate
::
log_if_err
;
use
crate
::
log_if_err
;
use
crate
::
utils
::
help
::
get_now
;
use
anyhow
::{
bail
,
Context
,
Result
};
use
anyhow
::{
bail
,
Context
,
Result
};
use
delay_timer
::
prelude
::{
DelayTimer
,
DelayTimerBuilder
,
TaskBuilder
};
use
delay_timer
::
prelude
::{
DelayTimer
,
DelayTimerBuilder
,
TaskBuilder
};
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
HashMap
;
...
@@ -63,6 +64,34 @@ impl Timer {
...
@@ -63,6 +64,34 @@ impl Timer {
Ok
(())
Ok
(())
}
}
/// restore timer
pub
fn
restore
(
&
mut
self
)
->
Result
<
()
>
{
self
.refresh
()
?
;
let
cur_timestamp
=
get_now
();
// seconds
let
profiles
=
self
.core
.as_ref
()
.unwrap
()
.profiles
.lock
();
profiles
.get_items
()
.unwrap_or
(
&
vec!
[])
.iter
()
.filter
(|
item
|
item
.uid
.is_some
()
&&
item
.updated
.is_some
()
&&
item
.option
.is_some
())
.filter
(|
item
|
{
// mins to seconds
let
interval
=
item
.option
.as_ref
()
.unwrap
()
.update_interval
.unwrap_or
(
0
)
as
usize
*
60
;
let
updated
=
item
.updated
.unwrap
();
return
interval
>
0
&&
cur_timestamp
-
updated
>=
interval
;
})
.for_each
(|
item
|
{
let
uid
=
item
.uid
.as_ref
()
.unwrap
();
if
let
Some
((
task_id
,
_
))
=
self
.timer_map
.get
(
uid
)
{
log_if_err!
(
self
.delay_timer
.advance_task
(
*
task_id
));
}
});
Ok
(())
}
/// generate a uid -> update_interval map
/// generate a uid -> update_interval map
fn
gen_map
(
&
self
)
->
HashMap
<
String
,
u64
>
{
fn
gen_map
(
&
self
)
->
HashMap
<
String
,
u64
>
{
let
profiles
=
self
.core
.as_ref
()
.unwrap
()
.profiles
.lock
();
let
profiles
=
self
.core
.as_ref
()
.unwrap
()
.profiles
.lock
();
...
...
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