Browse Source

资源管理器Over

master
hejl 2 months ago
parent
commit
f7c2dee021
  1. 17
      win_text_editor/lib/app/services/file_service.dart
  2. 6
      win_text_editor/lib/main.dart

17
win_text_editor/lib/app/services/file_service.dart

@ -9,18 +9,33 @@ class FileService { @@ -9,18 +9,33 @@ class FileService {
if (await directory.exists()) {
final entities = directory.listSync();
// FileNode
for (final entity in entities) {
nodes.add(
FileNode(
name: entity.path.split(Platform.pathSeparator).last,
path: entity.path,
isDirectory: entity is Directory,
depth: parentDepth + 1, // +1
depth: parentDepth + 1,
children: [],
),
);
}
//
nodes.sort((a, b) {
if (a.isDirectory && !b.isDirectory) {
return -1; // a是文件夹b是文件a排在前面
} else if (!a.isDirectory && b.isDirectory) {
return 1; // a是文件b是文件夹b排在前面
} else {
//
return a.name.compareTo(b.name);
}
});
}
return nodes;
}

6
win_text_editor/lib/main.dart

@ -8,9 +8,9 @@ void main() async { @@ -8,9 +8,9 @@ void main() async {
//
await windowManager.ensureInitialized();
WindowOptions windowOptions = const WindowOptions(
size: Size(1200, 800),
size: Size(1800, 1200),
center: true,
title: 'Win Text Editor',
title: '文本转换',
);
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
@ -26,7 +26,7 @@ class MyApp extends StatelessWidget { @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '文本编辑器',
title: '文本转换',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,

Loading…
Cancel
Save