mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-19 10:22:07 +08:00
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user