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
2f8146b1
There was an error fetching the commit references. Please try again later.
Unverified
Commit
2f8146b1
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
fix: clash field state error
parent
7f321c89
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/components/setting/mods/clash-field-viewer.tsx
+14
-12
14 additions, 12 deletions
src/components/setting/mods/clash-field-viewer.tsx
with
14 additions
and
12 deletions
src/components/setting/mods/clash-field-viewer.tsx
+
14
−
12
View file @
2f8146b1
...
...
@@ -46,8 +46,11 @@ const handleFields = [...HANDLE_FIELDS, ...DEFAULT_FIELDS].sort(fieldSorter);
const
ClashFieldViewer
=
({
handler
}:
Props
)
=>
{
const
{
t
}
=
useTranslation
();
const
{
data
,
mutate
}
=
useSWR
(
"
getProfiles
"
,
getProfiles
);
const
{
data
:
existsKeys
=
[]
}
=
useSWR
(
const
{
data
:
profiles
=
{},
mutate
:
mutateProfile
}
=
useSWR
(
"
getProfiles
"
,
getProfiles
);
const
{
data
:
existsKeys
=
[],
mutate
:
mutateExists
}
=
useSWR
(
"
getRuntimeExists
"
,
getRuntimeExists
);
...
...
@@ -63,12 +66,12 @@ const ClashFieldViewer = ({ handler }: Props) => {
}
useEffect
(()
=>
{
if
(
open
)
mutate
();
},
[
open
]
);
useEffect
(()
=>
{
setSelected
(
data
?.
valid
||
[]);
},
[
data
?
.
valid
]);
if
(
open
)
{
mutateProfile
(
);
mutateExists
();
setSelected
(
profiles
.
valid
||
[]);
}
},
[
open
,
profiles
.
valid
]);
const
handleChange
=
(
item
:
string
)
=>
{
if
(
!
item
)
return
;
...
...
@@ -81,7 +84,7 @@ const ClashFieldViewer = ({ handler }: Props) => {
const
handleSave
=
async
()
=>
{
setOpen
(
false
);
const
oldSet
=
new
Set
(
data
?
.
valid
||
[]);
const
oldSet
=
new
Set
(
profiles
.
valid
||
[]);
const
curSet
=
new
Set
(
selected
);
const
joinSet
=
new
Set
(
selected
.
concat
([...
oldSet
]));
...
...
@@ -89,7 +92,7 @@ const ClashFieldViewer = ({ handler }: Props) => {
try
{
await
changeProfileValid
([...
curSet
]);
mutate
();
mutate
Profile
();
Notice
.
success
(
"
Refresh clash config
"
,
1000
);
}
catch
(
err
:
any
)
{
Notice
.
error
(
err
?.
message
||
err
.
toString
());
...
...
@@ -112,7 +115,6 @@ const ClashFieldViewer = ({ handler }: Props) => {
{
otherFields
.
map
((
item
)
=>
{
const
inSelect
=
selected
.
includes
(
item
);
const
inConfig
=
existsKeys
.
includes
(
item
);
const
inValid
=
data
?.
valid
?.
includes
(
item
);
return
(
<
Stack
key
=
{
item
}
mb
=
{
0.5
}
direction
=
"row"
alignItems
=
"center"
>
...
...
@@ -124,7 +126,7 @@ const ClashFieldViewer = ({ handler }: Props) => {
/>
<
Typography
width
=
"100%"
>
{
item
}
</
Typography
>
{
!
inSelect
&&
inConfig
&&
!
inValid
&&
<
WarnIcon
/>
}
{
!
inSelect
&&
inConfig
&&
<
WarnIcon
/>
}
</
Stack
>
);
})
}
...
...
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