From ab45f40cc83fa9e0a2984acbe0df6d80e4d9e1a9 Mon Sep 17 00:00:00 2001 From: iven Date: Tue, 2 Jun 2026 23:06:11 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BF=AE=E8=AE=A2=E5=AE=9E=E6=96=BD?= =?UTF-8?q?=E8=AE=A1=E5=88=92=20=E2=80=94=20=E4=BF=AE=E5=A4=8D=20EditorVie?= =?UTF-8?q?w=20=E7=9B=AE=E6=A0=87=E7=B1=BB/apiClient.data/=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=90=8E=E7=AB=AF=E5=B7=B2=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2026-06-02-classroom-pilot-readiness.md | 106 ++++++++---------- 1 file changed, 44 insertions(+), 62 deletions(-) diff --git a/docs/superpowers/plans/2026-06-02-classroom-pilot-readiness.md b/docs/superpowers/plans/2026-06-02-classroom-pilot-readiness.md index ab55d57..96a950b 100644 --- a/docs/superpowers/plans/2026-06-02-classroom-pilot-readiness.md +++ b/docs/superpowers/plans/2026-06-02-classroom-pilot-readiness.md @@ -154,29 +154,11 @@ git commit -m "feat(app): 添加 EditorBloc.LoadJournal event — 加载已有 **Files:** - Modify: `app/lib/features/editor/views/editor_page.dart` -- [ ] **Step 1: 在 _EditorStackState.initState 中加载已有日记** +> ⚠️ **重要:** `_loadExistingJournal` 已存在于 `_EditorViewState`(line ~278-331),使用多个细粒度事件(TitleChanged, MoodChanged, TagsLoaded, StrokesLoaded, ElementsLoaded)。本任务将其替换为单一的原子 `LoadJournal` 事件。修改目标是 **`_EditorViewState`**,不是 `_EditorStackState`。 -修改 `_EditorStackState` 的 `initState`: +- [ ] **Step 1: 替换 `_EditorViewState._loadExistingJournal` 方法** -```dart -@override -void initState() { - super.initState(); - _titleController = TextEditingController(text: widget.state.title); - - // 如果打开已有日记,加载其数据 - if (widget.journalId != null) { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (!mounted) return; - _loadExistingJournal(widget.journalId!); - }); - } -} -``` - -- [ ] **Step 2: 实现 _loadExistingJournal 方法** - -在 `_EditorStackState` 中添加: +找到 `_EditorViewState._loadExistingJournal`(约 line 287-331),替换为使用 LoadJournal 的版本: ```dart /// 加载已有日记数据并 dispatch LoadJournal @@ -217,50 +199,30 @@ Future _loadExistingJournal(String journalId) async { lastSavedAt: entry.updatedAt, )); - // 同步标题输入框 - _titleController.text = entry.title; + // 同步标题输入框(_EditorStackState 中的 controller) } catch (e) { debugPrint('加载日记失败: $e'); } } ``` -- [ ] **Step 3: 确认 JournalRepository 有 getElements 方法** +- [ ] **Step 2: 验证 JournalRepository.getElements 已存在(完整性检查,预计已存在)** Run: `cd g:/nj/app && grep -n "getElements" lib/data/repositories/journal_repository.dart` -如果不存在,需要在 `JournalRepository` 接口和实现中添加: +Expected: 找到方法声明,无需添加。 -```dart -// journal_repository.dart -Future> getElements(String journalId); - -// isar_journal_repository.dart -@override -Future> getElements(String journalId) async { - // 查询 isar 中该 journalId 的所有元素 - final collections = await isar.journalElementCollections - .where() - .filter() - .journalIdEqualTo(journalId) - .findAll(); - return collections.map(_collectionToElement).toList(); -} -``` - -- [ ] **Step 4: 运行 flutter analyze 确认无错误** +- [ ] **Step 3: 运行 flutter analyze 确认无错误** Run: `cd g:/nj/app && flutter analyze` Expected: No issues found -- [ ] **Step 5: 提交** +- [ ] **Step 4: 提交** ```bash cd g:/nj git add app/lib/features/editor/views/editor_page.dart -git add app/lib/data/repositories/journal_repository.dart -git add app/lib/data/repositories/isar_journal_repository.dart -git commit -m "feat(app): EditorPage 加载已有日记 — initState 触发 LoadJournal" +git commit -m "feat(app): EditorPage 加载已有日记 — 替换为 LoadJournal 原子事件" ``` --- @@ -604,7 +566,7 @@ class _CommentCountBadge extends StatelessWidget { Future> _fetchComments() async { try { final response = await apiClient.get('/diary/journals/$journalId/comments'); - return response as List; + return response.data as List; } catch (_) { return []; } @@ -667,7 +629,7 @@ class _CommentListFuture extends StatelessWidget { Future> _fetchComments() async { try { final response = await apiClient.get('/diary/journals/$journalId/comments'); - final list = response as List; + final list = response.data as List; return list.map((json) => Comment( id: json['id'] as String, journalId: json['journal_id'] as String, @@ -920,7 +882,22 @@ git commit -m "fix(server): 补充暖记管理端菜单 seed — 贴纸/主题/ - Modify: `crates/erp-diary/src/handler/sticker_handler.rs` - Modify: `crates/erp-diary/src/lib.rs` -- [ ] **Step 1: 在 sticker_service.rs 添加 CRUD 方法** +- [ ] **Step 1: 在 dto.rs 添加 UpdateStickerPackReq DTO** + +参考已有的 `CreateStickerPackReq`,在 `crates/erp-diary/src/dto.rs` 中添加: + +```rust +#[derive(Debug, Deserialize, Validate, ToSchema)] +pub struct UpdateStickerPackReq { + #[validate(length(min = 1, max = 100))] + pub name: Option, + pub description: Option, + pub category: Option, + pub is_free: Option, +} +``` + +- [ ] **Step 2: 在 sticker_service.rs 添加 CRUD 方法** ```rust // 创建贴纸包 @@ -931,7 +908,7 @@ pub async fn update_sticker_pack(&self, id: &str, req: UpdateStickerPackReq) -> pub async fn delete_sticker_pack(&self, id: &str) -> Result<()> { ... } ``` -- [ ] **Step 2: 在 sticker_handler.rs 添加 handler** +- [ ] **Step 3: 在 sticker_handler.rs 添加 handler** ```rust // POST /diary/sticker-packs — 需 diary.sticker.manage 权限 @@ -944,14 +921,14 @@ pub async fn update_sticker_pack(...) { ... } pub async fn delete_sticker_pack(...) { ... } ``` -- [ ] **Step 3: 在 lib.rs 注册路由** +- [ ] **Step 4: 在 lib.rs 注册路由** -- [ ] **Step 4: 运行 cargo check + cargo test** +- [ ] **Step 5: 运行 cargo check + cargo test** Run: `cd g:/nj && cargo check && cargo test` Expected: PASS -- [ ] **Step 5: 提交** +- [ ] **Step 6: 提交** ```bash git add crates/erp-diary/ @@ -998,20 +975,25 @@ git commit -m "feat(web): 贴纸包管理 CRUD UI — 创建/编辑/删除" ### Task 15: 主题编辑/停用 **Files:** -- Modify: `crates/erp-diary/src/service/topic_service.rs` -- Modify: `crates/erp-diary/src/handler/topic_handler.rs` -- Modify: `crates/erp-diary/src/lib.rs` +- Verify: `crates/erp-diary/src/handler/topic_handler.rs` (update_topic + deactivate_topic 已存在) - Modify: `apps/web/src/api/diary/topics.ts` - Modify: `apps/web/src/pages/diary/TopicList.tsx` -- [ ] **Step 1: 后端添加主题更新/停用** +> ⚠️ **后端已实现** — `topic_handler.rs` 已有 `update_topic` (PUT) 和 `deactivate_topic` (PATCH) handler,`lib.rs` 已注册路由。只需补全管理端 UI。 -```rust -// PUT /diary/topics/{id} — 编辑主题(标题/描述/截止日期) -// PATCH /diary/topics/{id}/deactivate — 停用主题 +- [ ] **Step 1: 验证后端 API 可用** + +Run: `cd g:/nj && grep -n "update_topic\|deactivate_topic" crates/erp-diary/src/handler/topic_handler.rs` +Expected: 找到两个方法 + +- [ ] **Step 2: 在 topics.ts 添加 update/deactivate API 调用** + +```typescript +update: (id: string, data: UpdateTopicReq) => api.put(`/diary/topics/${id}`, data), +deactivate: (id: string) => api.patch(`/diary/topics/${id}/deactivate`), ``` -- [ ] **Step 2: 管理端 TopicList.tsx 添加编辑/停用按钮** +- [ ] **Step 3: 管理端 TopicList.tsx 添加编辑/停用按钮** - [ ] **Step 3: 提交**