refactor: format
TS Lint / ESLint (push) Has been cancelled
TS Lint / Oxlint (push) Has been cancelled
TS Lint / TypeScript (push) Has been cancelled

This commit is contained in:
2026-07-14 11:47:05 +02:00
parent 566f8403ef
commit a9b2e31d81
17 changed files with 432 additions and 183 deletions
+90 -18
View File
@@ -4,10 +4,10 @@ import { getCron, parseCron, validCron } from "@/lib/cron";
import { CronType } from "@/enums";
import { DEFAULT_CRON } from "@/constants";
const cron = defineModel<string|null>({ required: true });
const cron = defineModel<string | null>({ required: true });
const rawCron = ref<string>(DEFAULT_CRON);
const valid = ref<boolean>(true);
const props = defineProps<{editMode: boolean}>();
const props = defineProps<{ editMode: boolean }>();
const cronType = ref<CronType>(CronType.ONE_TIME);
const cronValue = ref<number>(0);
@@ -24,7 +24,7 @@ function updateCron() {
}
function onChangeCronType() {
switch(cronType.value) {
switch (cronType.value) {
case CronType.EVERY_DAY:
cronValue.value = 0;
break;
@@ -63,25 +63,97 @@ watch(cron, () => {
<template>
<div class="flex gap-2">
<select v-model="cronType" class="select" @change="onChangeCronType">
<option :value="CronType.ONE_TIME">{{ $t('cron.type.one_time') }}</option>
<option :value="CronType.EVERY_DAY">{{ $t('cron.type.every_day') }}</option>
<option :value="CronType.EVERY_WEEK">{{ $t('cron.type.every_week') }}</option>
<option :value="CronType.EVERY_MONTH">{{ $t('cron.type.every_month') }}</option>
<option :value="CronType.EVERY_YEAR">{{ $t('cron.type.every_year') }}</option>
<option :value="CronType.SPECIFIC">{{ $t('cron.type.specific') }}</option>
<option :value="CronType.ONE_TIME">
{{ $t("cron.type.one_time") }}
</option>
<option :value="CronType.EVERY_DAY">
{{ $t("cron.type.every_day") }}
</option>
<option :value="CronType.EVERY_WEEK">
{{ $t("cron.type.every_week") }}
</option>
<option :value="CronType.EVERY_MONTH">
{{ $t("cron.type.every_month") }}
</option>
<option :value="CronType.EVERY_YEAR">
{{ $t("cron.type.every_year") }}
</option>
<option :value="CronType.SPECIFIC">
{{ $t("cron.type.specific") }}
</option>
</select>
<select v-if="cronType === CronType.EVERY_DAY" v-model="cronValue" class="select" @change="onChangeCronValue">
<option v-for="i in Array.from(Array(24).keys())" :key="`h${i}`" :value="i">{{ i.toFixed(0).padStart(2, '0') }}:00</option>
<select
v-if="cronType === CronType.EVERY_DAY"
v-model="cronValue"
class="select"
@change="onChangeCronValue"
>
<option
v-for="i in Array.from(Array(24).keys())"
:key="`h${i}`"
:value="i"
>
{{ i.toFixed(0).padStart(2, "0") }}:00
</option>
</select>
<select v-if="cronType === CronType.EVERY_WEEK" v-model="cronValue" class="select" @change="onChangeCronValue">
<option v-for="i in Array.from(Array(7).keys())" :key="`w${i}`" :value="i + 1">{{ $t(`cron.week.${i.toFixed(0)}`) }}</option>
<select
v-if="cronType === CronType.EVERY_WEEK"
v-model="cronValue"
class="select"
@change="onChangeCronValue"
>
<option
v-for="i in Array.from(Array(7).keys())"
:key="`w${i}`"
:value="i + 1"
>
{{ $t(`cron.week.${i.toFixed(0)}`) }}
</option>
</select>
<select v-if="cronType === CronType.EVERY_MONTH" v-model="cronValue" class="select" @change="onChangeCronValue">
<option v-for="i in Array.from(Array(31).keys())" :key="`d${i}`" :value="i + 1">{{i + 1}}{{ i % 10 == 0 ? $t('cron.month.st') : (i % 10 === 1 ? $t('cron.month.nd'): (i % 10 === 2 ? $t('cron.month.rd') : $t('cron.month.th'))) }}</option>
<select
v-if="cronType === CronType.EVERY_MONTH"
v-model="cronValue"
class="select"
@change="onChangeCronValue"
>
<option
v-for="i in Array.from(Array(31).keys())"
:key="`d${i}`"
:value="i + 1"
>
{{ i + 1
}}{{
i % 10 == 0
? $t("cron.month.st")
: i % 10 === 1
? $t("cron.month.nd")
: i % 10 === 2
? $t("cron.month.rd")
: $t("cron.month.th")
}}
</option>
</select>
<select v-if="cronType === CronType.EVERY_YEAR" v-model="cronValue" class="select" @change="onChangeCronValue">
<option v-for="i in Array.from(Array(12).keys())" :key="`m${i}`" :value="i + 1">{{ $t(`cron.year.${i.toFixed(0)}`) }}</option>
<select
v-if="cronType === CronType.EVERY_YEAR"
v-model="cronValue"
class="select"
@change="onChangeCronValue"
>
<option
v-for="i in Array.from(Array(12).keys())"
:key="`m${i}`"
:value="i + 1"
>
{{ $t(`cron.year.${i.toFixed(0)}`) }}
</option>
</select>
<input v-if="cronType === CronType.SPECIFIC" v-model="rawCron" type="text" class="input font-mono" :class="valid ? '' : 'input-error'" @input="onInputRawCron" />
<input
v-if="cronType === CronType.SPECIFIC"
v-model="rawCron"
type="text"
class="input font-mono"
:class="valid ? '' : 'input-error'"
@input="onInputRawCron"
/>
</div>
</template>