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', proxyDisplayMode: 'simple',
proxyDisplayOrder: 'default', proxyDisplayOrder: 'default',
autoCheckUpdate: true, autoCheckUpdate: true,
useNameserverPolicy: false,
nameserverPolicy: {},
sysProxy: { enable: false, mode: 'manual' } sysProxy: { enable: false, mode: 'manual' }
} }

View File

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

View File

@ -23,8 +23,15 @@ const Settings: React.FC = () => {
}) })
const { appConfig, patchAppConfig } = useAppConfig() 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 [url, setUrl] = useState(delayTestUrl)
const [ua, setUa] = useState(userAgent)
return ( return (
<BasePage <BasePage
@ -76,6 +83,20 @@ const Settings: React.FC = () => {
</SettingItem> </SettingItem>
</SettingCard> </SettingCard>
<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> <SettingItem title="延迟测试地址" divider>
<Input <Input
size="sm" size="sm"