代码优化,功能新增

This commit is contained in:
DelLevin-Home
2026-06-26 23:46:37 +08:00
parent f7ef50a677
commit 45137b96d6
59 changed files with 5041 additions and 4937 deletions

View File

@@ -314,6 +314,7 @@ class Note {
final DateTime createdAt;
final DateTime updatedAt;
final bool isDeleted;
final bool isPinned;
Note({
required this.id,
@@ -325,6 +326,7 @@ class Note {
required this.createdAt,
required this.updatedAt,
this.isDeleted = false,
this.isPinned = false,
});
factory Note.fromJson(Map<String, dynamic> json) {
@@ -342,6 +344,7 @@ class Note {
? DateTime.parse(json['updated_at'])
: DateTime.now(),
isDeleted: json['is_deleted'] == 1 || json['is_deleted'] == true,
isPinned: json['is_pinned'] == 1 || json['is_pinned'] == true,
);
}
@@ -356,9 +359,10 @@ class Note {
'created_at': createdAt.toUtc().toIso8601String(),
'updated_at': updatedAt.toUtc().toIso8601String(),
'is_deleted': isDeleted ? 1 : 0,
'is_pinned': isPinned ? 1 : 0,
};
}
/// 复制并修改
Note copyWith({
String? id,
@@ -370,6 +374,7 @@ class Note {
DateTime? createdAt,
DateTime? updatedAt,
bool? isDeleted,
bool? isPinned,
}) {
return Note(
id: id ?? this.id,
@@ -381,6 +386,7 @@ class Note {
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
isDeleted: isDeleted ?? this.isDeleted,
isPinned: isPinned ?? this.isPinned,
);
}