fix: add flag to fix css issue#1784
Conversation
WalkthroughThe changes introduce a new feature flag Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
d7c20c9 to
491f94d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/plugins/page/src/composable/usePage.ts (1)
126-137: Inconsistent CSS formatting between code paths.The
baseStylevariable (line 127) uses\r\nnewlines without trimming, whileformatCssRule(line 126) uses\nnewlines with trimming. WhenuseBaseStyleis falsy,baseStyleis returned; when truthy,formatCssRuleis used for the samepageBaseStyledata. This creates inconsistent output formatting.Additionally,
baseStyleis redundant whenuseBaseStyleis truthy sinceformatCssRuleis used instead.♻️ Suggested refactor for consistent formatting
- const formatCssRule = (className: string, style: string) => `.${className} {\n ${style.trim()}\n}\n` - const baseStyle = `.${pageOptions.pageBaseStyle.className}{\r\n ${pageOptions.pageBaseStyle.style}\r\n}\r\n` + const formatCssRule = (className: string, style: string) => `.${className} {\n ${style.trim()}\n}\n` + const baseStyle = formatCssRule(pageOptions.pageBaseStyle.className, pageOptions.pageBaseStyle.style) if (!materialsOptions.useBaseStyle) { return baseStyle } return [ - formatCssRule(pageOptions.pageBaseStyle.className, pageOptions.pageBaseStyle.style), + baseStyle, formatCssRule(materialsOptions.blockBaseStyle.className, materialsOptions.blockBaseStyle.style), formatCssRule(materialsOptions.componentBaseStyle.className, materialsOptions.componentBaseStyle.style) ].join('\n')🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/plugins/page/src/composable/usePage.ts` around lines 126 - 137, The code returns a differently formatted CSS string depending on materialsOptions.useBaseStyle because baseStyle uses CRLF and no trimming while formatCssRule uses LF and trims; to fix, remove the redundant hardcoded baseStyle and always produce page base CSS via formatCssRule(pageOptions.pageBaseStyle.className, pageOptions.pageBaseStyle.style) so both code paths use identical formatting, and ensure formatCssRule remains the single source of truth for generating CSS rules (update any return that currently uses baseStyle to call formatCssRule instead).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/settings/styles/src/components/classNamesContainer/index.vue`:
- Around line 462-464: The code is preemptively replacing double quotes with
single quotes before formatting which is redundant and can corrupt escaped
quotes; remove the content.replace(/"/g, "'") step and pass the raw content into
formatString so cssData is set via cssData = formatString(content, 'css')
(locate the assignment to cssData and the use of formatString in the
classNamesContainer component to update accordingly).
---
Nitpick comments:
In `@packages/plugins/page/src/composable/usePage.ts`:
- Around line 126-137: The code returns a differently formatted CSS string
depending on materialsOptions.useBaseStyle because baseStyle uses CRLF and no
trimming while formatCssRule uses LF and trims; to fix, remove the redundant
hardcoded baseStyle and always produce page base CSS via
formatCssRule(pageOptions.pageBaseStyle.className,
pageOptions.pageBaseStyle.style) so both code paths use identical formatting,
and ensure formatCssRule remains the single source of truth for generating CSS
rules (update any return that currently uses baseStyle to call formatCssRule
instead).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a6c1c353-5d7a-4c45-95e1-7fb7bb26f1ff
📒 Files selected for processing (3)
designer-demo/engine.config.jspackages/plugins/page/src/composable/usePage.tspackages/settings/styles/src/components/classNamesContainer/index.vue
English | 简体中文
PR
添加 css结构化 特性开关,临时解决 #1776 样式丢失问题
原始PR #1749
验证:https://hexqi.github.io/tiny-engine/?type=app&tenant=1
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
New Features
enableStructuredCssto control CSS processing behavior throughout the application.Configuration Changes