Skip to content

feat(week-date): ✨ 新增 WeekDate 周日期选择组件#1438

Open
North-al wants to merge 10 commits intoMoonofweisheng:masterfrom
North-al:feature/week-date
Open

feat(week-date): ✨ 新增 WeekDate 周日期选择组件#1438
North-al wants to merge 10 commits intoMoonofweisheng:masterfrom
North-al:feature/week-date

Conversation

@North-al
Copy link
Contributor

@North-al North-al commented Jan 6, 2026

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

组件场景

  • 预约/排班按周查看
  • 周计划、周统计数据切换
image image

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

发行说明

  • 新特性

    • 新增 WeekDate 周日期选择器组件:周选择、可配置周起始日、形状切换、禁用日期、选择/切换事件与图标插槽。
  • 文档

    • 添加中英文组件文档与演示页,包含用法示例、事件说明、类型与插槽示例。
  • Chores

    • 补充国际化文案、导航/页面条目与主题变量以支持新组件展示与样式定制。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 6, 2026

@North-al is attempting to deploy a commit to the weisheng's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5e17b2c
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/695ce4fd954fbc0008d1bba2
😎 Deploy Preview https://deploy-preview-1438--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

Walkthrough

新增 WeekDate 周日期选择器:包含 Vue SFC 组件、类型与导出、样式与主题变量、演示子页面、路由与导航项、本地化词条及中英文文档与示例页面(无现有 API 签名变更)。

Changes

Cohort / File(s) 变更摘要
文档 & 侧边栏
docs/component/week-date.md, docs/en-US/component/week-date.md, docs/.vitepress/locales/en-US.ts, docs/.vitepress/locales/zh-CN.ts
新增中/英文组件文档页,并在 VitePress 本地化侧边栏中插入 WeekDate 导航项。
演示页面 & 路由
src/pages.json, src/pages/index/Index.vue, src/subPages/weekDate/Index.vue
新增页面配置与主导航条目;添加子页面演示(多用例、事件、插槽、toast 示例)。
国际化资源
src/locale/en-US.json, src/locale/zh-CN.json
新增多条 WeekDate 相关中/英文本地化键值。
组件实现与类型导出
src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue, .../types.ts, .../index.ts
新增 wd-week-date Vue SFC(props/emits、周列表、翻周与选择逻辑);新增类型:WeekStartWeekDateItemWeekChangeEventweekDateProps;在 index.ts 中导出类型。
样式与主题变量
src/uni_modules/wot-design-uni/components/wd-week-date/index.scss, src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss, src/uni_modules/wot-design-uni/components/wd-config-provider/types.ts
新增组件 SCSS;在全局变量文件新增约 10 个 week-date 主题变量;在 ConfigProvider 类型中加入 weekDateThemeVars

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • 签名组件 #830 — 也新增输入类组件并修改站点导航/页面配置,与本次对 src/pages.json 和导航项的更改存在代码层面关联。

Suggested reviewers

  • Moonofweisheng

Poem

🐰 新周到来翩翩跳,七日排队暖心跳
文档示例仔细描,样式变量整齐包
选中翻周皆可报,插槽图标任意调 🎋

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题清晰准确地总结了主要变更:新增WeekDate周日期选择组件,与changeset的核心目的完全相符。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue:
- Line 71: WEEK_LABELS is hardcoded to Chinese and breaks i18n; replace the
constant with a locale-aware source by reading week day labels from your i18n
system or dayjs locale inside the wd-week-date component (e.g., derive labels
where WEEK_LABELS is used), e.g., create a computed/getter (used in the
template) that fetches localized weekday names from your i18n API or
dayjs.localeData().weekdaysMin() and use that instead of the static WEEK_LABELS
constant.
🧹 Nitpick comments (3)
docs/component/week-date.md (1)

45-88: 建议改进文档示例的变量命名

三个禁用日期的示例都使用了相同的变量名 value4,这可能让读者感到困惑。建议使用不同的变量名以提高文档清晰度。另外,示例中使用了 dayjs 但未展示导入语句。

💡 建议的改进方案

在第一个示例之前添加 dayjs 导入说明:

import dayjs from 'dayjs'

并为不同示例使用不同的变量名:

  • 禁用之前的日期:使用 value4
  • 禁用之后的日期:使用 value5valueAfter
  • 禁用星期三和星期五:使用 value6valueWeekdays
src/uni_modules/wot-design-uni/components/wd-week-date/types.ts (1)

2-2: 移除未使用的导入。

makeNumberPropnumericProp 已导入但未使用,建议移除以保持代码整洁。

🔎 建议修改
-import { baseProps, makeNumberProp, makeNumericProp, makeRequiredProp, makeStringProp, numericProp } from '../common/props'
+import { baseProps, makeNumericProp, makeRequiredProp, makeStringProp } from '../common/props'
src/subPages/weekDate/Index.vue (1)

91-101: Toast 消息使用了硬编码的中文字符串。

事件处理函数中的 Toast 消息(如 切换日期:日期:类型:)使用了硬编码的中文文本,与 demo-block 标题使用 $t() 进行国际化的方式不一致。此外,第 100 行的 as string 类型断言是多余的,因为 WeekChangeEvent.date 已经是 string 类型。

🔎 建议修改
 const handleSelect5 = (date: WeekDateItem) => {
-  success(`切换日期:${date.fullDate}`)
+  success(`${t('qie-huan-ri-qi')}:${date.fullDate}`)
 }

 const handleChange6 = (date: WeekChangeEvent) => {
-  success(`日期:${date.date},类型:${date.type}`)
+  success(`${t('ri-qi')}:${date.date},${t('lei-xing')}:${date.type}`)
 }

 const handleChange7 = (date: WeekChangeEvent) => {
-  success(`日期:${date.date},类型:${date.type}`)
-  value7.value = date.date as string
+  success(`${t('ri-qi')}:${date.date},${t('lei-xing')}:${date.type}`)
+  value7.value = date.date
 }
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b6833c and 70225d4.

📒 Files selected for processing (15)
  • docs/.vitepress/locales/en-US.ts
  • docs/.vitepress/locales/zh-CN.ts
  • docs/component/week-date.md
  • docs/en-US/component/week-date.md
  • src/locale/en-US.json
  • src/locale/zh-CN.json
  • src/pages.json
  • src/pages/index/Index.vue
  • src/subPages/weekDate/Index.vue
  • src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss
  • src/uni_modules/wot-design-uni/components/wd-config-provider/types.ts
  • src/uni_modules/wot-design-uni/components/wd-week-date/index.scss
  • src/uni_modules/wot-design-uni/components/wd-week-date/index.ts
  • src/uni_modules/wot-design-uni/components/wd-week-date/types.ts
  • src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-11-26T02:35:53.123Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 `wd-divider.vue` 文件(路径:`src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue`)中,`props.customStyle` 是字符串类型,用于传递自定义的样式字符串。

Applied to files:

  • docs/component/week-date.md
  • src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue
  • src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss
  • src/subPages/weekDate/Index.vue
📚 Learning: 2024-11-24T06:12:44.418Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue
  • src/subPages/weekDate/Index.vue
🪛 Biome (2.1.2)
src/pages.json

[error] 821-822: Expected a property but instead found '// #ifdef MP'.

Expected a property here.

(parse)


[error] 821-822: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 822-823: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 823-823: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 823-823: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 823-826: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 826-826: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 826-826: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 826-827: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 827-829: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Generate Test Summary
🔇 Additional comments (21)
docs/.vitepress/locales/en-US.ts (1)

263-265: LGTM!

WeekDate 导航项添加正确,位置合理,与其他组件条目保持一致。

src/uni_modules/wot-design-uni/components/wd-config-provider/types.ts (2)

1056-1067: LGTM!

weekDateThemeVars 类型定义完整,命名规范与其他组件主题变量保持一致,所有属性都正确设置为可选类型。


1137-1138: LGTM!

weekDateThemeVars 已正确集成到 ConfigProviderThemeVars 联合类型中,使得 WeekDate 组件可以通过 ConfigProvider 进行主题定制。

docs/.vitepress/locales/zh-CN.ts (1)

267-270: LGTM!

中文导航项添加正确,文案清晰,位置与英文版保持一致。

src/pages.json (1)

818-832: LGTM!

WeekDate 页面配置完整,遵循项目规范。静态分析工具报告的错误是误报,uni-app 的条件编译注释语法在 pages.json 中是合法的。

docs/component/week-date.md (4)

90-108: LGTM!

选择回调示例完整,展示了类型导入和事件处理的正确用法。


110-149: LGTM!

切换周事件的两个示例都很清晰,第二个示例特别好地展示了如何实现日期跟随切换的效果,并且提醒了不建议与 disabled-date 搭配使用的注意事项。


151-164: LGTM!

插槽使用示例清晰,展示了如何自定义左右切换按钮的图标。


166-211: LGTM!

API 文档完整且格式规范,属性表、事件表和类型定义都清晰易懂。外部样式类的定义符合项目规范。

src/uni_modules/wot-design-uni/components/wd-week-date/index.ts (1)

1-1: LGTM!

类型导出结构清晰,遵循了组件库的标准导出模式,方便消费者从模块入口直接导入所需类型。

src/pages/index/Index.vue (1)

167-170: LGTM!

新增的 weekDate 页面入口位置合理,与日历相关组件(calendar、calendarView)分组在一起,遵循了现有的列表结构模式。

src/uni_modules/wot-design-uni/components/wd-week-date/index.scss (1)

1-89: LGTM!

样式实现遵循了组件库的 BEM 命名规范和 mixin 使用模式。设计令牌(CSS 变量)的使用保证了主题一致性,过渡动画使状态切换更平滑。

docs/en-US/component/week-date.md (1)

1-215: LGTM!

文档结构完整,涵盖了组件的所有功能点。代码示例清晰易懂,API 表格详尽。特别是第 132 行关于 disabled-date 与日期跟随功能配合使用的警告说明很有价值。

src/uni_modules/wot-design-uni/components/wd-week-date/types.ts (1)

4-54: LGTM!

类型定义清晰完整,JSDoc 注释有助于开发者理解各属性的用途。WeekStartWeekDateItemWeekChangeEvent 的类型设计合理,与文档描述一致。

src/subPages/weekDate/Index.vue (1)

1-57: LGTM!

演示页面全面展示了 WeekDate 组件的各项功能,包括基础用法、周起始日配置、形状定制、多种禁用日期场景、事件处理和自定义插槽。结构清晰,便于开发者参考。

src/locale/zh-CN.json (1)

1664-1677: LGTM!

新增的 WeekDate 相关本地化键值完整,命名风格与现有条目保持一致。涵盖了组件导航、演示页面所需的所有文本。

src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue (3)

1-39: 模板结构清晰合理

组件模板设计良好,包含上一周/下一周按钮、周列表展示,并提供了插槽支持自定义图标。状态类绑定(active、disabled、circle)逻辑清晰。


127-155: 事件处理和资源清理实现良好

  • onSelect 方法正确地防止了禁用日期的选择
  • prevWeek/nextWeek 导航功能实现合理
  • onBeforeUnmount 中显式停止 watch 是良好的实践,虽然 Vue 3 会自动清理,但显式清理提高了代码的可维护性

87-92: 周起始日期计算逻辑验证完成,代码实现正确

周起始日期的计算公式 (day - weekStart + 7) % 7 经过验证所有场景都正确运行,无需修改。代码已正确处理以下情况:

  • 跨年/跨月边界:dayjs 的 subtract() 方法内部正确处理日期边界转换
  • 夏令时:组件在日期精度(非小时/分钟)下操作,不受 DST 影响
  • 时区:代码使用本地时间,无 UTC 转换需求

实现可以按现状保留。

src/locale/en-US.json (1)

1664-1676: 国际化资源添加完整

为 WeekDate 组件添加了完整的英文本地化资源,包括标题、属性说明和功能描述。翻译内容准确清晰,与现有的本地化资源风格保持一致。

src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss (1)

1026-1036: 样式变量定义规范

WeekDate 组件的样式变量定义完整且规范:

  • 遵循项目现有的命名约定 $-week-date-*
  • 正确使用 CSS 自定义属性支持主题定制
  • 默认值合理引用了共享的主题颜色变量(如 $-color-theme$-color-gray-5 等)
  • 变量覆盖了组件所需的所有视觉元素

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI Agents
In @src/locale/en-US.json:
- Around line 1665-1678: There are duplicate localization keys mapping to the
same value: remove the redundant key (either "week-date-title" or
"weekdate-zhou-ri-qi-xuan-ze") after confirming which one the codebase actually
references; search usages of both keys and keep the one that is used, deleting
the unused key from en-US.json. Also trim the trailing space in the
"qie-huan-ri-qi" value (change "Selected date: " to "Selected date:" unless the
space is intentionally required by downstream formatting) and run a quick
grep/IDE search to ensure no code depends on the trailing space.

In @src/locale/zh-CN.json:
- Around line 1665-1666: The two i18n keys use inconsistent prefixes:
"week-date-title" (with hyphen) and "weekdate-zhou-ri-qi-xuan-ze" (without
hyphen); rename the latter to "week-date-zhou-ri-qi-xuan-ze" to match the
"week-date-" prefix and update any code references that access
"weekdate-zhou-ri-qi-xuan-ze" (search for usages of that key) so all lookups use
the unified "week-date-" prefixed key.
🧹 Nitpick comments (1)
src/locale/zh-CN.json (1)

1668-1668: WeekDate 组件的命名需改进一致性,但不存在键冲突风险。

审查发现 "xing-zhuang""lei-xing" 这两个键在整个代码库中仅出现于 WeekDate 组件的本地化文件中,不存在与其他组件的键冲突。然而,WeekDate 组件内部的命名存在不一致性:某些键使用 week-date-weekdate- 前缀(如 "week-date-title""weekdate-zhou-ri-qi-xuan-ze"),而其他键则没有前缀。为了提高代码的可维护性和一致性,建议为所有组件特定的键添加统一的前缀。

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70225d4 and 2b38ac6.

📒 Files selected for processing (7)
  • docs/component/week-date.md
  • docs/en-US/component/week-date.md
  • src/locale/en-US.json
  • src/locale/zh-CN.json
  • src/subPages/weekDate/Index.vue
  • src/uni_modules/wot-design-uni/components/wd-week-date/types.ts
  • src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/uni_modules/wot-design-uni/components/wd-week-date/types.ts
  • docs/component/week-date.md
  • docs/en-US/component/week-date.md
  • src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue
  • src/subPages/weekDate/Index.vue
🔇 Additional comments (1)
src/locale/en-US.json (1)

1664-1664: 格式修改正确

在 "zuo-zhong" 条目后添加尾部逗号是必要的,因为后续添加了新的 WeekDate 本地化条目。JSON 语法正确。

Comment on lines +1665 to +1678
"week-date-title": "WeekDate",
"weekdate-zhou-ri-qi-xuan-ze": "WeekDate",
"qi-shi-zhou-qi-zhou-ri": "Start of Week (Sunday)",
"xing-zhuang": "Shape",
"jin-yong-ri-qi": "Disabled Date",
"jin-yong-zhi-qian-de-ri-qi": "Disable Dates Before Today",
"jin-yong-zhi-hou-de-ri-qi": "Disable Dates After Today",
"jin-yong-xing-qi-san-he-xing-qi-wu": "Disable Wednesday and Friday",
"xuan-ze-hui-diao": "Select Callback",
"qie-huan-zhou-shi-jian": "Week Change Event",
"qie-huan-zhou-ri-qi-gen-sui": "Week Change Date Follow",
"zi-ding-yi-tu-biao-cha-zhi": "Custom Icons (Slots)",
"qie-huan-ri-qi": "Selected date: ",
"lei-xing": "Type"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify duplicate keys and check the specific keys mentioned in the review

echo "=== Checking if src/locale/en-US.json exists ==="
if [ ! -f "src/locale/en-US.json" ]; then
  echo "File not found"
  exit 1
fi

echo "=== Extracting lines 1665-1678 to verify content ==="
sed -n '1665,1678p' src/locale/en-US.json

echo ""
echo "=== Checking for duplicate keys in entire JSON file ==="
jq -r 'keys[]' src/locale/en-US.json | sort | uniq -d

echo ""
echo "=== Searching for 'lei-xing' key in the entire file ==="
grep -n '"lei-xing"' src/locale/en-US.json

echo ""
echo "=== Searching for 'xing-zhuang' key in the entire file ==="
grep -n '"xing-zhuang"' src/locale/en-US.json

echo ""
echo "=== Checking values for 'week-date-title' and 'weekdate-zhou-ri-qi-xuan-ze' ==="
jq '.["week-date-title"], .["weekdate-zhou-ri-qi-xuan-ze"]' src/locale/en-US.json

echo ""
echo "=== Checking for trailing spaces in 'qie-huan-ri-qi' value ==="
jq '.["qie-huan-ri-qi"]' src/locale/en-US.json | od -c | head -20

Repository: Moonofweisheng/wot-design-uni

Length of output: 1286


🏁 Script executed:

#!/bin/bash
echo "=== Checking exact value of 'qie-huan-ri-qi' ==="
jq -r '.["qie-huan-ri-qi"]' src/locale/en-US.json | sed 's/$/[END]/' | cat -A

echo ""
echo "=== Checking exact value length ==="
jq -r '.["qie-huan-ri-qi"]' src/locale/en-US.json | wc -c

echo ""
echo "=== Double-checking all new keys to see if any others have trailing/leading spaces ==="
jq '.["week-date-title"], .["weekdate-zhou-ri-qi-xuan-ze"], .["qi-shi-zhou-qi-zhou-ri"], .["xing-zhuang"], .["jin-yong-ri-qi"], .["jin-yong-zhi-qian-de-ri-qi"], .["jin-yong-zhi-hou-de-ri-qi"], .["jin-yong-xing-qi-san-he-xing-qi-wu"], .["xuan-ze-hui-diao"], .["qie-huan-zhou-shi-jian"], .["qie-huan-zhou-ri-qi-gen-sui"], .["zi-ding-yi-tu-biao-cha-zhi"], .["qie-huan-ri-qi"], .["lei-xing"]' src/locale/en-US.json | cat -A

Repository: Moonofweisheng/wot-design-uni

Length of output: 556


移除重复的本地化键

发现两个键映射到相同值:"week-date-title""weekdate-zhou-ri-qi-xuan-ze" 都为 "WeekDate"。建议检查是否存在冗余,如确实重复,应删除其中一个。

此外,"qie-huan-ri-qi" 的值末尾包含空格("Selected date: "),请确认是否为必要。

🤖 Prompt for AI Agents
In @src/locale/en-US.json around lines 1665 - 1678, There are duplicate
localization keys mapping to the same value: remove the redundant key (either
"week-date-title" or "weekdate-zhou-ri-qi-xuan-ze") after confirming which one
the codebase actually references; search usages of both keys and keep the one
that is used, deleting the unused key from en-US.json. Also trim the trailing
space in the "qie-huan-ri-qi" value (change "Selected date: " to "Selected
date:" unless the space is intentionally required by downstream formatting) and
run a quick grep/IDE search to ensure no code depends on the trailing space.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/locale/zh-CN.json (1)

1667-1678: WeekDate 本地化键命名不一致,建议统一添加组件前缀。

部分 WeekDate 相关的键使用了 week-date- 前缀(如 week-date-titleweek-date-xing-zhuang),但包括 qi-shi-zhou-qi-zhou-rijin-yong-ri-qilei-xing 等在内的 11 个键缺少该前缀。建议为所有 WeekDate 组件相关的本地化键统一添加 week-date- 前缀,确保命名风格一致。

需要更新的位置:

  1. src/locale/zh-CN.jsonsrc/locale/en-US.json 中的键名
  2. src/subPages/weekDate/Index.vue 中对应的 $t() 调用
🔎 建议的修复方案
-"qi-shi-zhou-qi-zhou-ri": "起始周期(周日)",
+"week-date-qi-shi-zhou-qi-zhou-ri": "起始周期(周日)",
 "week-date-xing-zhuang": "WeekDate 形状",
-"jin-yong-ri-qi": "禁用日期",
-"jin-yong-zhi-qian-de-ri-qi": "禁用之前的日期",
-"jin-yong-zhi-hou-de-ri-qi": "禁用之后的日期",
-"jin-yong-xing-qi-san-he-xing-qi-wu": "禁用星期三和星期五",
-"xuan-ze-hui-diao": "选择回调",
-"qie-huan-zhou-shi-jian": "切换周事件",
-"qie-huan-zhou-ri-qi-gen-sui": "切换周日期跟随",
-"zi-ding-yi-tu-biao-cha-zhi": "自定义图标(插槽)",
-"qie-huan-ri-qi": "切换日期:",
-"lei-xing": "类型"
+"week-date-jin-yong-ri-qi": "禁用日期",
+"week-date-jin-yong-zhi-qian-de-ri-qi": "禁用之前的日期",
+"week-date-jin-yong-zhi-hou-de-ri-qi": "禁用之后的日期",
+"week-date-jin-yong-xing-qi-san-he-xing-qi-wu": "禁用星期三和星期五",
+"week-date-xuan-ze-hui-diao": "选择回调",
+"week-date-qie-huan-zhou-shi-jian": "切换周事件",
+"week-date-qie-huan-zhou-ri-qi-gen-sui": "切换周日期跟随",
+"week-date-zi-ding-yi-tu-biao-cha-zhi": "自定义图标(插槽)",
+"week-date-qie-huan-ri-qi": "切换日期:",
+"week-date-lei-xing": "类型"

同步更新 src/subPages/weekDate/Index.vue 中的 $t() 调用和 en-US.json 中对应的键名。

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b38ac6 and 57f9e43.

📒 Files selected for processing (4)
  • src/locale/en-US.json
  • src/locale/zh-CN.json
  • src/pages/index/Index.vue
  • src/subPages/weekDate/Index.vue
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/pages/index/Index.vue
  • src/subPages/weekDate/Index.vue
  • src/locale/en-US.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-24T06:12:44.418Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。

Applied to files:

  • src/locale/zh-CN.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: ESLint Check
🔇 Additional comments (1)
src/locale/zh-CN.json (1)

1665-1666: 命名前缀已修复 ✓

之前评审指出的前缀不一致问题已得到解决,Line 1666 的键名已从 weekdate-zhou-ri-qi-xuan-ze 更正为 week-date-zhou-ri-qi-xuan-ze,与 week-date-title 保持了一致的连字符格式。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/uni_modules/wot-design-uni/components/wd-week-date/types.ts (1)

48-48: 建议验证 weekStart 的运行时校验。

weekStart 的 TypeScript 类型已限定为 0 或 1,但 makeNumericProp 在运行时可能接受任意数字。建议在组件内部添加运行时校验,确保只接受 0(周日)或 1(周一)。

可通过以下脚本检查是否已有相关校验:

#!/bin/bash
# 描述:检查 weekStart 的运行时校验逻辑

# 搜索组件中对 weekStart 的使用和校验
rg -n -C5 'weekStart' --type=vue --type=ts -g '**/wd-week-date/**'
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57f9e43 and 5e17b2c.

📒 Files selected for processing (2)
  • src/uni_modules/wot-design-uni/components/wd-week-date/types.ts
  • src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/uni_modules/wot-design-uni/components/wd-week-date/wd-week-date.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test Components (wd-config-provider)
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
🔇 Additional comments (2)
src/uni_modules/wot-design-uni/components/wd-week-date/types.ts (2)

13-33: 类型定义清晰完善!

WeekStart、WeekDateItem 和 WeekChangeEvent 三个类型定义结构合理,字段注释详尽,完全符合周日期选择器的业务场景需求。


40-40: 无需修改,modelValue 类型处理已正确实现。

组件在 normalizeDate 函数中(wd-week-date.vue 第 68-81 行)已完整处理了所有三种类型:

  • 通过 dayjs(value) 正确转换 Number(时间戳)、String(日期字符串)和 Date 对象
  • 使用 isValid() 验证日期有效性
  • 提供 console.warn 警告机制处理无效日期
  • 返回规范化的日期对象或 null 作为安全降级

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant