use DurationOptions[5].value to avoid using magic strings

This commit is contained in:
forgottener 2025-06-02 13:45:15 +08:00
parent 7580d653c2
commit 4d7db53f28

View File

@ -31,7 +31,7 @@ limitations under the License. -->
<div> <div>
<div class="label">{{ t("duration") }}</div> <div class="label">{{ t("duration") }}</div>
<Radio class="mb-5" :value="duration" :options="DurationOptions" @change="changeDuration" /> <Radio class="mb-5" :value="duration" :options="DurationOptions" @change="changeDuration" />
<div v-if="duration === 'custom'" class="custom-duration"> <div v-if="duration === DurationOptions[5].value" class="custom-duration">
<div class="label">{{ t("customDuration") }} ({{ t("seconds") }})</div> <div class="label">{{ t("customDuration") }} ({{ t("seconds") }})</div>
<el-input <el-input
size="small" size="small"
@ -154,7 +154,7 @@ limitations under the License. -->
async function createTask() { async function createTask() {
let finalDuration: number; let finalDuration: number;
if (duration.value === "custom") { if (duration.value === DurationOptions[5].value) {
if (!customDurationSeconds.value || customDurationSeconds.value < 1 || customDurationSeconds.value > 900) { if (!customDurationSeconds.value || customDurationSeconds.value < 1 || customDurationSeconds.value > 900) {
ElMessage.error("Please enter a valid duration between 1 and 900 seconds"); ElMessage.error("Please enter a valid duration between 1 and 900 seconds");
return; return;