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
99c46685
There was an error fetching the commit references. Please try again later.
Unverified
Commit
99c46685
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: finish clash field control
parent
066b0804
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/setting/mods/clash-field-viewer.tsx
+10
-7
10 additions, 7 deletions
src/components/setting/mods/clash-field-viewer.tsx
src/components/setting/setting-clash.tsx
+9
-6
9 additions, 6 deletions
src/components/setting/setting-clash.tsx
with
19 additions
and
13 deletions
src/components/setting/mods/clash-field-viewer.tsx
+
10
−
7
View file @
99c46685
...
...
@@ -13,6 +13,7 @@ import {
Tooltip
,
Typography
,
}
from
"
@mui/material
"
;
import
{
BuildCircleRounded
,
InfoRounded
}
from
"
@mui/icons-material
"
;
import
{
changeProfileValid
,
getProfiles
}
from
"
@/services/cmds
"
;
import
{
ModalHandler
}
from
"
@/hooks/use-modal-handler
"
;
import
enhance
,
{
...
...
@@ -20,11 +21,10 @@ import enhance, {
HANDLE_FIELDS
,
USE_FLAG_FIELDS
,
}
from
"
@/services/enhance
"
;
import
{
BuildCircleRounded
,
InfoRounded
}
from
"
@mui/icons-material
"
;
import
Notice
from
"
@/components/base/base-notice
"
;
interface
Props
{
handler
:
ModalHandler
;
onError
:
(
err
:
Error
)
=>
void
;
}
const
fieldSorter
=
(
a
:
string
,
b
:
string
)
=>
{
...
...
@@ -39,7 +39,7 @@ const fieldSorter = (a: string, b: string) => {
const
useFields
=
[...
USE_FLAG_FIELDS
].
sort
(
fieldSorter
);
const
handleFields
=
[...
HANDLE_FIELDS
,
...
DEFAULT_FIELDS
].
sort
(
fieldSorter
);
const
ClashFieldViewer
=
({
handler
,
onError
}:
Props
)
=>
{
const
ClashFieldViewer
=
({
handler
}:
Props
)
=>
{
const
{
t
}
=
useTranslation
();
const
{
data
,
mutate
}
=
useSWR
(
"
getProfiles
"
,
getProfiles
);
...
...
@@ -56,8 +56,6 @@ const ClashFieldViewer = ({ handler, onError }: Props) => {
};
}
console
.
log
(
"
render
"
);
useEffect
(()
=>
{
if
(
open
)
mutate
();
},
[
open
]);
...
...
@@ -85,8 +83,9 @@ const ClashFieldViewer = ({ handler, onError }: Props) => {
try
{
await
changeProfileValid
([...
new
Set
(
selected
)]);
mutate
();
Notice
.
success
(
"
Refresh clash config
"
,
1000
);
}
catch
(
err
:
any
)
{
onError
(
err
);
Notice
.
error
(
err
?.
message
||
err
.
toString
()
);
}
};
...
...
@@ -125,7 +124,11 @@ const ClashFieldViewer = ({ handler, onError }: Props) => {
);
})
}
<
Divider
sx
=
{
{
my
:
0.5
}
}
/>
<
Divider
sx
=
{
{
my
:
1
}
}
>
<
Typography
color
=
"text.secondary"
fontSize
=
{
14
}
>
Clash Verge Control Fields
</
Typography
>
</
Divider
>
{
handleFields
.
map
((
item
)
=>
(
<
Stack
key
=
{
item
}
mb
=
{
0.5
}
direction
=
"row"
alignItems
=
"center"
>
...
...
This diff is collapsed.
Click to expand it.
src/components/setting/setting-clash.tsx
+
9
−
6
View file @
99c46685
import
useSWR
,
{
useSWRConfig
}
from
"
swr
"
;
import
useSWR
from
"
swr
"
;
import
{
useSetRecoilState
}
from
"
recoil
"
;
import
{
useTranslation
}
from
"
react-i18next
"
;
import
{
...
...
@@ -27,8 +27,11 @@ interface Props {
const
SettingClash
=
({
onError
}:
Props
)
=>
{
const
{
t
}
=
useTranslation
();
const
{
mutate
}
=
useSWRConfig
();
const
{
data
:
clashConfig
}
=
useSWR
(
"
getClashConfig
"
,
getClashConfig
);
const
{
data
:
clashConfig
,
mutate
:
mutateClash
}
=
useSWR
(
"
getClashConfig
"
,
getClashConfig
);
const
{
data
:
versionData
}
=
useSWR
(
"
getVersion
"
,
getVersion
);
const
{
...
...
@@ -45,7 +48,7 @@ const SettingClash = ({ onError }: Props) => {
const
onSwitchFormat
=
(
_e
:
any
,
value
:
boolean
)
=>
value
;
const
onChangeData
=
(
patch
:
Partial
<
ApiType
.
ConfigData
>
)
=>
{
mutate
(
"
getClashConfig
"
,
{
...
clashConfig
,
...
patch
},
false
);
mutate
Clash
((
old
)
=>
({
...(
old
!
||
{})
,
...
patch
}
)
,
false
);
};
const
onUpdateData
=
async
(
patch
:
Partial
<
ApiType
.
ConfigData
>
)
=>
{
await
updateConfigs
(
patch
);
...
...
@@ -64,7 +67,7 @@ const SettingClash = ({ onError }: Props) => {
Notice
.
success
(
"
Change Clash port successfully!
"
,
1000
);
// update the config
mutate
(
"
getClashConfig
"
);
mutate
Clash
(
);
};
// get clash core version
...
...
@@ -75,7 +78,7 @@ const SettingClash = ({ onError }: Props) => {
return
(
<
SettingList
title
=
{
t
(
"
Clash Setting
"
)
}
>
<
WebUIViewer
handler
=
{
webUIHandler
}
onError
=
{
onError
}
/>
<
ClashFieldViewer
handler
=
{
fieldHandler
}
onError
=
{
onError
}
/>
<
ClashFieldViewer
handler
=
{
fieldHandler
}
/>
<
SettingItem
label
=
{
t
(
"
Allow Lan
"
)
}
>
<
GuardState
...
...
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