Repository navigation
Conversation
lnuxe
requested review from
anlyyao,
chaishi,
liweijie0812 and
uyarn
as code owners
December 3, 2026 03:01
1 of 11 tasks
lnuxe
added a commit
to lnuxe/tdesign-vue
that referenced
this pull request
Dec 3, 2026
上一版把 'normal' 一并加进了 validator 白名单,依据是 constants.ts 的 STATUS_TEXT 含该值。复核后不成立: - 全仓没有 status--normal 样式,只有 success/error/warning 的图标与颜色分支 - STATUS_TEXT 这个导出没有任何调用方,测试里另写了一份不含 normal 的副本 - API 文档(progress.md)从未列过 normal 也就是说加进去的是个无行为取值,等于给规范引入空壳。收窄为只接受空字符串 (issue Tencent#3470 的诉求就是 status='' 不告警),normal 用例一并移除。 status 的默认值改到上游定义解决:TDesignOteam/tdesign-api#1091。
lnuxe
added a commit
to lnuxe/tdesign-vue
that referenced
this pull request
Dec 3, 2026
status 的 validator 只允许 success/error/warning/active,模板里常见的 :status="percent >= 100 ? 'success' : ''" 在进度未满时会报 [Vue warn]: Invalid prop: custom validator check failed for prop "status"。 白名单加入空字符串,表示不设置状态(issue Tencent#3470 的诉求)。 不包含 'normal':组件里 STATUS_TEXT 虽然含该值,但全仓没有对应的 status--normal 样式,该导出也没有任何调用方引用,API 文档从未列过它, 加进去等于给规范引入一个无行为的取值。 注:本文件是自动生成产物,源定义已另行修复 —— TDesignOteam/tdesign-api#1091 给 Progress.json 的 status 补上 field_default_value,从生成侧根治。
Progress 的 status 在 API 定义里没有 field_default_value,生成出来的 props.ts 只声明了 validator 白名单,既没有 default,也没有 falsy 直接放行的守卫。 模板里常见的 :status="percent >= 100 ? 'success' : ''" 因此会在控制台报 [Vue warn]: Invalid prop: custom validator check failed for prop "status"。 在 packages/data/Progress.json 给 status 补上 field_default_value: "''" (与同组件的 color 写法一致),并重新生成 6 个平台的产物: - props.ts / defaultProps.ts 得到空字符串默认值 - type.ts 与 API 文档(progress.md / README.md)同步标注默认值 校验白名单保持不变 —— 组件里 STATUS_TEXT 虽然含 'normal',但它既无对应样式 也无任何引用,不纳入本次改动。 关联 issue: Tencent/tdesign-vue#3470
lnuxe
force-pushed
the
fix/progress-status-default
branch
from
December 3, 2026 03:09
96a22f3 to
a70beb0
Compare
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 的性质是?
问题
Progress的status在 API 定义里没有field_default_value(packages/data/Progress.json,id 924),生成出来的props.ts因此只有 validator 白名单,既没有default,也拿不到生成器对「带默认值的枚举字段」自动追加的if (!val) return true守卫。结果:模板里常见的写法
进度未满时
status为'',控制台报:对照:同组件的
color定义里有field_default_value: "''",生成出来就带default: '';size、theme同理。修复
在
packages/data/Progress.json给status补上"field_default_value": "''",再重新生成 spec 覆盖的 6 个平台产物。定义变更:
"field_type": [ "String" ], + "field_default_value": "''", "field_enum": [ "success", "error", "warning", "active" ],生成结果(以
tdesign-vue为例):status: { type: String as PropType<TdProgressProps['status']>, + default: '' as TdProgressProps['status'], validator(val: TdProgressProps['status']): boolean { if (!val) return true; return ['success', 'error', 'warning', 'active'].includes(val); }, },为什么改源定义而不是改生成产物
packages/products/**是脚本自动生成的,文件头标注「请勿随意修改」。只改产物会在下次生成时被覆盖;改packages/data/Progress.json才不会掉。范围
validator白名单不变。组件里的STATUS_TEXT虽然含'normal',但它既没有对应的status--normal样式,也没有任何调用方引用,加了等于给规范引入一个无行为的取值,故不纳入。Vue(PC)/React(PC)/Vue(Mobile)/React(Mobile)/Miniprogram/UniApp。status默认值相关的行,未夹带生成器的排版差异(import type风格、英文文档全角/半角标点)。关联