feat(profile): raise auto-update intervals below 24h

Each auto-update reloads the core, which drops every connection running through a
`proxy-providers` entry. Existing profiles are corrected once at startup; the form
warns about shorter intervals but still saves them.
This commit is contained in:
wonfen
2026-08-17 12:14:24 +08:00
parent 73d986369c
commit ec6241b30a
21 changed files with 215 additions and 17 deletions
+38 -17
View File
@@ -35,6 +35,9 @@ export interface ProfileViewerRef {
// remote / local
type ProfileViewerProps = Props & { ref?: Ref<ProfileViewerRef> }
// 同后端 constants::profile::MIN_UPDATE_INTERVAL
const MIN_UPDATE_INTERVAL = 1440
export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
const { t } = useTranslation()
const [open, setOpen] = useState(false)
@@ -354,23 +357,41 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
<Controller
name="option.update_interval"
control={control}
render={({ field }) => (
<TextField
{...text}
{...field}
type="number"
label={t('profiles.modals.profileForm.fields.updateInterval')}
slotProps={{
input: {
endAdornment: (
<InputAdornment position="end">
{t('shared.units.minutes')}
</InputAdornment>
),
},
}}
/>
)}
render={({ field }) => {
const interval = Number(field.value)
// 0 和空值表示不自动更新,不提醒
const tooFrequent =
Number.isFinite(interval) &&
interval > 0 &&
interval < MIN_UPDATE_INTERVAL
return (
<TextField
{...text}
{...field}
type="number"
label={t('profiles.modals.profileForm.fields.updateInterval')}
helperText={
tooFrequent
? t(
'profiles.modals.profileForm.warnings.frequentUpdate',
{ minutes: MIN_UPDATE_INTERVAL },
)
: undefined
}
slotProps={{
formHelperText: { sx: { color: 'warning.main' } },
input: {
endAdornment: (
<InputAdornment position="end">
{t('shared.units.minutes')}
</InputAdornment>
),
},
}}
/>
)
}}
/>
<Controller
name="option.with_proxy"