fix a little

This commit is contained in:
pompurin404 2024-08-09 16:50:04 +08:00
parent b80dbfbcfd
commit f1b83ee070
No known key found for this signature in database
3 changed files with 29 additions and 6 deletions

View File

@ -4,6 +4,8 @@ export const defaultConfig: IAppConfig = {
proxyDisplayMode: 'simple',
proxyDisplayOrder: 'default',
autoCheckUpdate: true,
useNameserverPolicy: false,
nameserverPolicy: {},
sysProxy: { enable: false, mode: 'manual' }
}

View File

@ -55,20 +55,20 @@ const DNS: React.FC = () => {
if (value.trim()) {
if (index < list.length) {
list[index] = value
} else if (list.length < 4) {
} else {
list.push(value)
}
} else {
list.splice(index, 1)
}
setValues({ ...values, [type]: list.slice(0, 4) })
setValues({ ...values, [type]: list })
}
const renderListInputs = (type: string, placeholder: string): ReactNode => {
const currentItems = values[type].slice(0, 4)
const showNewLine = currentItems.length < 4 && currentItems.every((item) => item.trim() !== '')
const currentItems = values[type]
const showNewLine = currentItems.every((item: string) => item.trim() !== '')
return [...currentItems, ...(showNewLine ? [''] : [])].slice(0, 4).map((item, index) => (
return [...currentItems, ...(showNewLine ? [''] : [])].map((item, index) => (
<div key={index} className="mt-2 flex">
<Input
fullWidth

View File

@ -23,8 +23,15 @@ const Settings: React.FC = () => {
})
const { appConfig, patchAppConfig } = useAppConfig()
const { silentStart = false, delayTestUrl, delayTestTimeout, autoCheckUpdate } = appConfig || {}
const {
silentStart = false,
delayTestUrl,
delayTestTimeout,
autoCheckUpdate,
userAgent
} = appConfig || {}
const [url, setUrl] = useState(delayTestUrl)
const [ua, setUa] = useState(userAgent)
return (
<BasePage
@ -76,6 +83,20 @@ const Settings: React.FC = () => {
</SettingItem>
</SettingCard>
<SettingCard>
<SettingItem title="订阅拉取 UA" divider>
<Input
size="sm"
className="w-[60%]"
value={ua}
placeholder="默认 clash-meta"
onValueChange={(v) => {
setUa(v)
debounce(() => {
patchAppConfig({ userAgent: v })
}, 2000)
}}
></Input>
</SettingItem>
<SettingItem title="延迟测试地址" divider>
<Input
size="sm"