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
a2cf26e7
There was an error fetching the commit references. Please try again later.
Unverified
Commit
a2cf26e7
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: add proxy item check loading
parent
71e69003
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/components/base/base-loading.tsx
+50
-0
50 additions, 0 deletions
src/components/base/base-loading.tsx
src/components/proxy/proxy-item.tsx
+50
-37
50 additions, 37 deletions
src/components/proxy/proxy-item.tsx
with
100 additions
and
37 deletions
src/components/base/base-loading.tsx
0 → 100644
+
50
−
0
View file @
a2cf26e7
import
{
styled
}
from
"
@mui/material
"
;
const
Loading
=
styled
(
"
div
"
)
`
position: relative;
display: flex;
height: 100%;
min-height: 18px;
box-sizing: border-box;
align-items: center;
& > div {
box-sizing: border-box;
width: 6px;
height: 6px;
margin: 2px;
border-radius: 100%;
animation: loading 0.7s -0.15s infinite linear;
}
& > div:nth-child(2n-1) {
animation-delay: -0.5s;
}
@keyframes loading {
50% {
opacity: 0.2;
transform: scale(0.75);
}
100% {
opacity: 1;
transform: scale(1);
}
}
`
;
const
LoadingItem
=
styled
(
"
div
"
)(({
theme
})
=>
({
background
:
theme
.
palette
.
text
.
secondary
,
}));
const
BaseLoading
=
()
=>
{
return
(
<
Loading
>
<
LoadingItem
/>
<
LoadingItem
/>
<
LoadingItem
/>
</
Loading
>
);
};
export
default
BaseLoading
;
This diff is collapsed.
Click to expand it.
src/components/proxy/proxy-item.tsx
+
50
−
37
View file @
a2cf26e7
...
...
@@ -13,6 +13,7 @@ import {
Theme
,
}
from
"
@mui/material
"
;
import
delayManager
from
"
@/services/delay
"
;
import
BaseLoading
from
"
../base/base-loading
"
;
interface
Props
{
groupName
:
string
;
...
...
@@ -43,6 +44,9 @@ const TypeBox = styled(Box)(({ theme }) => ({
const
ProxyItem
=
(
props
:
Props
)
=>
{
const
{
groupName
,
proxy
,
selected
,
showType
=
true
,
sx
,
onClick
}
=
props
;
// -1/<=0 为 不显示
// -2 为 loading
const
[
delay
,
setDelay
]
=
useState
(
-
1
);
useEffect
(()
=>
{
...
...
@@ -61,6 +65,7 @@ const ProxyItem = (props: Props) => {
},
[
proxy
]);
const
onDelay
=
useLockFn
(
async
()
=>
{
setDelay
(
-
2
);
return
delayManager
.
checkDelay
(
proxy
.
name
,
groupName
)
.
then
((
result
)
=>
setDelay
(
result
))
...
...
@@ -81,14 +86,9 @@ const ProxyItem = (props: Props) => {
?
alpha
(
primary
.
main
,
0.15
)
:
alpha
(
primary
.
main
,
0.35
);
const
color
=
mode
===
"
light
"
?
primary
.
main
:
primary
.
light
;
const
showDelay
=
delay
>
0
;
const
showIcon
=
!
showDelay
&&
selected
;
return
{
"
.the-check
"
:
{
display
:
"
none
"
},
"
.the-delay
"
:
{
display
:
showDelay
?
"
block
"
:
"
none
"
},
"
.the-icon
"
:
{
display
:
showIcon
?
"
block
"
:
"
none
"
},
"
&:hover .the-check
"
:
{
display
:
!
showDelay
?
"
block
"
:
"
none
"
},
"
&:hover .the-delay
"
:
{
display
:
showDelay
?
"
block
"
:
"
none
"
},
"
&:hover .the-icon
"
:
{
display
:
"
none
"
},
...
...
@@ -116,7 +116,14 @@ const ProxyItem = (props: Props) => {
<
ListItemIcon
sx
=
{
{
justifyContent
:
"
flex-end
"
,
color
:
"
primary.main
"
}
}
>
{
!
proxy
.
provider
&&
(
{
delay
===
-
2
&&
(
<
Widget
>
<
BaseLoading
/>
</
Widget
>
)
}
{
!
proxy
.
provider
&&
delay
!==
-
2
&&
(
// provider的节点不支持检测
<
Widget
className
=
"the-check"
onClick
=
{
(
e
)
=>
{
...
...
@@ -124,43 +131,49 @@ const ProxyItem = (props: Props) => {
e
.
stopPropagation
();
onDelay
();
}
}
sx
=
{
(
theme
)
=>
({
"
:hover
"
:
{
bgcolor
:
alpha
(
theme
.
palette
.
primary
.
main
,
0.15
)
},
sx
=
{
({
palette
})
=>
({
display
:
"
none
"
,
// hover才显示
"
:hover
"
:
{
bgcolor
:
alpha
(
palette
.
primary
.
main
,
0.15
)
},
})
}
>
Check
</
Widget
>
)
}
<
Widget
className
=
"the-delay"
onClick
=
{
(
e
)
=>
{
if
(
proxy
.
provider
)
return
;
e
.
preventDefault
();
e
.
stopPropagation
();
onDelay
();
}
}
color
=
{
delay
>
500
?
"
error.main
"
:
delay
<
100
?
"
success.main
"
:
"
text.secondary
"
}
sx
=
{
({
palette
})
=>
!
proxy
.
provider
?
{
"
:hover
"
:
{
bgcolor
:
alpha
(
palette
.
primary
.
main
,
0.15
)
}
}
:
{}
}
>
{
delay
>
1
e5
?
"
Error
"
:
delay
>
3000
?
"
Timeout
"
:
`
${
delay
}
ms`
}
</
Widget
>
<
CheckCircleOutlineRounded
className
=
"the-icon"
sx
=
{
{
fontSize
:
16
}
}
/>
{
delay
>
0
&&
(
// 显示延迟
<
Widget
className
=
"the-delay"
onClick
=
{
(
e
)
=>
{
if
(
proxy
.
provider
)
return
;
e
.
preventDefault
();
e
.
stopPropagation
();
onDelay
();
}
}
color
=
{
delay
>
500
?
"
error.main
"
:
delay
<
100
?
"
success.main
"
:
"
text.secondary
"
}
sx
=
{
({
palette
})
=>
!
proxy
.
provider
?
{
"
:hover
"
:
{
bgcolor
:
alpha
(
palette
.
primary
.
main
,
0.15
)
}
}
:
{}
}
>
{
delay
>
1
e5
?
"
Error
"
:
delay
>
3000
?
"
Timeout
"
:
`
${
delay
}
ms`
}
</
Widget
>
)
}
{
delay
!==
-
2
&&
delay
<=
0
&&
selected
&&
(
// 展示已选择的icon
<
CheckCircleOutlineRounded
className
=
"the-icon"
sx
=
{
{
fontSize
:
16
}
}
/>
)
}
</
ListItemIcon
>
</
ListItemButton
>
</
ListItem
>
...
...
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