功能更新

This commit is contained in:
DelLevin-Home
2026-07-02 19:49:41 +08:00
parent 30a002feb2
commit 24fb7aab55
13 changed files with 475 additions and 177 deletions

View File

@@ -679,8 +679,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
try {
final now = DateTime.now();
if (_isEditing) {
// 更新现有笔记
if (_isEditing && widget.note != null) {
// 更新现有笔记(编辑已有笔记)
final updatedNote = widget.note!.copyWith(
title: _titleController.text.trim(),
content: content,
@@ -689,8 +689,18 @@ class _NoteFormPageState extends State<NoteFormPage> {
updatedAt: now,
);
await context.read<AppProvider>().updateNote(updatedNote);
} else if (_savedNote != null) {
// 自动保存过的新笔记,更新它
final updatedNote = _savedNote!.copyWith(
title: _titleController.text.trim(),
content: content,
tags: _tags,
images: _images,
updatedAt: now,
);
await context.read<AppProvider>().updateNote(updatedNote);
} else {
// 添加新笔记 - 先创建笔记获取ID
// 添加新笔记
final noteId = now.millisecondsSinceEpoch.toString();
// 如果有图片需要移动到正确的ID目录