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
cf00c947
There was an error fetching the commit references. Please try again later.
Unverified
Commit
cf00c947
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
fix: user agent not works
parent
b2a24c7a
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
+11
-3
11 additions, 3 deletions
src-tauri/src/cmds.rs
src-tauri/src/core/profiles.rs
+26
-3
26 additions, 3 deletions
src-tauri/src/core/profiles.rs
src-tauri/src/utils/help.rs
+1
-1
1 addition, 1 deletion
src-tauri/src/utils/help.rs
with
38 additions
and
7 deletions
src-tauri/src/cmds.rs
+
11
−
3
View file @
cf00c947
...
@@ -59,19 +59,27 @@ pub async fn update_profile(
...
@@ -59,19 +59,27 @@ pub async fn update_profile(
clash_state
:
State
<
'_
,
ClashState
>
,
clash_state
:
State
<
'_
,
ClashState
>
,
profiles_state
:
State
<
'_
,
ProfilesState
>
,
profiles_state
:
State
<
'_
,
ProfilesState
>
,
)
->
Result
<
(),
String
>
{
)
->
Result
<
(),
String
>
{
let
url
=
{
let
(
url
,
opt
)
=
{
// must release the lock here
// must release the lock here
let
profiles
=
profiles_state
.0
.lock
()
.unwrap
();
let
profiles
=
profiles_state
.0
.lock
()
.unwrap
();
let
item
=
wrap_err!
(
profiles
.get_item
(
&
index
))
?
;
let
item
=
wrap_err!
(
profiles
.get_item
(
&
index
))
?
;
// check the profile type
if
let
Some
(
typ
)
=
item
.itype
.as_ref
()
{
if
*
typ
!=
"remote"
{
ret_err!
(
format!
(
"could not update the `{typ}` profile"
));
}
}
if
item
.url
.is_none
()
{
if
item
.url
.is_none
()
{
ret_err!
(
"failed to get the item url"
);
ret_err!
(
"failed to get the item url"
);
}
}
item
.url
.clone
()
.unwrap
()
(
item
.url
.clone
()
.unwrap
()
,
item
.option
.clone
())
};
};
let
item
=
wrap_err!
(
PrfItem
::
from_url
(
&
url
,
None
,
None
,
option
)
.await
)
?
;
let
fetch_opt
=
PrfOption
::
merge
(
opt
,
option
);
let
item
=
wrap_err!
(
PrfItem
::
from_url
(
&
url
,
None
,
None
,
fetch_opt
)
.await
)
?
;
let
mut
profiles
=
profiles_state
.0
.lock
()
.unwrap
();
let
mut
profiles
=
profiles_state
.0
.lock
()
.unwrap
();
wrap_err!
(
profiles
.update_item
(
index
.clone
(),
item
))
?
;
wrap_err!
(
profiles
.update_item
(
index
.clone
(),
item
))
?
;
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/core/profiles.rs
+
26
−
3
View file @
cf00c947
...
@@ -73,6 +73,31 @@ pub struct PrfOption {
...
@@ -73,6 +73,31 @@ pub struct PrfOption {
pub
with_proxy
:
Option
<
bool
>
,
pub
with_proxy
:
Option
<
bool
>
,
}
}
impl
PrfOption
{
pub
fn
merge
(
one
:
Option
<
Self
>
,
other
:
Option
<
Self
>
)
->
Option
<
Self
>
{
if
one
.is_some
()
&&
other
.is_some
()
{
let
mut
one
=
one
.unwrap
();
let
other
=
other
.unwrap
();
if
let
Some
(
val
)
=
other
.user_agent
{
one
.user_agent
=
Some
(
val
);
}
if
let
Some
(
val
)
=
other
.with_proxy
{
one
.with_proxy
=
Some
(
val
);
}
return
Some
(
one
);
}
if
one
.is_none
()
{
return
other
;
}
return
one
;
}
}
impl
Default
for
PrfItem
{
impl
Default
for
PrfItem
{
fn
default
()
->
Self
{
fn
default
()
->
Self
{
PrfItem
{
PrfItem
{
...
@@ -414,9 +439,7 @@ impl Profiles {
...
@@ -414,9 +439,7 @@ impl Profiles {
patch!
(
each
,
item
,
selected
);
patch!
(
each
,
item
,
selected
);
patch!
(
each
,
item
,
extra
);
patch!
(
each
,
item
,
extra
);
patch!
(
each
,
item
,
updated
);
patch!
(
each
,
item
,
updated
);
patch!
(
each
,
item
,
option
);
// can be removed
each
.option
=
item
.option
;
self
.items
=
Some
(
items
);
self
.items
=
Some
(
items
);
return
self
.save_file
();
return
self
.save_file
();
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/utils/help.rs
+
1
−
1
View file @
cf00c947
...
@@ -68,7 +68,7 @@ macro_rules! wrap_err {
...
@@ -68,7 +68,7 @@ macro_rules! wrap_err {
/// return the string literal error
/// return the string literal error
#[macro_export]
#[macro_export]
macro_rules!
ret_err
{
macro_rules!
ret_err
{
(
$str
:
literal
)
=>
{
(
$str
:
expr
)
=>
{
return
Err
(
$str
.into
())
return
Err
(
$str
.into
())
};
};
}
}
...
...
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