mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-02 18:41:35 +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,
|
language: "javascript" as const,
|
||||||
code: "",
|
code: "",
|
||||||
timeout: 10,
|
timeout: 10,
|
||||||
|
autoQueryInterval: 5,
|
||||||
codingPlanProvider: autoDetected,
|
codingPlanProvider: autoDetected,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -249,6 +250,7 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
|||||||
language: "javascript" as const,
|
language: "javascript" as const,
|
||||||
code: "",
|
code: "",
|
||||||
timeout: 10,
|
timeout: 10,
|
||||||
|
autoQueryInterval: 5,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +259,7 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
|||||||
language: "javascript" as const,
|
language: "javascript" as const,
|
||||||
code: PRESET_TEMPLATES[TEMPLATE_TYPES.GENERAL],
|
code: PRESET_TEMPLATES[TEMPLATE_TYPES.GENERAL],
|
||||||
timeout: 10,
|
timeout: 10,
|
||||||
|
autoQueryInterval: 5,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1061,7 +1064,10 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setScript({
|
setScript({
|
||||||
...script,
|
...script,
|
||||||
timeout: validateTimeout(e.target.value),
|
timeout:
|
||||||
|
e.target.value === ""
|
||||||
|
? (("" as unknown) as number)
|
||||||
|
: Number(e.target.value),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onBlur={(e) =>
|
onBlur={(e) =>
|
||||||
@@ -1085,14 +1091,15 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
|||||||
min={0}
|
min={0}
|
||||||
max={1440}
|
max={1440}
|
||||||
value={
|
value={
|
||||||
script.autoQueryInterval ?? script.autoIntervalMinutes ?? 0
|
script.autoQueryInterval ?? script.autoIntervalMinutes ?? 5
|
||||||
}
|
}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setScript({
|
setScript({
|
||||||
...script,
|
...script,
|
||||||
autoQueryInterval: validateAndClampInterval(
|
autoQueryInterval:
|
||||||
e.target.value,
|
e.target.value === ""
|
||||||
),
|
? (("" as unknown) as number)
|
||||||
|
: Number(e.target.value),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onBlur={(e) =>
|
onBlur={(e) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user