mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
fix style
This commit is contained in:
parent
a1f477d502
commit
c5ec08893e
@ -18,8 +18,7 @@ const CollapseInput: React.FC<CollapseInputProps> = (props) => {
|
|||||||
style={{ paddingInlineEnd: 0 }}
|
style={{ paddingInlineEnd: 0 }}
|
||||||
classNames={{
|
classNames={{
|
||||||
inputWrapper: 'cursor-pointer bg-transparent p-0 data-[hover=true]:bg-content2',
|
inputWrapper: 'cursor-pointer bg-transparent p-0 data-[hover=true]:bg-content2',
|
||||||
input: 'w-0 focus:w-[150px] transition-all duration-200',
|
input: 'w-0 focus:w-[150px] focus:ml-2 transition-all duration-200'
|
||||||
innerWrapper: 'cursor-pointer p-0'
|
|
||||||
}}
|
}}
|
||||||
endContent={
|
endContent={
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -34,8 +34,8 @@ const DNS: React.FC = () => {
|
|||||||
'https://dns.alidns.com/dns-query'
|
'https://dns.alidns.com/dns-query'
|
||||||
]
|
]
|
||||||
} = dns || {}
|
} = dns || {}
|
||||||
|
const [changed, setChanged] = useState(false)
|
||||||
const [values, setValues] = useState({
|
const [values, originSetValues] = useState({
|
||||||
ipv6,
|
ipv6,
|
||||||
useHosts,
|
useHosts,
|
||||||
enhancedMode,
|
enhancedMode,
|
||||||
@ -53,6 +53,11 @@ const DNS: React.FC = () => {
|
|||||||
hosts: Object.entries(hosts || {}).map(([domain, value]) => ({ domain, value }))
|
hosts: Object.entries(hosts || {}).map(([domain, value]) => ({ domain, value }))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const setValues = (v: typeof values): void => {
|
||||||
|
originSetValues(v)
|
||||||
|
setChanged(true)
|
||||||
|
}
|
||||||
|
|
||||||
const handleListChange = (type: string, value: string, index: number): void => {
|
const handleListChange = (type: string, value: string, index: number): void => {
|
||||||
const list = [...values[type]]
|
const list = [...values[type]]
|
||||||
if (value.trim()) {
|
if (value.trim()) {
|
||||||
@ -112,48 +117,55 @@ const DNS: React.FC = () => {
|
|||||||
),
|
),
|
||||||
useNameserverPolicy: values.useNameserverPolicy
|
useNameserverPolicy: values.useNameserverPolicy
|
||||||
})
|
})
|
||||||
await patchControledMihomoConfig(patch)
|
try {
|
||||||
await restartCore()
|
setChanged(false)
|
||||||
|
await patchControledMihomoConfig(patch)
|
||||||
|
await restartCore()
|
||||||
|
} catch (e) {
|
||||||
|
alert(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
title="DNS 设置"
|
title="DNS 设置"
|
||||||
header={
|
header={
|
||||||
<Button
|
changed && (
|
||||||
size="sm"
|
<Button
|
||||||
className="app-nodrag"
|
size="sm"
|
||||||
color="primary"
|
className="app-nodrag"
|
||||||
onPress={() => {
|
color="primary"
|
||||||
const hostsObject = Object.fromEntries(
|
onPress={() => {
|
||||||
values.hosts.map(({ domain, value }) => [domain, value])
|
const hostsObject = Object.fromEntries(
|
||||||
)
|
values.hosts.map(({ domain, value }) => [domain, value])
|
||||||
const dnsConfig = {
|
|
||||||
ipv6: values.ipv6,
|
|
||||||
'fake-ip-range': values.fakeIPRange,
|
|
||||||
'fake-ip-filter': values.fakeIPFilter,
|
|
||||||
'enhanced-mode': values.enhancedMode,
|
|
||||||
'use-hosts': values.useHosts,
|
|
||||||
'use-system-hosts': values.useSystemHosts,
|
|
||||||
'respect-rules': values.respectRules,
|
|
||||||
nameserver: values.nameserver,
|
|
||||||
'proxy-server-nameserver': values.proxyServerNameserver,
|
|
||||||
fallback: [],
|
|
||||||
'fallback-filter': {}
|
|
||||||
}
|
|
||||||
if (values.useNameserverPolicy) {
|
|
||||||
dnsConfig['nameserver-policy'] = Object.fromEntries(
|
|
||||||
values.nameserverPolicy.map(({ domain, value }) => [domain, value])
|
|
||||||
)
|
)
|
||||||
}
|
const dnsConfig = {
|
||||||
onSave({
|
ipv6: values.ipv6,
|
||||||
dns: dnsConfig,
|
'fake-ip-range': values.fakeIPRange,
|
||||||
hosts: hostsObject
|
'fake-ip-filter': values.fakeIPFilter,
|
||||||
})
|
'enhanced-mode': values.enhancedMode,
|
||||||
}}
|
'use-hosts': values.useHosts,
|
||||||
>
|
'use-system-hosts': values.useSystemHosts,
|
||||||
保存
|
'respect-rules': values.respectRules,
|
||||||
</Button>
|
nameserver: values.nameserver,
|
||||||
|
'proxy-server-nameserver': values.proxyServerNameserver,
|
||||||
|
fallback: [],
|
||||||
|
'fallback-filter': {}
|
||||||
|
}
|
||||||
|
if (values.useNameserverPolicy) {
|
||||||
|
dnsConfig['nameserver-policy'] = Object.fromEntries(
|
||||||
|
values.nameserverPolicy.map(({ domain, value }) => [domain, value])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onSave({
|
||||||
|
dns: dnsConfig,
|
||||||
|
hosts: hostsObject
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
保存
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<SettingCard>
|
<SettingCard>
|
||||||
|
|||||||
@ -22,8 +22,8 @@ const Sniffer: React.FC = () => {
|
|||||||
'skip-domain': skipDomain = ['+.push.apple.com'],
|
'skip-domain': skipDomain = ['+.push.apple.com'],
|
||||||
'force-domain': forceDomain = []
|
'force-domain': forceDomain = []
|
||||||
} = sniffer || {}
|
} = sniffer || {}
|
||||||
|
const [changed, setChanged] = useState(false)
|
||||||
const [values, setValues] = useState({
|
const [values, originSetValues] = useState({
|
||||||
parsePureIP,
|
parsePureIP,
|
||||||
forceDNSMapping,
|
forceDNSMapping,
|
||||||
overrideDestination,
|
overrideDestination,
|
||||||
@ -31,10 +31,19 @@ const Sniffer: React.FC = () => {
|
|||||||
skipDomain,
|
skipDomain,
|
||||||
forceDomain
|
forceDomain
|
||||||
})
|
})
|
||||||
|
const setValues = (v: typeof values): void => {
|
||||||
|
originSetValues(v)
|
||||||
|
setChanged(true)
|
||||||
|
}
|
||||||
|
|
||||||
const onSave = async (patch: Partial<IMihomoConfig>): Promise<void> => {
|
const onSave = async (patch: Partial<IMihomoConfig>): Promise<void> => {
|
||||||
await patchControledMihomoConfig(patch)
|
try {
|
||||||
await restartCore()
|
setChanged(false)
|
||||||
|
await patchControledMihomoConfig(patch)
|
||||||
|
await restartCore()
|
||||||
|
} catch (e) {
|
||||||
|
alert(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSniffPortChange = (protocol: keyof typeof sniff, value: string): void => {
|
const handleSniffPortChange = (protocol: keyof typeof sniff, value: string): void => {
|
||||||
@ -69,25 +78,27 @@ const Sniffer: React.FC = () => {
|
|||||||
<BasePage
|
<BasePage
|
||||||
title="域名嗅探设置"
|
title="域名嗅探设置"
|
||||||
header={
|
header={
|
||||||
<Button
|
changed && (
|
||||||
size="sm"
|
<Button
|
||||||
className="app-nodrag"
|
size="sm"
|
||||||
color="primary"
|
className="app-nodrag"
|
||||||
onPress={() =>
|
color="primary"
|
||||||
onSave({
|
onPress={() =>
|
||||||
sniffer: {
|
onSave({
|
||||||
'parse-pure-ip': values.parsePureIP,
|
sniffer: {
|
||||||
'force-dns-mapping': values.forceDNSMapping,
|
'parse-pure-ip': values.parsePureIP,
|
||||||
'override-destination': values.overrideDestination,
|
'force-dns-mapping': values.forceDNSMapping,
|
||||||
sniff: values.sniff,
|
'override-destination': values.overrideDestination,
|
||||||
'skip-domain': values.skipDomain,
|
sniff: values.sniff,
|
||||||
'force-domain': values.forceDomain
|
'skip-domain': values.skipDomain,
|
||||||
}
|
'force-domain': values.forceDomain
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
>
|
}
|
||||||
保存
|
>
|
||||||
</Button>
|
保存
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<SettingCard>
|
<SettingCard>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user