mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-13 11:53:41 +00:00
fix: file explorer and support select file (#111)
This commit is contained in:
1 parent
34bcbd9571
commit
1e08ecd8db
3 files changed
+67
-9
No files matched your search
@@ -3,9 +3,11 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../../../api/api.dart';
|
||||
import '../../../api/model/task.dart';
|
||||
import '../../../util/file_explorer.dart';
|
||||
import '../../../util/file_icon.dart';
|
||||
import '../../../util/icons.dart';
|
||||
import '../../../util/message.dart';
|
||||
@@ -53,6 +55,18 @@ class BuildTaskListView extends GetView {
|
||||
return task.status == Status.running;
|
||||
}
|
||||
|
||||
String buildExplorerUrl(Task task) {
|
||||
if (task.meta.res.rootDir.trim().isEmpty) {
|
||||
return path.join(
|
||||
Util.safeDir(task.meta.opts.path),
|
||||
Util.safeDir(task.meta.res.files[0].path),
|
||||
task.meta.res.files[0].name);
|
||||
} else {
|
||||
return path.join(Util.safeDir(task.meta.opts.path),
|
||||
Util.safeDir(task.meta.res.rootDir));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> showDeleteDialog(String id) {
|
||||
final keep = true.obs;
|
||||
|
||||
@@ -100,9 +114,7 @@ class BuildTaskListView extends GetView {
|
||||
list.add(IconButton(
|
||||
icon: const Icon(Icons.folder_open),
|
||||
onPressed: () async {
|
||||
final file = File(Util.buildAbsPath(task.meta.opts.path,
|
||||
task.meta.res.files[0].path, task.meta.res.files[0].name));
|
||||
await launchUrl(file.parent.uri);
|
||||
await FileExplorer.openAndSelectFile(buildExplorerUrl(task));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user