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 {
if (await directory.exists()) { if (await directory.exists()) {
final entities = directory.listSync(); final entities = directory.listSync();
// FileNode
for (final entity in entities) { for (final entity in entities) {
nodes.add( nodes.add(
FileNode( FileNode(
name: entity.path.split(Platform.pathSeparator).last, name: entity.path.split(Platform.pathSeparator).last,
path: entity.path, path: entity.path,
isDirectory: entity is Directory, isDirectory: entity is Directory,
depth: parentDepth + 1, // +1 depth: parentDepth + 1,
children: [], 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; return nodes;
} }

6
win_text_editor/lib/main.dart

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

Loading…
Cancel
Save