mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-23 14:12:14 +08:00
fix: set default auto-query interval to 5min and fix number input clearing
- Change default autoQueryInterval from 0 (disabled) to 5 minutes for new usage scripts (Token Plan, Balance, and general templates) - Fix controlled number inputs (timeout & interval) that couldn't be cleared: defer validation to onBlur so users can delete and retype
This commit is contained in:
@@ -238,6 +238,7 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
||||
language: "javascript" as const,
|
||||
code: "",
|
||||
timeout: 10,
|
||||
autoQueryInterval: 5,
|
||||
codingPlanProvider: autoDetected,
|
||||
};
|
||||
}
|
||||
@@ -249,6 +250,7 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
||||
language: "javascript" as const,
|
||||
code: "",
|
||||
timeout: 10,
|
||||
autoQueryInterval: 5,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -257,6 +259,7 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
||||
language: "javascript" as const,
|
||||
code: PRESET_TEMPLATES[TEMPLATE_TYPES.GENERAL],
|
||||
timeout: 10,
|
||||
autoQueryInterval: 5,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1061,7 +1064,10 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
||||
onChange={(e) =>
|
||||
setScript({
|
||||
...script,
|
||||
timeout: validateTimeout(e.target.value),
|
||||
timeout:
|
||||
e.target.value === ""
|
||||
? (("" as unknown) as number)
|
||||
: Number(e.target.value),
|
||||
})
|
||||
}
|
||||
onBlur={(e) =>
|
||||
@@ -1085,14 +1091,15 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
||||
min={0}
|
||||
max={1440}
|
||||
value={
|
||||
script.autoQueryInterval ?? script.autoIntervalMinutes ?? 0
|
||||
script.autoQueryInterval ?? script.autoIntervalMinutes ?? 5
|
||||
}
|
||||
onChange={(e) =>
|
||||
setScript({
|
||||
...script,
|
||||
autoQueryInterval: validateAndClampInterval(
|
||||
e.target.value,
|
||||
),
|
||||
autoQueryInterval:
|
||||
e.target.value === ""
|
||||
? (("" as unknown) as number)
|
||||
: Number(e.target.value),
|
||||
})
|
||||
}
|
||||
onBlur={(e) =>
|
||||
|
||||
Reference in New Issue
Block a user