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
c5289dc0
There was an error fetching the commit references. Please try again later.
Unverified
Commit
c5289dc0
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
fix: field sort for filter
parent
d1918770
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src-tauri/src/enhance/field.rs
+24
-1
24 additions, 1 deletion
src-tauri/src/enhance/field.rs
src-tauri/src/enhance/mod.rs
+1
-1
1 addition, 1 deletion
src-tauri/src/enhance/mod.rs
with
25 additions
and
2 deletions
src-tauri/src/enhance/field.rs
+
24
−
1
View file @
c5289dc0
use
serde_yaml
::{
Mapping
,
Value
};
use
serde_yaml
::{
Mapping
,
Value
};
use
std
::
collections
::
HashSet
;
pub
const
HANDLE_FIELDS
:
[
&
str
;
9
]
=
[
pub
const
HANDLE_FIELDS
:
[
&
str
;
9
]
=
[
"mode"
,
"mode"
,
...
@@ -102,7 +103,7 @@ pub fn use_lowercase(config: Mapping) -> Mapping {
...
@@ -102,7 +103,7 @@ pub fn use_lowercase(config: Mapping) -> Mapping {
ret
ret
}
}
pub
fn
use_sort
(
config
:
Mapping
)
->
Mapping
{
pub
fn
use_sort
(
config
:
Mapping
,
enable_filter
:
bool
)
->
Mapping
{
let
mut
ret
=
Mapping
::
new
();
let
mut
ret
=
Mapping
::
new
();
HANDLE_FIELDS
HANDLE_FIELDS
...
@@ -115,6 +116,28 @@ pub fn use_sort(config: Mapping) -> Mapping {
...
@@ -115,6 +116,28 @@ pub fn use_sort(config: Mapping) -> Mapping {
ret
.insert
(
key
,
value
.clone
());
ret
.insert
(
key
,
value
.clone
());
});
});
});
});
if
!
enable_filter
{
let
supported_keys
:
HashSet
<&
str
>
=
HANDLE_FIELDS
.into_iter
()
.chain
(
OTHERS_FIELDS
)
.chain
(
DEFAULT_FIELDS
)
.collect
();
let
config_keys
:
HashSet
<&
str
>
=
config
.keys
()
.filter_map
(|
e
|
e
.as_str
())
.into_iter
()
.collect
();
config_keys
.difference
(
&
supported_keys
)
.for_each
(|
&
key
|
{
let
key
=
Value
::
from
(
key
);
config
.get
(
&
key
)
.map
(|
value
|
{
ret
.insert
(
key
,
value
.clone
());
});
});
}
ret
ret
}
}
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/enhance/mod.rs
+
1
−
1
View file @
c5289dc0
...
@@ -116,7 +116,7 @@ pub fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
...
@@ -116,7 +116,7 @@ pub fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
config
=
use_filter
(
config
,
&
clash_fields
,
enable_filter
);
config
=
use_filter
(
config
,
&
clash_fields
,
enable_filter
);
config
=
use_tun
(
config
,
enable_tun
);
config
=
use_tun
(
config
,
enable_tun
);
config
=
use_sort
(
config
);
config
=
use_sort
(
config
,
enable_filter
);
let
mut
exists_set
=
HashSet
::
new
();
let
mut
exists_set
=
HashSet
::
new
();
exists_set
.extend
(
exists_keys
.into_iter
()
.filter
(|
s
|
clash_fields
.contains
(
s
)));
exists_set
.extend
(
exists_keys
.into_iter
()
.filter
(|
s
|
clash_fields
.contains
(
s
)));
...
...
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