笔记编辑功能修复

This commit is contained in:
DelLevin-Home
2026-07-16 04:12:04 +08:00
parent 1aab6858a7
commit 10ecf57fa7
9 changed files with 481 additions and 24 deletions

View File

@@ -30,13 +30,18 @@ List<String> parseStringListGeneric(dynamic data) {
return data.map((e) => e.toString()).toList();
}
if (data is String) {
if (data.isEmpty) return [];
try {
final decoded = jsonDecode(data);
if (decoded is List) {
return decoded.map((e) => e.toString()).toList();
}
// JSON 解析成功但不是 List如 Map、String保留原始值
return [data];
} catch (e) {
return data.split(',').map((s) => s.trim()).where((s) => s.isNotEmpty).toList();
// JSON 解析失败,按逗号分割;若无逗号则作为单元素保留
final split = data.split(',').map((s) => s.trim()).where((s) => s.isNotEmpty).toList();
return split.isNotEmpty ? split : [data];
}
}
return [];