-
Notifications
You must be signed in to change notification settings - Fork 8.3k
perf: 表单需要通过权限控制是否需要展示,dependencies.if 这种方式需要别triggerFields触发字段,不能满足要求 #6756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
WalkthroughA new optional boolean hide property is added to FormSchema and wired into FormField. Visibility computation and template gating now consider hide, preventing rendering when true. Documentation is updated accordingly. No other fields or behaviors are changed. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant FormRenderer as FormRenderer
participant FormField as FormField (component)
participant DOM as DOM
User->>FormRenderer: Provide schema (may include hide)
FormRenderer->>FormField: Pass props (hide, isIf, isShow, ...)
Note over FormField: Compute visible = !hide && isIf && isShow
alt hide is true OR visibility false
FormField-->>DOM: Do not render field
Note right of DOM: Validation/visibility logic bypassed
else
FormField->>DOM: Render field wrapper and content
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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. Comment |
There was a problem hiding this 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 (4)
packages/@core/ui-kit/form-ui/src/types.ts (1)
258-259: Clarify hide semantics and priority in JSDocLGTM adding
hide. To reduce ambiguity withdependencies.if/show, document thathidehas highest priority (hard hide: not rendered, not validated) and is intended for permission gating.Apply this diff to improve the comment:
- /** 是否隐藏表单项 */ + /** 是否隐藏表单项(最高优先级;为 true 时不渲染且不参与校验,适合权限控制) */ hide?: boolean;packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (2)
98-101: De-duplicate visibility logic: introduce isRendered to avoid driftKeep a single source of truth for render gating and derive
visiblefrom it. This preserves current behavior (CSS hide viaisShow) while making the code harder to regress.Apply this diff:
-const visible = computed(() => { - return !hide && isIf.value && isShow.value; -}); +const isRendered = computed(() => !hide && isIf.value); +const visible = computed(() => isRendered.value && isShow.value);Note: When using
hidefor permission gating, confirm whether retaining field values on unmount is desired. CurrentkeepValue: truepreserves values even after the field becomes hidden; if that’s not intended for permissions, we can add aclearOnHideoption or proactively clear the value on transition to hidden. Happy to provide a patch if needed.
287-288: Use the same computed for template gatingBind the template gate to
isRenderedto keep parity with script logic.Apply this diff:
- <FormField - v-if="!hide && isIf" + <FormField + v-if="isRendered"docs/src/components/common-ui/vben-form.md (1)
476-477: Document intent and precedence of hideSpell out that
hidehas the highest priority and is aimed at permission-driven hard hide (no render, no validation).Apply this diff:
- /** 是否隐藏表单项 */ + /** 是否隐藏表单项(最高优先级;true 时不渲染且不参与校验,适合权限控制) */ hide?: boolean;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
docs/src/components/common-ui/vben-form.md(1 hunks)packages/@core/ui-kit/form-ui/src/form-render/form-field.vue(3 hunks)packages/@core/ui-kit/form-ui/src/types.ts(1 hunks)
⏰ 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). (7)
- GitHub Check: Lint (windows-latest)
- GitHub Check: Test (windows-latest)
- GitHub Check: Check (ubuntu-latest)
- GitHub Check: Check (windows-latest)
- GitHub Check: Lint (ubuntu-latest)
- GitHub Check: post-update (windows-latest)
- GitHub Check: post-update (ubuntu-latest)
🔇 Additional comments (1)
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (1)
44-45: Prop plumbing looks correct
hideis correctly surfaced from schema into the component.
Summary by CodeRabbit
New Features
Documentation