npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue3-cron-ep

v1.0.5

Published

Vue3 + Element Plus 实现的 Cron 表达式生成器组件

Readme

vue3-cron-ep

基于 Vue 3 + Element Plus 的 Cron 表达式生插件,支持可视化配置、手动输入解析、实时校验和国际化。

特性

  • 支持 6 / 7 位 Cron 表达式
  • 支持可视化面板配置与手动输入解析
  • 支持日/周互斥、范围、步长、L、# 等格式校验
  • 内置中文、英文语言包
  • 支持 vue-i18n 命名空间接入,避免污染业务项目根翻译键
  • 支持组件级 locale/messages,未安装或未合并语言包时也有默认 fallback
  • 支持全局插件注册和局部组件使用

安装

npm install vue3-cron-ep
# 或
pnpm add vue3-cron-ep
# 或
yarn add vue3-cron-ep

需要在项目中安装并注册 Element Plus:

import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import Vue3CronEp from 'vue3-cron-ep'
import 'vue3-cron-ep/dist/index.css'
const app = createApp(App)
app.use(ElementPlus)
app.use(Vue3CronEp)
app.mount('#app')

基础使用

<template>
  <Vue3CronEp v-model="cronText" />
</template>

<script setup>
import { ref } from 'vue'
import { Vue3CronEp } from 'vue3-cron-ep'
import 'vue3-cron-ep/dist/index.css'

const cronText = ref('0 0 12 * * ?')
</script>

国际化

组件默认使用命名空间 vue3CronEp。推荐将语言包合并到业务项目的 vue-i18n 中,避免 secondconfirm 等通用 key 与业务翻译冲突。

推荐:创建 i18n 时合并

import { createI18n } from 'vue-i18n'
import { createCronI18nMessages } from 'vue3-cron-ep'

const i18n = createI18n({
  legacy: false,
  locale: 'zh-CN',
  fallbackLocale: 'en-US',
  messages: createCronI18nMessages()
})

app.use(i18n)

已有 i18n:安装时自动合并

import Vue3CronEp from 'vue3-cron-ep'
import { installCronI18n } from 'vue3-cron-ep'

installCronI18n(i18n)

app.use(Vue3CronEp)

也可以在注册插件时传入:

app.use(Vue3CronEp, {
  i18n,
  locale: 'zh-CN',
  fallbackLocale: 'en-US'
})

不接入 vue-i18n:组件级语言

<Vue3CronEp v-model="cronText" locale="en" />

自定义文案

app.use(Vue3CronEp, {
  i18n,
  messages: {
    'zh-CN': {
      cron: 'Cron 表达式',
      validation: {
        expressionLength: '请输入 6 位或 7 位 Cron 表达式'
      }
    }
  }
})

cron.js 校验结果国际化

validateCronvalidateSingleCronFieldcheckIllegal 支持传入国际化选项,适合业务项目直接调用工具函数:

import { validateCron, validateSingleCronField } from 'vue3-cron-ep'

validateCron('0 0 12 * * *', { locale: 'en-US' })
// {
//   valid: false,
//   code: 'dayWeekMutualExclusive',
//   message: 'Day and Week cannot both be specified. One of them must be ?'
// }

validateSingleCronField('70', 0, 59, { locale: 'zh-CN' })
// {
//   valid: false,
//   code: 'valueOutOfRange',
//   params: { min: 0, max: 59 },
//   message: '数值超出范围 0~59'
// }

如果你已经有 vue-i18nt 方法,也可以直接传入:

validateCron(value, {
  t: (key, params) => i18n.global.t(`vue3CronEp.${key}`, params)
})

如果你希望使用自定义命名空间:

app.use(Vue3CronEp, {
  i18n,
  i18nNamespace: 'myCron'
})

兼容旧用法

cronMessages 仍然导出扁平语言包,兼容旧项目手动合并:

import { cronMessages } from 'vue3-cron-ep'

const i18n = createI18n({
  legacy: false,
  locale: 'zh',
  fallbackLocale: 'en',
  messages: {
    zh: { ...cronMessages.zh },
    en: { ...cronMessages.en }
  }
})

新项目建议优先使用 createCronI18nMessages()installCronI18n()

API

Props

| 名称 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | modelValue | string | 0 0 12 * * ? | Cron 表达式,支持 v-model | | locale | string | 当前 i18n locale 或 zh-CN | 组件内部 fallback 使用的语言 | | messages | object | {} | 组件级自定义语言包 | | i18nNamespace | string | vue3CronEp | vue-i18n 命名空间 |

导出

| 名称 | 说明 | | --- | --- | | Vue3CronEp | 组件本体 | | cronMessages | 旧版扁平语言包 | | cronI18nMessages | 默认命名空间语言包 | | createCronI18nMessages(customMessages?, options?) | 创建可直接传给 vue-i18n 的语言包 | | createCronI18nConfig(options?) | 创建基础 vue-i18n 配置 | | installCronI18n(i18n, options?) | 向已有 vue-i18n 实例合并组件语言包 | | validateCron(cronText, options?) | 校验完整 Cron 表达式,支持国际化结果 | | validateSingleCronField(value, min, max, options?) | 校验单个 Cron 字段,支持国际化结果 | | translateCronValidation(result, options?) | 将校验错误码转换为本地化文案 |

License

MIT