fix: 保存故事时将 cover_url 写入后端,修复书架封面为空的问题

_addNewBookWithAnimation 新增 coverUrl 参数,POST /stories/ 时携带
cover_url 字段,两处调用均从 saveResult 传入生成好的封面 URL。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
repair-agent 2026-03-02 15:57:14 +08:00
parent 51f994a2cc
commit 73cffb704f

View File

@ -474,6 +474,7 @@ class _DeviceControlPageState extends ConsumerState<DeviceControlPage>
await _addNewBookWithAnimation( await _addNewBookWithAnimation(
title: saveResult['title'] as String? ?? '新故事', title: saveResult['title'] as String? ?? '新故事',
content: saveResult['content'] as String? ?? '', content: saveResult['content'] as String? ?? '',
coverUrl: saveResult['cover_url'] as String? ?? '',
); );
} }
} }
@ -601,6 +602,7 @@ class _DeviceControlPageState extends ConsumerState<DeviceControlPage>
_addNewBookWithAnimation( _addNewBookWithAnimation(
title: saveResult['title'] as String? ?? '新故事', title: saveResult['title'] as String? ?? '新故事',
content: saveResult['content'] as String? ?? '', content: saveResult['content'] as String? ?? '',
coverUrl: saveResult['cover_url'] as String? ?? '',
); );
} }
} }
@ -900,7 +902,7 @@ class _DeviceControlPageState extends ConsumerState<DeviceControlPage>
); );
} }
Future<void> _addNewBookWithAnimation({String title = '新故事', String content = ''}) async { Future<void> _addNewBookWithAnimation({String title = '新故事', String content = '', String coverUrl = ''}) async {
// Find the first shelf that has space // Find the first shelf that has space
int? targetShelfId; int? targetShelfId;
for (final shelf in _shelves) { for (final shelf in _shelves) {
@ -923,6 +925,7 @@ class _DeviceControlPageState extends ConsumerState<DeviceControlPage>
'title': title, 'title': title,
'content': content, 'content': content,
'shelf_id': targetShelfId, 'shelf_id': targetShelfId,
if (coverUrl.isNotEmpty) 'cover_url': coverUrl,
}); });
// Reload to get the new story // Reload to get the new story
await _loadShelves(); await _loadShelves();