Skip to content

Commit fd8420b

Browse files
committed
docs: add custom cron expression
1 parent c065bde commit fd8420b

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<template>
2+
<v-app>
3+
<div class="mb-2">{{value}}</div>
4+
<CronLight v-model="value" :periods="periods" :fields="fields" @error="error=$event" :custom-locale="customLocale"></CronLight>
5+
</v-app>
6+
</template>
7+
8+
9+
10+
<script>
11+
12+
import core from '@vue-js-cron/core'
13+
const { locale, util } = core
14+
15+
export default {
16+
data() {
17+
18+
let defaultItems = locale.defaultItems('en')
19+
20+
return {
21+
value: '* * * * *',
22+
error: '',
23+
periods: [
24+
{ id: 'year', text: 'year', value: ['month', 'day', 'hour', 'minute', 'second'] },
25+
{ id: 'hour', text: 'hour', value: ['minute', 'second'] },
26+
{ id: 'minute', text: 'minute', value: ['second'] },
27+
{ id: 'second', text: 'second', value: [] },
28+
],
29+
fields: [
30+
{ id: 'second', items: util.genItems(0, 59)},
31+
{ id: 'minute', items: defaultItems.minuteItems},
32+
{ id: 'hour', items: defaultItems.hourItems},
33+
{ id: 'day', items: defaultItems.dayItems},
34+
{ id: 'month', items: defaultItems.monthItems},
35+
],
36+
customLocale: {
37+
eachPeriod: {
38+
secondField: {
39+
prefix: ':'
40+
}
41+
},
42+
hourPeriod: {
43+
minuteField: {
44+
prefix: 'at',
45+
suffix: '',
46+
empty: 'every minute'
47+
}
48+
},
49+
minutePeriod: {
50+
secondField: {
51+
prefix: 'at',
52+
suffix: 'second(s)',
53+
empty: 'every'
54+
}
55+
}
56+
}
57+
}
58+
},
59+
}
60+
</script>

docs/src/.vuepress/components/custom-periods.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<template>
22
<v-app>
33

4-
<CronVuetify v-model="value" :periods="periods" @error="error=$event"></CronVuetify>
4+
<div class="mb-2">{{value}}</div>
5+
<CronLight v-model="value" :periods="periods" @error="error=$event"></CronLight>
56

67
</v-app>
78
</template>

docs/src/.vuepress/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ module.exports = {
5858
collapsable: false,
5959
children: [
6060
'getting-started',
61-
'custom-periods'
61+
'custom-periods',
62+
'custom-fields'
6263
]
6364
}
6465
],

docs/src/guide/custom-fields.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Custom Cron Expression
2+
3+
<code-example title="cron expression with seconds">
4+
<template v-slot:source>
5+
6+
<<< @/src/.vuepress/components/custom-fields.vue
7+
8+
</template>
9+
<custom-fields />
10+
</code-example>

0 commit comments

Comments
 (0)