物料可以单独设置是否添加基础样式,可以和物料插件useBaseStyle配置组合使用#1238
物料可以单独设置是否添加基础样式,可以和物料插件useBaseStyle配置组合使用#1238chilingling merged 6 commits intoopentiny:developfrom
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant GN as generateNode
participant GM as getMaterial
Caller->>GN: Call generateNode({ type, component })
GN->>GM: Request material configuration
GM-->>GN: Return material config
GN->>GN: Combine global and material useBaseStyle flags
GN->>GN: Conditionally assign className in schema
GN-->>Caller: Return node schema
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
BWrong
left a comment
There was a problem hiding this comment.
物料可以单独设置是否添加基础样式,可以和物料插件useBaseStyle配置组合使用
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/plugins/materials/src/composable/useMaterial.ts (4)
466-487: Improved flexibility for material styling configurationThe reworked
generateNodefunction now provides more granular control over base styles through the material configuration. This is a good improvement that allows individual materials to opt-out of base styles when needed.Consider renaming
notUseBaseStyletoskipBaseStyleordisableBaseStyleto avoid double negation, which would make the logic more intuitive:- const notUseBaseStyle = material.configure?.notUseBaseStyle - const useBaseStyle = getOptions(meta.id).useBaseStyle && !notUseBaseStyle + const skipBaseStyle = material.configure?.skipBaseStyle + const useBaseStyle = getOptions(meta.id).useBaseStyle && !skipBaseStyle
468-471: Consider adding a safety check for the material objectThe current implementation could throw an error if
materialis undefined or null before accessingconfigure.Add a safety check to ensure
materialis defined:- const material = getMaterial(component) + const material = getMaterial(component) || {}This matches line 389 where
getMaterialreturns an empty object as a fallback.
471-478: Consider extracting the base style class name into a variableFor better maintainability and to avoid repeating the options getter.
Extract the repeated pattern into variables:
const useBaseStyle = getOptions(meta.id).useBaseStyle && !notUseBaseStyle + const componentBaseClassName = useBaseStyle ? getOptions(meta.id).componentBaseStyle.className : '' const schema = { componentName: component, ...snippet, props: { ...snippet.props, - className: useBaseStyle ? getOptions(meta.id).componentBaseStyle.className : '' + className: componentBaseClassName } }
481-484: Same pattern repeated for block typeSimilar to the previous comment, the same pattern of accessing options and checking
useBaseStyleis repeated.For consistency and to avoid repeating logic, consider refactoring:
if (type === 'block') { schema.componentType = 'Block' - schema.props.className = getOptions(meta.id).useBaseStyle ? getOptions(meta.id).blockBaseStyle.className : '' + schema.props.className = useBaseStyle ? getOptions(meta.id).blockBaseStyle.className : '' }This maintains consistency with how
useBaseStyleis used above and avoids re-evaluatinggetOptions(meta.id).useBaseStyle.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/plugins/materials/src/composable/useMaterial.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
BWrong
left a comment
There was a problem hiding this comment.
fix: 优化配置名称为useBaseStyle,保持和全局配置一致
BWrong
left a comment
There was a problem hiding this comment.
fix: 优化配置名称为useBaseStyle,保持和全局配置一致
|
|
…o pr/BWrong/1238

English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit