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
f062f7f9
There was an error fetching the commit references. Please try again later.
Unverified
Commit
f062f7f9
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: change global mode ui, close #226
parent
f6837804
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/pages/proxies.tsx
+16
-22
16 additions, 22 deletions
src/pages/proxies.tsx
src/services/api.ts
+6
-1
6 additions, 1 deletion
src/services/api.ts
with
22 additions
and
23 deletions
src/pages/proxies.tsx
+
16
−
22
View file @
f062f7f9
import
useSWR
,
{
useSWRConfig
}
from
"
swr
"
;
import
{
useEffect
}
from
"
react
"
;
import
{
useEffect
,
useMemo
}
from
"
react
"
;
import
{
useLockFn
}
from
"
ahooks
"
;
import
{
useTranslation
}
from
"
react-i18next
"
;
import
{
Button
,
ButtonGroup
,
List
,
Paper
}
from
"
@mui/material
"
;
...
...
@@ -7,8 +7,8 @@ import { getClashConfig, updateConfigs } from "@/services/api";
import
{
patchClashConfig
}
from
"
@/services/cmds
"
;
import
{
getProxies
}
from
"
@/services/api
"
;
import
BasePage
from
"
@/components/base/base-page
"
;
import
BaseEmpty
from
"
@/components/base/base-empty
"
;
import
ProxyGroup
from
"
@/components/proxy/proxy-group
"
;
import
ProxyGlobal
from
"
@/components/proxy/proxy-global
"
;
const
ProxyPage
=
()
=>
{
const
{
t
}
=
useTranslation
();
...
...
@@ -18,7 +18,7 @@ const ProxyPage = () => {
const
modeList
=
[
"
rule
"
,
"
global
"
,
"
direct
"
,
"
script
"
];
const
curMode
=
clashConfig
?.
mode
.
toLowerCase
();
const
{
groups
=
[],
proxies
=
[]
}
=
proxiesData
??
{};
const
{
global
,
groups
=
[],
proxies
=
[]
}
=
proxiesData
??
{};
// make sure that fetch the proxies successfully
useEffect
(()
=>
{
...
...
@@ -37,9 +37,15 @@ const ProxyPage = () => {
mutate
(
"
getClashConfig
"
);
});
const
displayGroups
=
useMemo
(()
=>
{
if
(
!
global
)
return
groups
;
if
(
curMode
===
"
global
"
||
curMode
===
"
direct
"
)
return
[
global
,
...
groups
];
return
groups
;
},
[
global
,
groups
,
curMode
]);
// difference style
const
showGroup
=
(
curMode
===
"
rule
"
||
curMode
===
"
script
"
)
&&
!!
groups
.
length
;
const
showGroup
=
displayGroups
.
length
>
0
;
const
pageStyle
=
showGroup
?
{}
:
{
height
:
"
100%
"
};
const
paperStyle
:
any
=
showGroup
?
{
mb
:
0.5
}
...
...
@@ -48,7 +54,7 @@ const ProxyPage = () => {
return
(
<
BasePage
contentStyle
=
{
pageStyle
}
title
=
{
showGroup
?
t
(
"
Proxy Groups
"
)
:
t
(
"
Proxies
"
)
}
title
=
{
t
(
"
Proxy Groups
"
)
}
header
=
{
<
ButtonGroup
size
=
"small"
>
{
modeList
.
map
((
mode
)
=>
(
...
...
@@ -65,26 +71,14 @@ const ProxyPage = () => {
}
>
<
Paper
sx
=
{
{
borderRadius
:
1
,
boxShadow
:
2
,
...
paperStyle
}
}
>
{
(
curMode
===
"
rule
"
||
curMode
===
"
script
"
)
&&
!!
g
roups
.
length
&&
(
{
displayG
roups
.
length
>
0
?
(
<
List
>
{
g
roups
.
map
((
group
)
=>
(
{
displayG
roups
.
map
((
group
)
=>
(
<
ProxyGroup
key
=
{
group
.
name
}
group
=
{
group
}
/>
))
}
</
List
>
)
}
{
((
curMode
===
"
rule
"
&&
!
groups
.
length
)
||
curMode
===
"
global
"
)
&&
(
<
ProxyGlobal
groupName
=
"GLOBAL"
curProxy
=
{
proxiesData
?.
global
?.
now
}
proxies
=
{
proxies
}
/>
)
}
{
curMode
===
"
direct
"
&&
(
<
ProxyGlobal
groupName
=
"DIRECT"
curProxy
=
"DIRECT"
proxies
=
{
[
proxiesData
?.
direct
!
].
filter
(
Boolean
)
}
/>
)
:
(
<
BaseEmpty
/>
)
}
</
Paper
>
</
BasePage
>
...
...
This diff is collapsed.
Click to expand it.
src/services/api.ts
+
6
−
1
View file @
f062f7f9
...
...
@@ -142,7 +142,12 @@ export async function getProxies() {
)
);
return
{
global
,
direct
,
groups
,
records
:
proxyRecord
,
proxies
};
const
_global
:
ApiType
.
ProxyGroupItem
=
{
...
global
,
all
:
global
?.
all
?.
map
((
item
)
=>
generateItem
(
item
))
||
[],
};
return
{
global
:
_global
,
direct
,
groups
,
records
:
proxyRecord
,
proxies
};
}
// get proxy providers
...
...
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