fix style

This commit is contained in:
pompurin404 2024-09-03 15:34:16 +08:00
parent a1f477d502
commit c5ec08893e
No known key found for this signature in database
3 changed files with 84 additions and 62 deletions

View File

@ -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

View File

@ -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,14 +117,20 @@ const DNS: React.FC = () => {
), ),
useNameserverPolicy: values.useNameserverPolicy useNameserverPolicy: values.useNameserverPolicy
}) })
try {
setChanged(false)
await patchControledMihomoConfig(patch) await patchControledMihomoConfig(patch)
await restartCore() await restartCore()
} catch (e) {
alert(e)
}
} }
return ( return (
<BasePage <BasePage
title="DNS 设置" title="DNS 设置"
header={ header={
changed && (
<Button <Button
size="sm" size="sm"
className="app-nodrag" className="app-nodrag"
@ -154,6 +165,7 @@ const DNS: React.FC = () => {
> >
</Button> </Button>
)
} }
> >
<SettingCard> <SettingCard>

View File

@ -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> => {
try {
setChanged(false)
await patchControledMihomoConfig(patch) await patchControledMihomoConfig(patch)
await restartCore() 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,6 +78,7 @@ const Sniffer: React.FC = () => {
<BasePage <BasePage
title="域名嗅探设置" title="域名嗅探设置"
header={ header={
changed && (
<Button <Button
size="sm" size="sm"
className="app-nodrag" className="app-nodrag"
@ -88,6 +98,7 @@ const Sniffer: React.FC = () => {
> >
</Button> </Button>
)
} }
> >
<SettingCard> <SettingCard>