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
433716cf
There was an error fetching the commit references. Please try again later.
Commit
433716cf
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: optimize the proxy group order
parent
e737bb4c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/proxy.ts
+28
-24
28 additions, 24 deletions
src/services/proxy.ts
with
28 additions
and
24 deletions
src/services/proxy.ts
+
28
−
24
View file @
433716cf
...
...
@@ -12,35 +12,39 @@ export interface ProxyItem {
now
?:
string
;
}
export
type
ProxyGroupItem
=
Omit
<
ProxyItem
,
"
all
"
|
"
now
"
>
&
{
all
?:
ProxyItem
[];
now
?:
string
;
export
type
ProxyGroupItem
=
Omit
<
ProxyItem
,
"
all
"
>
&
{
all
:
ProxyItem
[];
};
/// Get the Proxy infomation
export
async
function
getProxyInfo
()
{
const
response
=
(
await
axiosIns
.
get
(
"
/proxies
"
))
as
any
;
const
results
=
(
response
?.
proxies
??
{})
as
Record
<
string
,
ProxyItem
>
;
const
global
=
results
[
"
GLOBAL
"
]
||
results
[
"
global
"
];
const
proxies
=
Object
.
values
(
results
).
filter
((
each
)
=>
each
.
all
==
null
);
const
groups
=
Object
.
values
(
results
).
filter
(
(
each
)
=>
each
.
name
.
toLocaleUpperCase
()
!==
"
GLOBAL
"
&&
each
.
all
!=
null
)
as
ProxyGroupItem
[];
groups
.
forEach
((
each
)
=>
{
// @ts-ignore
each
.
all
=
each
.
all
?.
map
((
item
)
=>
results
[
item
]).
filter
((
e
)
=>
e
);
});
groups
.
sort
((
a
,
b
)
=>
b
.
name
.
localeCompare
(
a
.
name
));
return
{
global
,
groups
,
proxies
,
};
const
proxies
=
(
response
?.
proxies
??
{})
as
Record
<
string
,
ProxyItem
>
;
const
global
=
proxies
[
"
GLOBAL
"
];
const
order
=
global
?.
all
;
let
groups
:
ProxyGroupItem
[]
=
[];
if
(
order
)
{
groups
=
order
.
filter
((
name
)
=>
proxies
[
name
]?.
all
)
.
map
((
name
)
=>
proxies
[
name
])
.
map
((
each
)
=>
({
...
each
,
all
:
each
.
all
!
.
map
((
item
)
=>
proxies
[
item
]),
}));
}
else
{
groups
=
Object
.
values
(
proxies
)
.
filter
((
each
)
=>
each
.
name
!==
"
GLOBAL
"
&&
each
.
all
)
.
map
((
each
)
=>
({
...
each
,
all
:
each
.
all
!
.
map
((
item
)
=>
proxies
[
item
]),
}));
groups
.
sort
((
a
,
b
)
=>
b
.
name
.
localeCompare
(
a
.
name
));
}
return
{
global
,
groups
,
proxies
};
}
/// Update the Proxy Choose
...
...
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