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
741abc03
There was an error fetching the commit references. Please try again later.
Unverified
Commit
741abc03
authored
1 year ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: show loading when change profile
parent
7854775d
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/components/profile/profile-box.tsx
+1
-0
1 addition, 0 deletions
src/components/profile/profile-box.tsx
src/components/profile/profile-item.tsx
+22
-1
22 additions, 1 deletion
src/components/profile/profile-item.tsx
src/pages/profiles.tsx
+7
-0
7 additions, 0 deletions
src/pages/profiles.tsx
with
30 additions
and
1 deletion
src/components/profile/profile-box.tsx
+
1
−
0
View file @
741abc03
...
...
@@ -27,6 +27,7 @@ export const ProfileBox = styled(Box)(
}[
key
]
!
;
return
{
position
:
"
relative
"
,
width
:
"
100%
"
,
display
:
"
block
"
,
cursor
:
"
pointer
"
,
...
...
This diff is collapsed.
Click to expand it.
src/components/profile/profile-item.tsx
+
22
−
1
View file @
741abc03
...
...
@@ -12,6 +12,7 @@ import {
keyframes
,
MenuItem
,
Menu
,
CircularProgress
,
}
from
"
@mui/material
"
;
import
{
RefreshRounded
}
from
"
@mui/icons-material
"
;
import
{
atomLoadingCache
}
from
"
@/services/states
"
;
...
...
@@ -28,13 +29,14 @@ const round = keyframes`
interface
Props
{
selected
:
boolean
;
activating
:
boolean
;
itemData
:
IProfileItem
;
onSelect
:
(
force
:
boolean
)
=>
void
;
onEdit
:
()
=>
void
;
}
export
const
ProfileItem
=
(
props
:
Props
)
=>
{
const
{
selected
,
itemData
,
onSelect
,
onEdit
}
=
props
;
const
{
selected
,
activating
,
itemData
,
onSelect
,
onEdit
}
=
props
;
const
{
t
}
=
useTranslation
();
const
[
anchorEl
,
setAnchorEl
]
=
useState
<
any
>
(
null
);
...
...
@@ -192,6 +194,25 @@ export const ProfileItem = (props: Props) => {
event
.
preventDefault
();
}
}
>
{
activating
&&
(
<
Box
sx
=
{
{
position
:
"
absolute
"
,
display
:
"
flex
"
,
justifyContent
:
"
center
"
,
alignItems
:
"
center
"
,
top
:
10
,
left
:
10
,
right
:
10
,
bottom
:
2
,
zIndex
:
10
,
backdropFilter
:
"
blur(2px)
"
,
}
}
>
<
CircularProgress
size
=
{
20
}
/>
</
Box
>
)
}
<
Box
position
=
"relative"
>
<
Typography
width
=
"calc(100% - 36px)"
...
...
This diff is collapsed.
Click to expand it.
src/pages/profiles.tsx
+
7
−
0
View file @
741abc03
...
...
@@ -35,6 +35,7 @@ const ProfilePage = () => {
const
[
url
,
setUrl
]
=
useState
(
""
);
const
[
disabled
,
setDisabled
]
=
useState
(
false
);
const
[
activating
,
setActivating
]
=
useState
(
""
);
const
{
profiles
=
{},
...
...
@@ -99,6 +100,8 @@ const ProfilePage = () => {
const
onSelect
=
useLockFn
(
async
(
current
:
string
,
force
:
boolean
)
=>
{
if
(
!
force
&&
current
===
profiles
.
current
)
return
;
// 避免大多数情况下loading态闪烁
const
reset
=
setTimeout
(()
=>
setActivating
(
current
),
100
);
try
{
await
patchProfiles
({
current
});
mutateLogs
();
...
...
@@ -107,6 +110,9 @@ const ProfilePage = () => {
Notice
.
success
(
"
Refresh clash config
"
,
1000
);
}
catch
(
err
:
any
)
{
Notice
.
error
(
err
?.
message
||
err
.
toString
(),
4000
);
}
finally
{
clearTimeout
(
reset
);
setActivating
(
""
);
}
});
...
...
@@ -258,6 +264,7 @@ const ProfilePage = () => {
<
Grid
item
xs
=
{
12
}
sm
=
{
6
}
md
=
{
4
}
lg
=
{
3
}
key
=
{
item
.
file
}
>
<
ProfileItem
selected
=
{
profiles
.
current
===
item
.
uid
}
activating
=
{
activating
===
item
.
uid
}
itemData
=
{
item
}
onSelect
=
{
(
f
)
=>
onSelect
(
item
.
uid
,
f
)
}
onEdit
=
{
()
=>
viewerRef
.
current
?.
edit
(
item
)
}
...
...
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