Просмотр исходного кода

docs: 添加智页面重构和组件提取实施计划

Xiaogang Liao 4 месяцев назад
Родитель
Сommit
05faadf32a
2 измененных файлов с 210 добавлено и 0 удалено
  1. 104 0
      docs/extract-dimension-components.md
  2. 106 0
      docs/redesign-wisdom-page.md

+ 104 - 0
docs/extract-dimension-components.md

@@ -0,0 +1,104 @@
+# extract-dimension-components - Work Plan
+
+## TL;DR (For humans)
+
+**What you'll get:** A reusable `DimensionArticles.vue` component that any dimension page (身/智/心/行/富) can drop in to show dimension-filtered articles. It follows the exact same pattern as the existing DimensionTasks/DimensionActivities/DimensionProducts components — self-loading, configurable by `dimensionCode`, with "更多" link and article click events.
+
+**Why this approach:** The article section is currently inline in wisdom/index.vue — duplicated logic that every other dimension page would need to copy. Extracting it into a component follows the consistent Dimension* pattern already used for tasks, activities, and products, which are already shared across 9-14+ files each. No changes needed to existing components.
+
+**What it will NOT do:** Change the wisdom page layout (that's the companion plan `redesign-wisdom-page`). Modify existing components. Touch backend or routes.
+
+**Effort:** Quick
+**Risk:** Low — straightforward new component following an established 10-file-strong pattern
+**Decisions to sanity-check:** Whether articles should load internally (self-contained) or receive data as props — default is self-loading consistent with DimensionTasks.vue
+
+Your next move: **Approve** this plan, or run a high-accuracy review. Can run before or independently of the `redesign-wisdom-page` plan.
+
+---
+
+> TL;DR (machine): Quick, Low — create DimensionArticles.vue following existing Dimension* pattern. Self-loads articles filtered by dimensionCode. 1 todo.
+
+## Scope
+### Must have
+- Create `cfc-frontend/components/DimensionArticles.vue`
+- Component accepts `dimensionCode` prop (String, required)
+- Component loads articles on mount via `getFeaturedArticles({size:5})` from `../../utils/api.js`
+- Component filters articles by `relatedDimensions.indexOf(dimensionCode) !== -1`
+- Component displays max 5 articles with: category badge, title, summary, view count, date
+- Component emits `@moreArticles` when "更多" is clicked
+- Component emits `@articleClick(article)` when a card is tapped
+- Vue 2 Options API, no CSS Grid, no `?.`
+- Component self-contained — works on any dimension page
+
+### Must NOT have (guardrails, anti-slop, scope boundaries)
+- No changes to wisdom/index.vue or any other page (that's companion plan)
+- No changes to existing Dimension* components
+- No backend changes
+- No pages.json changes
+- No new dependencies
+- No CSS Grid (flexbox only)
+- No optional chaining `?.`
+- No inline external data loading beyond `getFeaturedArticles`
+
+## Verification strategy
+> Zero human intervention - all verification is agent-executed.
+- Test decision: tests-after (file existence + grep-based assertions)
+- Evidence: `.omo/evidence/task-1-dimension-articles-created.txt`
+
+## Execution strategy
+### Waves
+- **Wave 1** (1 todo): Create DimensionArticles.vue
+- **Wave 2** (1 todo): Verify compilation
+
+### Dependency matrix
+| Todo | Depends on | Blocks | Can parallelize with |
+| --- | --- | --- | --- |
+| T1. Create DimensionArticles.vue | — | T2 | — |
+| T2. Verify frontend compilation | T1 | — | — |
+
+## Todos
+- [ ] 1. Create DimensionArticles.vue component
+  What to do / Must NOT do: Create file `/app/cfc/cfc-frontend/components/DimensionArticles.vue`. Template: section with header "推荐阅读" + "更多" link → article card list. Each card shows: category badge (categoryName with color), title, summary (clamped), view count, publishedAt date. "更多" emits `@moreArticles`. Card tap emits `@articleClick(article)`. Empty state when no articles. Script: props `dimensionCode` (String, required), data `articles` (Array), `loading` (Boolean). On mount call `loadArticles()` method that calls `getFeaturedArticles({size: 5})`, filters `relatedDimensions` by `dimensionCode`. Style: scoped, flexbox only, no CSS Grid. Must NOT use `?.`. Must NOT use `display: grid`. Must NOT reference wisdom-specific data.
+  Parallelization: Wave 1 | Blocked by: — | Blocks: T2
+  References:
+    - Pattern to follow: `/app/cfc/cfc-frontend/components/DimensionTasks.vue` (1-148) — self-contained component, dimensionCode prop, loadTasks, emit pattern
+    - Article data shape: `wisdom/index.vue` lines 478-504 — API returns array of `{id, categoryName, title, summary, viewCount, publishedAt, relatedDimensions}`
+    - Existing article card UI: `wisdom/index.vue` lines 137-161 — category badge, title, summary, meta (views, date)
+    - Existing filter logic: `wisdom/index.vue` lines 264-275 — `relatedDimensions.indexOf('wisdom') !== -1`
+    - API import: `/app/cfc/cfc-frontend/utils/api.js` line 1175 — `export const getFeaturedArticles`
+  Acceptance criteria (agent-executable):
+    - File exists at `cfc-frontend/components/DimensionArticles.vue`
+    - Grep `\bprops\b` and `dimensionCode` present in file
+    - Grep `getFeaturedArticles` present in file
+    - Grep `relatedDimensions` present in file
+    - Grep `moreArticles` present in file (event emit)
+    - Grep `articleClick` present in file (event emit)
+    - Grep `\?\.` returns empty
+    - Grep `display:\s*grid` returns empty
+  QA scenarios:
+    - Happy: Read file and verify props/computed/methods match established pattern
+    - Structural: Verify template has section-header with "更多" link and article card loop
+    - Evidence: `.omo/evidence/task-1-dimension-articles-created.txt`
+  Commit: Y | `feat(frontend): 创建 DimensionArticles 组件,可复用维度文章卡片`
+
+- [ ] 2. Verify frontend compilation
+  What to do / Must NOT do: Run `npm run build:mp-weixin` from `/app/cfc/cfc-frontend/`. Exit 0.
+  Parallelization: Wave 2 | Blocked by: T1 | Blocks: —
+  References: `cfc-frontend/AGENTS.md`
+  Acceptance criteria: build exits 0, no compilation errors
+  QA: Capture output to `.omo/evidence/task-2-build-output.txt`
+  Commit: N
+
+## Final verification wave
+- [ ] F1. Plan compliance — DimensionArticles.vue exists with all required features
+- [ ] F2. Code quality — no `?.`, no CSS Grid, Vue 2 Options API
+- [ ] F3. Scope fidelity — no wisdom/index.vue or other page changes, no existing component changes
+
+## Commit strategy
+- Todo 1: `feat(frontend): 创建 DimensionArticles 组件,可复用维度文章卡片`
+
+## Success criteria
+1. `cfc-frontend/components/DimensionArticles.vue` exists
+2. Component can be added to any dimension page via `<DimensionArticles dimensionCode="X" />`
+3. Component renders dimension-filtered articles with "更多" link
+4. Frontend builds without errors

+ 106 - 0
docs/redesign-wisdom-page.md

@@ -0,0 +1,106 @@
+# redesign-wisdom-page - Work Plan
+
+## TL;DR (For humans)
+
+**What you'll get:** The "智" (wisdom) tab page gets a clearer, more visual layout: a cognitive 6-dimension radar chart replaces the old text summary, and the page removes clutter (extra highlight cards, tips section, bottom buttons) so the content flow is: energy bar → radar chart → member graph → quick entry → 4 content cards. The 4 content cards (tasks/activities/products/articles) remain inline for now — extracting them into a shared component is done in the companion plan `extract-dimension-components`.
+
+**Why this approach:** The existing `RadarChart.vue` component is already used on the "心" (mind) page and works perfectly — reusing it saves effort and ensures consistency. Splitting the page restructure and component extraction into two plans keeps each unit of work focused and independently verifiable.
+
+**What it will NOT do:** Create any new components (that's the companion plan). Change backend code. Modify existing component files (RadarChart, DimensionTasks, etc.). Touch page routing/pages.json.
+
+**Effort:** Short
+**Risk:** Low — mostly removing code sections and reordering, with RadarChart integration following an established pattern from mind/index.vue
+**Decisions to sanity-check:** RadarChart fill color for wisdom brand (`#6366F1`), "更多" navigation targets for each content card
+
+Your next move: **Approve** this plan, or ask for a high-accuracy review first. Companion plan `extract-dimension-components` can run before or after this one.
+
+---
+
+> TL;DR (machine): Short, Low — Frontend-only restructure of wisdom/index.vue: RadarChart integration with 6 cognitive dimensions, reorder to new layout, remove 5 obsolete sections, cleanup. No component creation. 2 todos.
+
+## Scope
+### Must have
+- Add RadarChart section showing 6 cognitive dimensions (感知/专注/记忆/逻辑/空间/加工速度) from assessment data
+- Reorder sections to: PageBanner → LoginGuideCard → FamilyEnergyBar → RadarChart → FamilyRelationGraph → UserQuickEntry → func-grid → DimensionTasks → DimensionActivities → DimensionProducts → article-list (inline)
+- Remove sections: 认知概览(7), 自己出题card(8), 训练中心card(9), 智慧小贴士(14), 快捷操作(15)
+- Remove associated data, computed, methods, styles
+- Verify frontend compiles without errors
+
+### Must NOT have (guardrails, anti-slop, scope boundaries)
+- No new component creation (DimensionArticles done in companion plan)
+- No backend changes
+- No modifications to existing components (RadarChart.vue, DimensionTasks.vue, DimensionActivities.vue, DimensionProducts.vue, PageBanner.vue, FamilyEnergyBar.vue, FamilyRelationGraph.vue, UserQuickEntry.vue)
+- No CSS Grid usage (use flexbox per mini-program constraint)
+- No optional chaining `?.` (use `&&` alternative)
+- No pages.json routing changes
+- No new dependencies
+
+## Verification strategy
+> Zero human intervention - all verification is agent-executed.
+- Test decision: tests-after (compilation check)
+- Evidence: build output + grep-based assertions on modified file
+
+## Execution strategy
+### Waves
+- **Wave 1** (1 todo): Todo 1 — restructure wisdom/index.vue (RadarChart, reorder, cleanup)
+- **Wave 2** (1 todo): Todo 2 — verify compilation
+
+### Dependency matrix
+| Todo | Depends on | Blocks | Can parallelize with |
+| --- | --- | --- | --- |
+| T1. Restructure wisdom/index.vue | — | T2 | — |
+| T2. Verify frontend compilation | T1 | — | — |
+
+## Todos
+- [ ] 1. Restructure wisdom/index.vue — RadarChart, layout reorder, cleanup
+  What to do / Must NOT do: Modify ONLY `cfc-frontend/pages/wisdom/index.vue`. The changes:
+    (a) ADD imports: `RadarChart from '../../components/RadarChart.vue'`
+    (b) ADD to `components: {}`: `RadarChart`
+    (c) ADD computed properties `cognitiveDimensions` (array of 6 {label, key}) and `cognitiveScores` (array of 6 scores from cognitiveReport) mapping the 6 cognitive dimensions. Keys: perceptionScore, focusScore, memoryScore, logicScore, spatialScore, processingSpeedScore. Labels: 感知能力, 专注力, 记忆力, 逻辑思维, 空间思维, 加工速度.
+    (d) REORDER template sections to: 1.PageBanner → 2.LoginGuideCard → 3.FamilyEnergyBar → 4.RadarChart (NEW: `<view class="section"><view class="section-header"><text class="section-title">认知雷达</text><text class="section-more" @click="goCognitiveReport">查看详情 ›</text></view><RadarChart :dimensions="cognitiveDimensions" :scores="cognitiveScores" :childName="activeChildName" fillColor="#6366F1" gridColor="#E0E7FF" labelColor="#3730A3" /></view>`) → 5.FamilyRelationGraph → 6.UserQuickEntry → 7.func-grid → 8.DimensionTasks → 9.DimensionActivities → 10.DimensionProducts → 11.article-list (keep inline, just reposition)
+    (e) REMOVE template sections: 认知概览(lines 62-84), 自己出题card(lines 86-98), 训练中心card(lines 100-112), 智慧小贴士(lines 163-174), 快捷操作(lines 176-190), bottom-spacer(lines 192-194)
+    (f) REMOVE from `<script>`: `WisdomTips` import (line 201), `lowestDimension` data (line 223-226 — partial of data block), `wisdomTips[]` data (lines 238-243), `loadCognitiveReport()` method (lines 359-368), `findLowestDimension()` method (lines 370-388), `WisdomTips` from components registration (line 211), `lowestDimension` ref in computed (lines 223-226)
+    (g) REMOVE from `<style>`: `.cognition-summary`, `.cognition-empty`, `.summary-*`, `.cognition-*`, `.highlight-card`, `.highlight-*`, `.tips-list`, `.tip-card`, `.tip-*`, `.quick-actions`, `.action-*`, `.bottom-spacer` rule blocks (lines 589-782)
+    Must NOT touch: PageBanner, LoginGuideCard, FamilyEnergyBar, FamilyRelationGraph, UserQuickEntry, func-grid sections. Must NOT break existing DimensionTasks/DimensionActivities/DimensionProducts components. Must NOT create DimensionArticles — keep inline articles section.
+  Parallelization: Wave 1 | Blocked by: — | Blocks: T2
+  References:
+    - Full source: `/app/cfc/cfc-frontend/pages/wisdom/index.vue` (all 784 lines)
+    - RadarChart usage: `/app/cfc/cfc-frontend/pages/mind/index.vue` lines 109-115 — props: dimensions, scores, childName, fillColor, gridColor, labelColor; event: dimensionClick
+    - RadarChart component: `/app/cfc/cfc-frontend/components/RadarChart.vue` (props listed above)
+    - Cognitive 6 dim fields: wisdom/index.vue lines 371-378 — perceptionScore, focusScore, memoryScore, logicScore, spatialScore, processingSpeedScore
+    - Wisdom brand color: README.md五维色系 — 智=金 `#6366F1`
+  Acceptance criteria (agent-executable):
+    - Template has `<RadarChart` after `</FamilyEnergyBar>` and before `<FamilyRelationGraph`
+    - Template has NO `cognition-summary`, `highlight-card`, `tips-list`, `quick-actions`, `bottom-spacer`
+    - Script has `RadarChart` imported and registered (import line + components block entry)
+    - Script has `cognitiveDimensions` and `cognitiveScores` computed properties
+    - Script has NO `WisdomTips`, NO `lowestDimension`, NO `wisdomTips`, NO `loadCognitiveReport`, NO `findLowestDimension`
+    - Style has NO `.cognition-summary`, `.cognition-empty`, `.highlight-card`, `.highlight-*`, `.tips-list`, `.tip-card`, `.quick-actions`, `.action-btn`, `.bottom-spacer`
+    - Grep for `\?\.` returns empty
+  QA scenarios:
+    - Happy: Read modified file, verify all section changes
+    - No-regression: Grep for removed identifiers; verify inline articles section still exists
+    - Evidence: `.omo/evidence/task-1-wisdom-restructure-verified.txt`
+  Commit: Y | `refactor(frontend): 重构智页面布局 — 集成雷达图、重排顺序、清理废弃区块`
+
+- [ ] 2. Verify frontend compilation
+  What to do / Must NOT do: Run `npm run build:mp-weixin` from `/app/cfc/cfc-frontend/`. Exit code 0 required. Capture output.
+  Parallelization: Wave 2 | Blocked by: T1 | Blocks: —
+  References: `cfc-frontend/AGENTS.md` commands section
+  Acceptance criteria: build exits 0, no compilation errors, dist/ exists
+  QA: Run build, capture output to `.omo/evidence/task-2-build-output.txt`
+  Commit: N
+
+## Final verification wave
+- [ ] F1. Plan compliance — RadarChart present, correct order, removed sections gone, no new components created
+- [ ] F2. Code quality — no `?.`, no CSS Grid, Vue 2 Options API
+- [ ] F3. Scope fidelity — no backend changes, no existing component modifications
+
+## Commit strategy
+- Todo 1: `refactor(frontend): 重构智页面布局 — 集成雷达图、重排顺序、清理废弃区块`
+
+## Success criteria
+1. Wisdom tab shows: PageBanner → LoginGuideCard → FamilyEnergyBar → RadarChart(6dim) → FamilyRelationGraph → UserQuickEntry → func-grid → DimensionTasks → DimensionActivities → DimensionProducts → articles
+2. RadarChart renders with actual cognitive assessment scores for the active child
+3. Removed sections (认知概览, highlight cards, tips, quick-actions) no longer appear
+4. Frontend builds without errors