Skip to content

Commit c90c9a0

Browse files
committed
app: compatible with windows
1 parent 9deafb0 commit c90c9a0

File tree

12 files changed

+28
-22
lines changed

12 files changed

+28
-22
lines changed

app/lib/api/file/pages/file_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class _FileListState extends ConsumerState<FileList> {
151151
if (file.type == "DIR") {
152152
Navigator.of(context).pushNamed(
153153
'/file/list',
154-
arguments: filepath.join(file.path, file.name),
154+
arguments: filepath.posix.join(file.path, file.name),
155155
);
156156
return;
157157
}

app/lib/api/file/pages/file_preview.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class _FilePreviewState extends ConsumerState<FilePreview> {
7272
}
7373

7474
_buildFile(File file) {
75-
final remotePath = filepath.join(file.path, file.name);
75+
final remotePath = filepath.posix.join(file.path, file.name);
7676

7777
if (PathUtil.isText(file.name, type: file.type)) {
7878
return TextPreview.remote(remotePath);
@@ -213,7 +213,7 @@ class _FileImagePreviewState extends ConsumerState<FileImagePreview> {
213213
});
214214
},
215215
child: ImagePreview.remote(
216-
filepath.join(file.path, file.name),
216+
filepath.posix.join(file.path, file.name),
217217
fit: BoxFit.contain,
218218
),
219219
);
@@ -277,7 +277,7 @@ class _FileAudioPreviewState extends State<FileAudioPreview>
277277

278278
_controller = AudioPreviewController(
279279
currentFiles.map((file) {
280-
final remotePath = filepath.join(file.path, file.name);
280+
final remotePath = filepath.posix.join(file.path, file.name);
281281
return PreviewSource.network(GRPC().previewURL(remotePath));
282282
}).toList(),
283283
index: index,
@@ -344,7 +344,7 @@ class _FileVideoPreviewState extends State<FileVideoPreview>
344344

345345
_controller = VideoPreviewController(
346346
currentFiles.map((file) {
347-
final remotePath = filepath.join(file.path, file.name);
347+
final remotePath = filepath.posix.join(file.path, file.name);
348348
return PreviewSource.network(GRPC().previewURL(remotePath));
349349
}).toList(),
350350
index: index,

app/lib/api/file/pages/file_select.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class _FileSelectState extends ConsumerState<FileSelect> {
112112
final result = ref
113113
.read(fileSelectionProvider)
114114
.selected
115-
.map((file) => filepath.join(file.path, file.name))
115+
.map((file) => filepath.posix.join(file.path, file.name))
116116
.toList();
117117

118118
_resetProvider();
@@ -136,7 +136,7 @@ class _FileSelectState extends ConsumerState<FileSelect> {
136136
_onTap(BuildContext context, File item) async {
137137
if (item.type == "DIR") {
138138
final Map<String, dynamic> args = {
139-
"path": filepath.join(item.path, item.name),
139+
"path": filepath.posix.join(item.path, item.name),
140140
"title": widget.title,
141141
"filter": widget.filter,
142142
"multiple": widget.multiple,

app/lib/api/file/providers/service.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ class FileService {
113113
const int chunkSize = 1024 * 32;
114114

115115
var size = file.lengthSync();
116+
var name = filepath.basename(file.path);
116117

117118
// 第0片不包括chunk
118119
yield FileRequest(
119120
path: path,
120121
size: size,
121-
filename: filepath.basename(file.path),
122+
filename: name,
122123
);
123124

124125
var index = 0;
@@ -134,7 +135,7 @@ class FileService {
134135
size: size,
135136
index: index,
136137
chunk: chunk.toList(),
137-
filename: filepath.basename(file.path),
138+
filename: name,
138139
);
139140

140141
chunk = readFile.readSync(readSize);
@@ -145,7 +146,7 @@ class FileService {
145146
size: size,
146147
index: index + 1,
147148
chunk: chunk.toList(),
148-
filename: filepath.basename(file.path),
149+
filename: name,
149150
);
150151
}
151152
}
@@ -254,5 +255,4 @@ class FileService {
254255
return _client.deleteRepo(request);
255256
});
256257
}
257-
258258
}

app/lib/api/file/widgets/file_action.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension FileActionTypeExtension on FileActionType {
7171
}
7272
return;
7373
case FileActionType.rename:
74-
final ext = filepath.extension(file.name);
74+
final ext = filepath.posix.extension(file.name);
7575
final result = await showEditingDialog(
7676
context,
7777
"重命名".tr(),
@@ -96,7 +96,7 @@ extension FileActionTypeExtension on FileActionType {
9696
}
9797
await FileService()
9898
.download(
99-
filepath.join(file.path, file.name),
99+
filepath.posix.join(file.path, file.name),
100100
io.File(PathUtil.autoRename(filepath.join(downloadPath, file.name))),
101101
)
102102
.then((_) {

app/lib/api/file/widgets/file_tree.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ class FileTreeState extends ConsumerState<FileTree> {
112112
CustomTreeNode<File>? parent = node.parent;
113113

114114
while (parent != null) {
115-
path = filepath.join(parent.content.name, path);
115+
path = filepath.posix.join(parent.content.name, path);
116116
parent = parent.parent;
117117
}
118-
path = filepath.join(widget.path, path);
118+
path = filepath.posix.join(widget.path, path);
119119

120120
final files = ref.refresh(fileProvider(path)).valueOrNull ?? [];
121121
node.children.clear();

app/lib/api/file/widgets/preview/source.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PreviewSource {
3939
PreviewSource.network(
4040
String url, {
4141
String? name,
42-
}) : name = name ?? filepath.basename(url),
42+
}) : name = name ?? filepath.url.basename(url),
4343
source = url,
4444
sourceType = SourceType.network;
4545

@@ -49,7 +49,7 @@ class PreviewSource {
4949
sourceType = SourceType.file;
5050

5151
PreviewSource.remote(String path)
52-
: name = filepath.basename(path),
52+
: name = filepath.posix.basename(path),
5353
source = GRPC().previewURL(path),
5454
sourceType = SourceType.network;
5555
}

app/lib/api/home/pages/index.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
33

44
import 'package:maple_file/app/app.dart';
55
import 'package:maple_file/app/i18n.dart';
6+
import 'package:maple_file/common/utils/util.dart';
67
import 'package:maple_file/common/widgets/tree.dart';
78
import 'package:maple_file/common/widgets/dialog.dart';
89
import 'package:maple_file/common/widgets/custom.dart';
@@ -106,7 +107,7 @@ class _DesktopIndexState extends ConsumerState<DesktopIndex> {
106107
label: Text('任务'.tr()),
107108
),
108109
],
109-
leading: const SizedBox(height: 16),
110+
leading: Util.isWindows ? null : const SizedBox(height: 16),
110111
trailing: Expanded(
111112
child: Column(
112113
mainAxisSize: MainAxisSize.min,

app/lib/app/app.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ class App {
4646
if (Util.isDesktop) {
4747
await windowManager.ensureInitialized();
4848

49-
WindowOptions windowOptions = const WindowOptions(
50-
size: Size(800, 600),
49+
WindowOptions windowOptions = WindowOptions(
50+
size: const Size(800, 600),
5151
center: true,
5252
backgroundColor: Colors.transparent,
53-
titleBarStyle: TitleBarStyle.hidden,
53+
titleBarStyle:
54+
Util.isWindows ? TitleBarStyle.normal : TitleBarStyle.hidden,
5455
);
5556
windowManager.waitUntilReadyToShow(windowOptions, () async {
5657
await windowManager.show();

app/lib/common/utils/path.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class PathUtil {
8686
Map<String, IconData> icons = {
8787
".apk": Icons.android,
8888
};
89-
return icons[filepath.extension(name)] ?? Icons.note;
89+
return icons[filepath.posix.extension(name)] ?? Icons.note;
9090
}
9191

9292
static bool isText(String name, {String? type}) {

0 commit comments

Comments
 (0)