代码优化,epub阅读标签

This commit is contained in:
DelLevin-Home
2026-06-28 02:25:07 +08:00
parent c810a1a381
commit 5f434ae3fa
35 changed files with 2110 additions and 525 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:uuid/uuid.dart';
/// 块类型枚举
@@ -220,9 +221,15 @@ class NotePlusDocument {
/// 从 JSONDB 行)创建
factory NotePlusDocument.fromJson(Map<String, dynamic> json) {
final blocksJson = json['blocks_json'] as String? ?? '[]';
final blocksList = (jsonDecode(blocksJson) as List<dynamic>)
.map((b) => NoteBlock.fromJson(b as Map<String, dynamic>))
.toList();
List<NoteBlock> blocksList;
try {
blocksList = (jsonDecode(blocksJson) as List<dynamic>)
.map((b) => NoteBlock.fromJson(b as Map<String, dynamic>))
.toList();
} catch (e) {
debugPrint('[NotePlusDocument] blocks_json 解析失败,使用默认空文档: $e');
blocksList = [];
}
return NotePlusDocument(
id: json['id'] as String?,