feat(ui): cron-schedule 纯库 — 每天/每周/高级三模式 compose+parse#149
Merged
Conversation
新增 ui/lib/cron-schedule.ts(无 UI/React 依赖),为定时器 UI 重做打基础: - ScheduleState + composeCron(state)→cron|null + parseCron(cron)→state - 周日恒发 0 不发 7(nextFireTime 的 dow 匹配只认 0-6) - 非法输入返回 null 供调用方禁用保存按钮;parseCron 永不抛异常 - 往返一致性:daily/weekly 形状可等价还原 - ui/lib/cron-schedule.test.ts:往返 + 边界 + nextFireTime dow 逗号列表/dow=7 锁定测试
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
sweetcornna
added a commit
that referenced
this pull request
Jul 18, 2026
接入 #149/#151/#154 落地的库与组件: - 表格行换用 <QzoneJobRow>(run/edit/pause·resume/delete),删除旧内联行 - cron 手填换成 <QzoneSchedulePicker>(composeCron/parseCron) - 选中人格后显示 <QzoneRefImagePicker> 选参考图(image_ref_labels) - 新增发送抖动 jitter_minutes(0–120)输入 - 选中行就地回填编辑:parseCron 回填 picker、锁定人格、Save→Update、取消编辑 - saveMutation 按 editingName 分流 patch/create;enabled 交由行内 pause/resume - 删除走页面级 ConfirmDialog;启停按 enabled 分流 pause/resume - 保留一键启用每日说说 + next-fire 预览 - 新增 en+zh-CN 双份文案;新增页面测试 6 例 Co-authored-by: Cornna <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR-F1 — 纯 cron helper 库(无 UI 依赖)
为后续「定时器不手填 cron 表达式、改选触发时间」的 UI 重做打地基。本 PR 只落纯 lib + 测试,不动任何组件/页面。
新增文件
ui/lib/cron-schedule.ts— 纯库,零 UI/React 依赖ui/lib/cron-schedule.test.ts— vitest(24 测试)API
type ScheduleState = { mode: "daily" | "weekly" | "advanced"; time: "HH:MM"; weekdays: number[](0-6, 0=周日); raw: string }composeCron(state): string | nulldaily→M H * * *weekly→M H * * d,d,…advanced→ 原样返回rawnull(调用方据此禁用保存按钮)parseCron(cron): ScheduleState— 永不抛异常,把现有任务的 cron 反解回 picker 状态*/N/ 范围 / dom·month 非*→advanced(raw保留原串)* * *→daily;dow 为逗号整数列表 →weekly关键设计:周日恒发
0,绝不发7ui/lib/api/scheduler.ts的nextFireTime用Date.getDay()(只产 0-6)匹配 dow 字段,* * * * 7匹配不到任何真实日期 → 预览为「永不触发」。因此 compose 出向把7 → 0,parse 入向对7归一到0。测试里锁定了nextFireTime("0 12 * * 7") === null这一行为,作为该规则的依据。往返一致性
composeCron(parseCron(x))对 daily/weekly/advanced 形状还原等价表达式(7折叠为等价的0)。nextFireTime 现状确认
无需改其解析逻辑:它早已支持 dow 逗号列表(
matchesField按,拆分),30 21 * * 1,3,5现在就能预览。本 PR 只补锁定测试(逗号列表命中 +dow=0命中 +dow=7永不命中)。验证
pnpm typecheck→ 0 errorspnpm test→ 156 files / 1211 passed / 2 skipped(含 tailwind/globals-glass 守卫测试绿)pnpm lint→ 仅既有 warning,未触及本 PR 文件