This commit is contained in:
LZX committed 2026-09-10 22:04:06 +08:00
commit 2379b4476f
141 files changed
+6087

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import 'dart:convert';
class FileDirectoryHistory {
final String? rootPath;
final String? lastOpenedFilePath;
final List<String> openDirectoryPaths;
const FileDirectoryHistory({
required this.rootPath,
required this.lastOpenedFilePath,
this.openDirectoryPaths = const [],
});
Map<String, dynamic> toMap() => {
'rootPath': rootPath,
'lastOpenedFilePath': lastOpenedFilePath,
'openDirectoryPaths': openDirectoryPaths,
};
factory FileDirectoryHistory.fromMap(Map<String, dynamic> map) {
return FileDirectoryHistory(
rootPath: map['rootPath'] as String?,
lastOpenedFilePath: map['lastOpenedFilePath'] as String?,
openDirectoryPaths: (map['openDirectoryPaths'] as List<dynamic>?)
?.map((e) => e.toString())
.toList() ??
const [],
);
}
String toJson() => jsonEncode(toMap());
factory FileDirectoryHistory.fromJson(String source) {
try {
final decoded = jsonDecode(source);
if (decoded is Map) {
return FileDirectoryHistory.fromMap(Map<String, dynamic>.from(decoded));
}
} catch (_) {}
return const FileDirectoryHistory(rootPath: null, lastOpenedFilePath: null);
}
}
+17
View File
@@ -0,0 +1,17 @@
class FileItem {
final String path;
final String name;
final bool isDirectory;
final List<FileItem> children;
final int depth;
bool isOpen;
FileItem({
required this.path,
required this.name,
this.isDirectory = false,
this.children = const [],
this.depth = 0,
this.isOpen = false
});
}