[WIP] Update Flutter frontend to support new API features#11
Merged
Conversation
IfeyChan702
marked this pull request as ready for review
February 12, 2026 10:12
Copilot stopped work on behalf of
IfeyChan702 due to an error
February 12, 2026 10:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Flutter Frontend Update - Story and Character Integration
Plan Checklist:
/flutter_app/lib/config/app_constants.dartstory_model.dartcharacter_model.dartconstants.dartwith new API endpointsapi_service.dartwith new API methodsstory_card.dartcharacter_card.dartstories_screen.dartstory_detail_screen.dartgenerate_story_screen.dartcharacters_screen.dartadd_character_screen.darthome_screen.dartto add Stories tabprofile_screen.dartto add "My Characters" optionpubspec.yamlto add image_picker dependencyOriginal prompt
背景
项目的 Spring Boot 后端已经完成了 Story(故事)和 Character(主角)相关的 API,但 Flutter 前端
flutter_app/目录下仍然是旧版本,缺少对应的前端页面和服务。需要更新 Flutter 前端,使其能够完整运行并对接所有后端 API。当前后端 API 列表
已有 API(Flutter 已对接)
POST /loginmobile- 登录POST /register- 注册POST /api/note/add- 创建笔记GET /api/note/list- 笔记列表GET /api/note/{id}- 笔记详情PUT /api/note/{id}- 更新笔记DELETE /api/note/{id}- 删除笔记GET /api/note/count- 笔记计数POST /api/rag/search- RAG 向量检索POST /api/rag/answer- RAG AI 回答POST /api/rag/chat- RAG 多轮对话GET /api/review/next- 获取待复习项POST /api/review/record- 记录复习GET /api/review/stats- 复习统计POST /api/review/initialize- 初始化复习新增 API(Flutter 尚未对接,需要添加)
Story Controller (
/api/story):POST /api/story/generate- 生成故事(核心功能,上传图片+选择主角,AI识别物品并生成故事){ "image": "base64或url", "imageType": "base64", "characterId": 1, "title": "可选标题" }GET /api/story/list- 获取故事列表(支持 characterId 和 isFavorite 筛选)GET /api/story/{id}- 获取故事详情PUT /api/story/{id}- 更新故事(标题、内容)DELETE /api/story/{id}- 删除故事POST /api/story/{id}/favorite- 收藏故事DELETE /api/story/{id}/favorite- 取消收藏POST /api/story/{id}/share- 生成分享链接GET /api/story/shared/{shareToken}- 通过分享链接查看故事Character Controller (
/api/character):GET /api/character/list- 获取主角列表GET /api/character/{id}- 获取主角详情POST /api/character/add- 创建主角PUT /api/character/{id}- 更新主角DELETE /api/character/{id}- 删除主角Search Controller (
/api/search):POST /api/search/stories- 搜索故事POST /api/search/characters- 搜索主角POST /api/search/all- 全局搜索需要完成的任务
1. 新增 Models
flutter_app/lib/models/story_model.dart:flutter_app/lib/models/character_model.dart:2. 更新
flutter_app/lib/utils/constants.dart添加所有新的 API endpoint 常量:
3. 更新
flutter_app/lib/services/api_service.dart在现有 ApiService 中添加以下方法:
重要: 保留现有的所有 Note、RAG、Review API 方法不变。在文件末尾(
}之前)追加新方法。4. 新增 Screens
flutter_app/lib/screens/stories_screen.dart- 故事列表页:flutter_app/lib/screens/story_detail_screen.dart- 故事详情页:flutter_app/lib/screens/generate_story_screen.dart- 生成故事页:flutter_app/lib/screens/characters_screen.dart- 主角列表页:flutter_app/lib/screens/add_character_screen.dart- 添加/编辑主角页:5. 新增 Widgets
flutter_app/lib/widgets/story_card.dart:flutter_app/lib/widgets/character_card.dart:6. 更新
flutter_app/lib/screens/home_screen.dart将底部导航栏从 4 个 tab 扩展为 5 个 tab:
导入新的 screen 文件:
stories_screen.dart,characters_screen.dart7. 更新
flutter_app/lib/screens/profile_screen.dart在 Profile 页面添加一个 ListTile "My Characters"(我的主角),点击后导航到 CharactersScreen。
8. 更新
flutter_app/pubspec.yaml添加
image_picker依赖(用于拍照/选图功能):9. 删除冗余文件
删除
flutter_app/lib/config/app_constants.dart(这个文件和flutter_app/lib/utils/constants.dart重复且内容是旧的占位符)。现有文件参考
现有
flutter_app/lib/utils/constants.dart的完整内容(需要在此基础上追加新 endpoint):