提交 a41f3847 编写于 作者: B baiy 提交者: ninecents

修复 #27

上级 b5804c91
......@@ -3253,6 +3253,11 @@
"integrity": "sha1-3TeelPDbgxCwgpH51kwyCXZmF/0=",
"dev": true
},
"async-validator": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-3.4.0.tgz",
"integrity": "sha512-VrFk4eYiJAWKskEz115iiuCf9O0ftnMMPXrOFMqyzGH2KxO7YwncKyn/FgOOP+0MDHMfXL7gLExagCutaZGigA=="
},
"asynckit": {
"version": "0.4.0",
"resolved": "http://registry.npm.taobao.org/asynckit/download/asynckit-0.4.0.tgz",
......@@ -4680,18 +4685,18 @@
}
},
"cron-parser": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.15.0.tgz",
"integrity": "sha512-rMFkrQw8+oG5OuwjiXesup4KeIlEG/IU82YtG4xyAHbO5jhKmYaHPp/ZNhq9+7TjSJ65E3zV3kQPUbmXSff2/g==",
"version": "2.16.3",
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.16.3.tgz",
"integrity": "sha512-XNJBD1QLFeAMUkZtZQuncAAOgJFWNhBdIbwgD22hZxrcWOImBFMKgPC66GzaXpyoJs7UvYLLgPH/8BRk/7gbZg==",
"requires": {
"is-nan": "^1.3.0",
"moment-timezone": "^0.5.31"
}
},
"cronstrue": {
"version": "1.94.0",
"resolved": "https://registry.npmjs.org/cronstrue/-/cronstrue-1.94.0.tgz",
"integrity": "sha512-DW5OIfJwNGj9R8RCRGsFt0lxp0LKUl6BOElhaNAEkswwihbv6s867oKyOVgh/eQt1z90bBpelWMTR5/mGRB9Hw=="
"version": "1.100.0",
"resolved": "https://registry.npmjs.org/cronstrue/-/cronstrue-1.100.0.tgz",
"integrity": "sha512-Hz+xjjmq2QgCQhnPxIVM02dwhOt5GwUywjKa17je9JWX4z2E0uecObXCFap8bmJE87JL9mToW/cGw5O06JgigQ=="
},
"cross-spawn": {
"version": "6.0.5",
......@@ -4999,7 +5004,7 @@
},
"de-indent": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
"resolved": "https://registry.npm.taobao.org/de-indent/download/de-indent-1.0.2.tgz",
"integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=",
"dev": true
},
......@@ -5496,8 +5501,8 @@
},
"element-resize-detector": {
"version": "1.2.1",
"resolved": "https://registry.npm.taobao.org/element-resize-detector/download/element-resize-detector-1.2.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felement-resize-detector%2Fdownload%2Felement-resize-detector-1.2.1.tgz",
"integrity": "sha1-sDBRlER6SGMVXljxMyOgrvMIUdE=",
"resolved": "https://registry.npmjs.org/element-resize-detector/-/element-resize-detector-1.2.1.tgz",
"integrity": "sha512-BdFsPepnQr9fznNPF9nF4vQ457U/ZJXQDSNF1zBe7yaga8v9AdZf3/NElYxFdUh7SitSGt040QygiTo6dtatIw==",
"requires": {
"batch-processor": "1.0.0"
}
......@@ -8319,14 +8324,14 @@
"dev": true
},
"js-base64": {
"version": "2.6.3",
"resolved": "https://registry.npm.taobao.org/js-base64/download/js-base64-2.6.3.tgz?cache=0&sync_timestamp=1594230799738&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-base64%2Fdownload%2Fjs-base64-2.6.3.tgz",
"integrity": "sha1-ev25tXqncX4V03C2bo82qcuDXcM="
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz",
"integrity": "sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ=="
},
"js-calendar": {
"version": "1.2.3",
"resolved": "http://registry.npm.taobao.org/js-calendar/download/js-calendar-1.2.3.tgz",
"integrity": "sha1-pYOwZEtOaVujlPNE0QPbzHp6fT4="
"resolved": "https://registry.npmjs.org/js-calendar/-/js-calendar-1.2.3.tgz",
"integrity": "sha512-dAA1/Zbp4+c5E+ARCVTIuKepXsNLzSYfzvOimiYD4S5eeP9QuplSHLcdhfqFSwyM1o1u6ku6RRRCyaZ0YAjiBw=="
},
"js-levenshtein": {
"version": "1.1.6",
......@@ -9920,8 +9925,8 @@
},
"popper.js": {
"version": "1.16.1",
"resolved": "https://registry.npm.taobao.org/popper.js/download/popper.js-1.16.1.tgz",
"integrity": "sha1-KiI8s9x7YhPXQOQDcr5A3kPmWxs="
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz",
"integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ=="
},
"portfinder": {
"version": "1.0.25",
......@@ -10737,7 +10742,7 @@
"dependencies": {
"strict-uri-encode": {
"version": "2.0.0",
"resolved": "https://registry.npm.taobao.org/strict-uri-encode/download/strict-uri-encode-2.0.0.tgz",
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
"integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY="
}
}
......@@ -12754,6 +12759,11 @@
"integrity": "sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4=",
"dev": true
},
"v-click-outside-x": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/v-click-outside-x/-/v-click-outside-x-3.7.1.tgz",
"integrity": "sha512-WmUgmcIXr9clVpm1AYS/FgHtcDicfnfoxgQCNg4O6vfk9GVnxA0vSqO321ogUo0b7czYTidj7fQENvWFMWOkUg=="
},
"validate-npm-package-license": {
"version": "3.0.4",
"resolved": "http://registry.npm.taobao.org/validate-npm-package-license/download/validate-npm-package-license-3.0.4.tgz",
......@@ -12788,9 +12798,9 @@
}
},
"view-design": {
"version": "4.3.1",
"resolved": "https://registry.npm.taobao.org/view-design/download/view-design-4.3.1.tgz",
"integrity": "sha1-sPnfnaGqN/RG5aD2JB5elFMN5GA=",
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/view-design/-/view-design-4.3.2.tgz",
"integrity": "sha512-58GH2fu5TVtUeeXWWu0VQXqgV01fGKHXhViw4p80OM/+SzhCJS2qzZYYpVyXaGKQM1OfeJHZrVFA/xLfpXK+0w==",
"requires": {
"async-validator": "^3.3.0",
"deepmerge": "^2.2.1",
......@@ -12802,20 +12812,10 @@
"v-click-outside-x": "^3.7.1"
},
"dependencies": {
"async-validator": {
"version": "3.3.0",
"resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-3.3.0.tgz",
"integrity": "sha1-HZIZO75g1tbIskZpLHAF6e0UqO4="
},
"deepmerge": {
"version": "2.2.1",
"resolved": "https://registry.npm.taobao.org/deepmerge/download/deepmerge-2.2.1.tgz",
"integrity": "sha1-XT/yKgHAD2RUBaL7wX0HeKGAEXA="
},
"v-click-outside-x": {
"version": "3.7.1",
"resolved": "https://registry.npm.taobao.org/v-click-outside-x/download/v-click-outside-x-3.7.1.tgz",
"integrity": "sha1-qgPqoOQeRMtSB9z4bC2fDdZAhME="
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz",
"integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA=="
}
}
},
......@@ -12826,9 +12826,9 @@
"dev": true
},
"vue": {
"version": "2.6.11",
"resolved": "https://registry.npm.taobao.org/vue/download/vue-2.6.11.tgz",
"integrity": "sha1-dllNh31LEiNEBuhONSdcbVFBJcU="
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.12.tgz",
"integrity": "sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg=="
},
"vue-cli-plugin-iview": {
"version": "1.0.6",
......@@ -12903,9 +12903,9 @@
}
},
"vue-router": {
"version": "3.3.4",
"resolved": "https://registry.npm.taobao.org/vue-router/download/vue-router-3.3.4.tgz?cache=0&sync_timestamp=1593769516133&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-router%2Fdownload%2Fvue-router-3.3.4.tgz",
"integrity": "sha1-Tjirw0oRxBtsPYJERJouNjumJQs="
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.3.tgz",
"integrity": "sha512-BADg1mjGWX18Dpmy6bOGzGNnk7B/ZA0RxuA6qedY/YJwirMfKXIDzcccmHbQI0A6k5PzMdMloc0ElHfyOoX35A=="
},
"vue-style-loader": {
"version": "4.1.2",
......
......@@ -2,26 +2,20 @@
<div>
<Row :gutter="16">
<Col span="12">
<Input v-model="current.input" style="margin-bottom: 16px" class="page-option-input">
<span slot="prepend">{{ $t('crontab_expression') }}</span>
<Input v-model="current.input" style="margin-bottom: 16px">
<span slot="prepend">表达式</span>
</Input>
<heightResize :append="['.page-option-input']">
<autoHeightTextarea :value="output" :placeholder="$t('crontab_execute_time')"/>
</heightResize>
<Input :value="output" :rows="14" type="textarea" placeholder="最近执行时间"></Input>
</Col>
<Col span="12" class="page-option-reference">
<Col span="12">
<Tabs value="example">
<TabPane :label="$t('crontab_example')" name="example">
<heightResize :reduce="52" @resize="resize">
<Table stripe size="small" :height="referenceHeight" border :columns="example.columns"
:data="example.data"></Table>
</heightResize>
<TabPane label="例子" name="example">
<Table stripe size="small" height="300" :columns="example.columns" :data="example.data"></Table>
</TabPane>
<TabPane :label="$t('crontab_format')" name="format" style="text-align: center">
<img v-if="locale === 'zh_CN'" src="../../statics/crontab_cn.png" style="height: 300px" alt="">
<img v-else src="../../statics/crontab_en.png" style="height: 300px" alt="">
<TabPane label="格式" name="format" style="text-align: center">
<img src="../../statics/crontab.png" style="height: 300px" alt="">
</TabPane>
<TabPane :label="$t('crontab_symbol')" name="special">
<TabPane label="特殊字符" name="special">
<Table stripe size="small" height="300" :columns="special.columns" :data="special.data"></Table>
</TabPane>
</Tabs>
......@@ -30,31 +24,21 @@
</div>
</template>
<script>
import cronstrue from 'cronstrue/i18n';
import parser from 'cron-parser';
import moment from "moment"
import {getCurrentLocale} from "../../i18n";
import heightResize from "./components/heightResize";
import autoHeightTextarea from "./components/autoHeightTextarea";
import cronstrue from 'cronstrue/i18n';
import parser from 'cron-parser';
import moment from "moment"
export default {
components: {
heightResize,
autoHeightTextarea
},
export default {
computed: {
locale() {
return getCurrentLocale()
},
output() {
if (!this.current.input) return "";
let list = [];
try {
list.push(this.conversion(this.current.input));
list.push(`\n${this.$t('crontab_execute_time_list')}`);
list.push(cronstrue.toString(this.current.input, {locale: "zh_CN"}));
list.push("\n最近10次执行时间");
let interval = parser.parseExpression(this.current.input);
for (let i = 1; i <= 10; i++) {
list.push(this.$t('crontab_no', [i, moment(interval.next().toString()).format("YYYY-MM-DD HH:mm:ss")]))
list.push(`第${i}次: ` + moment(interval.next().toString()).format("YYYY-MM-DD HH:mm:ss"))
}
this.$saveToolData(this.current);
} catch (err) {
......@@ -65,88 +49,67 @@ export default {
},
},
created() {
this.$initToolData('input', (data) => {
try {
cronstrue.toString(data)
} catch {
return false
}
return true
})
this.example.data = this.example.data.map((item) => {
return {
example: item,
text: this.conversion(item)
}
})
},
methods: {
conversion(input) {
return cronstrue.toString(input, {locale: this.locale})
},
resize(height) {
this.referenceHeight = height
}
this.current = Object.assign(this.current, this.$getToolData())
},
data() {
return {
referenceHeight: 101,
current: {
input: "2 */5 * * 2-5"
input: "2 */5 * * 2-5",
operation: "check"
},
special: {
columns: [
{title: this.$t('crontab_symbol'), key: 'name', width: 100},
{title: this.$t('crontab_description'), key: 'text'},
{title: '特殊字符', key: 'name', width: 100},
{title: '代表意义', key: 'text'},
],
data: [
{
name: "*",
text: this.$t('crontab_symbol_description_1')
name: "*(星号)",
text: "代表任何时刻都接受的意思。举例来说,范例一内那个日、月、周都是*,就代表着不论何月、何日的礼拜几的12:00都执行后续命令的意思。"
},
{
name: ",",
text: this.$t('crontab_symbol_description_2')
name: ",(逗号)",
text: "代表分隔时段的意思。举例来说,如果要执行的工作是3:00与6:00时,就会是:0 3,6 * * * command时间还是有五列,不过第二列是 3,6 ,代表3与6都适用"
},
{
name: "-",
text: this.$t('crontab_symbol_description_3')
name: "-(减号)",
text: "代表一段时间范围内,举例来说,8点到12点之间的每小时的20分都进行一项工作:20 8-12 * * * command仔细看到第二列变成8-12.代表 8,9,10,11,12 都适用的意思"
},
{
name: "/n",
text: this.$t('crontab_symbol_description_4')
name: "/n(斜线)",
text: "那个n代表数字,即是每隔n单位间隔的意思,例如每五分钟进行一次,则:*/5 * * * * command用*与/5来搭配,也可以写成0-59/5,意思相同"
}
]
},
example: {
columns: [
{title: this.$t('crontab_example'), key: 'example', width: 120},
{title: this.$t('crontab_description'), key: 'text'},
{title: '例子', key: 'example', width: 120},
{title: '说明', key: 'text'},
],
data: [
"*/1 * * * *",
"* * * * *",
"*/5 * * * *",
"0 * * * *",
"0 */1 * * *",
"0 7 * * *",
"10 7 * * *",
"0 0 * * *",
"0 0 * * 0",
"0 0 1 * *",
"0 0 1 1 *",
"5 * * * *",
"30 5 * * *",
"30 7 8 * *",
"30 5 8 6 *",
"30 6 * * 0",
"30 3 10,20 * *",
"25 8-11 * * *",
"*/15 * * * *",
"30 6 */10 * *"
{example: "*/1 * * * *", text: "每1分钟执行"},
{example: "* * * * *", text: "每1分钟执行"},
{example: "*/5 * * * *", text: "每5分钟执行"},
{example: "0 * * * *", text: "每小时执行"},
{example: "0 */1 * * *", text: "每小时执行"},
{example: "0 7 * * *", text: "每天上午7点执行"},
{example: "10 7 * * *", text: "每天上午7点10分执行"},
{example: "0 0 * * *", text: "每天定时执行一次"},
{example: "0 0 * * 0", text: "每周定时执行一次"},
{example: "0 0 1 * *", text: "每月定时执行一次"},
{example: "0 0 1 1 *", text: "每年定时执行一次"},
{example: "5 * * * *", text: "指定每小时的第5分钟执行一次命令"},
{example: "30 5 * * *", text: "指定每天的 5:30 执行命令"},
{example: "30 7 8 * *", text: "指定每月8号的7:30分执行命令"},
{example: "30 5 8 6 *", text: "指定每年的6月8日5:30执行命令"},
{example: "30 6 * * 0", text: "指定每星期日的6:30执行命令"},
{example: "30 3 10,20 * *", text: "每月10号及20号的3:30执行命令[注:“,”用来连接多个不连续的时段]"},
{example: "25 8-11 * * *", text: "每天8-11点的第25分钟执行命令[注:“-”用来连接连续的时段"},
{example: "*/15 * * * *", text: "每15分钟执行一次命令 [即每个小时的第0 15 30 45 60分钟执行命令]"},
{example: "30 6 */10 * *", text: "每个月中,每隔10天6:30执行一次命令[即每月的1、11、21、31日是的6:30执行一次命令。]"}
]
}
}
}
}
}
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册