当前 ReportView 编辑报表时使用 DesignDrawer(Shadcn Sheet 覆盖层),而 DashboardView 已经采用了右侧固定内联配置面板的模式。需要将 ReportView 重构为与 DashboardView 一致的模式:编辑时配置面板固定在右侧,修改后左侧报表预览立即更新。
🎯 目标
参考 DashboardView (apps/console/src/components/DashboardView.tsx) 的实现模式,将 ReportView 的编辑体验从 Sheet 覆盖层重构为右侧内联固定面板 + 左侧实时预览。
✅ 修改细节清单
1. apps/console/src/components/ReportView.tsx — 主要重构
2. apps/console/src/__tests__/ReportView.test.tsx — 测试更新
3. packages/plugin-report/src/ReportConfigPanel.tsx — 无需修改(确认)
4. packages/plugin-report/src/__tests__/ReportConfigPanel.test.tsx — 无需修改(确认)
5. ROADMAP.md — 更新
6. 运行测试验证
📐 架构参考
DashboardView 模式(目标状态):
┌──────────────────────────────────────────────────┐
│ Header (title + Edit button) │
├───────────────────────┬──────────────────────────┤
│ │ Edit Report: Sales Report │
│ Report Preview │ Report › Configuration │
│ (ReportViewer) │ ┌─ BASIC ──────────────┐ │
│ — live updates — │ │ Title │ │
│ │ │ Description │ │
│ │ ├─ DATA ──────────────┤ │
│ │ │ Data source │ │
│ │ │ Row limit │ │
│ │ ├─ FILTERS ───────────┤ │
│ │ │ + Add filter │ │
│ │ ├─ GROUP BY ──────────┤ │
│ │ │ + Add sort │ │
│ │ ├─ EXPORT ────────────┤ │
│ │ ├─ SCHEDULE ──────────┤ │
│ │ ├─ APPEARANCE ────────┤ │
│ │ └────────────────────┘ │
└───────────────────────┴──────────────────────────┘
关键文件参考:
apps/console/src/components/DashboardView.tsx — 目标模式参考(L422-L465 主区域布局)apps/console/src/components/ReportView.tsx — 需要重构的文件packages/plugin-report/src/ReportConfigPanel.tsx — 已有的 config panel(无需改动)packages/components/src/custom/config-panel-renderer.tsx — 通用 ConfigPanelRenderer(CSS 已支持内联:sm:relative)
当前
ReportView编辑报表时使用DesignDrawer(Shadcn Sheet 覆盖层),而DashboardView已经采用了右侧固定内联配置面板的模式。需要将ReportView重构为与DashboardView一致的模式:编辑时配置面板固定在右侧,修改后左侧报表预览立即更新。🎯 目标
参考
DashboardView(apps/console/src/components/DashboardView.tsx) 的实现模式,将ReportView的编辑体验从 Sheet 覆盖层重构为右侧内联固定面板 + 左侧实时预览。✅ 修改细节清单
1.
apps/console/src/components/ReportView.tsx— 主要重构DesignDrawer导入和使用 — 删除import { DesignDrawer } from './DesignDrawer'和 L276-L295 的<DesignDrawer>组件handleCloseDrawer回调 — 删除 L69-L71 的handleCloseDrawercallback(不再需要onOpenChange模式)drawerOpen状态重命名为configPanelOpen— 与 DashboardView 命名一致(L26)configVersion状态计数器 —const [configVersion, setConfigVersion] = useState(0);用于稳定useConfigDraft的 config 引用,防止每次 live field change 时 draft 被重置handleOpenDrawer→handleOpenConfigPanel— 改为:setEditSchema(reportData); setConfigPanelOpen(true); setConfigVersion(v => v + 1);handleCloseConfigPanel回调 —setConfigPanelOpen(false);useAdapter引入和 auto-save helper — 从'../context/AdapterProvider'导入useAdapter,添加saveSchemacallback 用于调用adapter.update('sys_report', reportName!, schema)+refresh()handleReportConfigSave回调 — 保存 config 到 editSchema,调用saveSchema,递增configVersionhandleReportFieldChange回调 —setEditSchema(prev => ({ ...prev, [field]: value }))用于实时 live previewuseMemo基于configVersion计算reportConfig,防止useConfigDraftdraft reset(与 DashboardView 的dashboardConfig模式一致)previewReport计算 — 从drawerOpen && editSchema ? editSchema : reportData改为editSchema || reportData(编辑后关闭面板仍保持 preview 直到 metadata 刷新)<ReportConfigPanel>从<DesignDrawer>的 children render prop 改为直接渲染在 flex 布局中,作为<div className="flex-1 overflow-hidden flex flex-col sm:flex-row relative">的直接子元素ReportConfigPanel— 添加在左侧报表预览和MetadataPanel之间:useEffect在configPanelOpen === false时清除 staleeditSchema(与 DashboardView L155-L160 一致)reportName导航清理 —useEffect在reportName变化时重置editSchema、configPanelOpen(与 DashboardView L139-L145 一致)onClick从handleOpenDrawer改为handleOpenConfigPanel2.
apps/console/src/__tests__/ReportView.test.tsx— 测试更新config-paneltest-id 应存在于 DOM 中adapter.update被调用3.
packages/plugin-report/src/ReportConfigPanel.tsx— 无需修改(确认)ReportConfigPanel组件无需改动 — 已经基于ConfigPanelRenderer + useConfigDraft构建,openprop 控制渲染,内联布局由 CSSabsolute inset-y-0 right-0 sm:relative自动适配4.
packages/plugin-report/src/__tests__/ReportConfigPanel.test.tsx— 无需修改(确认)5.
ROADMAP.md— 更新ReportView: Refactored to left-right split layout (preview + DesignDrawer)更新为:ReportView: Refactored to inline right-side config panel (preview + ReportConfigPanel) — consistent with DashboardView inline config panel pattern6. 运行测试验证
pnpm test packages/plugin-report— 确保 ReportConfigPanel 相关 13+ 测试全部通过pnpm test apps/console/src/__tests__/ReportView— 确保 ReportView 集成测试通过pnpm test apps/console— 确保 Console 全部测试通过(无回归)pnpm build— 确保 43/43 builds passingpnpm test— 全局测试套件无回归📐 架构参考
DashboardView 模式(目标状态):
关键文件参考:
apps/console/src/components/DashboardView.tsx— 目标模式参考(L422-L465 主区域布局)apps/console/src/components/ReportView.tsx— 需要重构的文件packages/plugin-report/src/ReportConfigPanel.tsx— 已有的 config panel(无需改动)packages/components/src/custom/config-panel-renderer.tsx— 通用 ConfigPanelRenderer(CSS 已支持内联:sm:relative)