combine upload files/folder button (#9643)

* combine upload files/folder button

Signed-off-by: 21pages <sunboeasy@gmail.com>

* web compress cache

Signed-off-by: 21pages <sunboeasy@gmail.com>

---------

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-10-14 15:46:21 +08:00
committed by GitHub
parent 498b8ba3d6
commit ce924cc0d3
46 changed files with 201 additions and 42 deletions

View File

@@ -490,6 +490,9 @@ class _FileManagerViewState extends State<FileManagerView> {
}
Widget headTools() {
var uploadButtonTapPosition = RelativeRect.fill;
RxBool isUploadFolder =
(bind.mainGetLocalOption(key: 'upload-folder-button') == 'Y').obs;
return Container(
child: Column(
children: [
@@ -814,48 +817,64 @@ class _FileManagerViewState extends State<FileManagerView> {
),
if (isWeb)
Obx(() => ElevatedButton.icon(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
isLocal
? EdgeInsets.only(left: 10)
: EdgeInsets.only(right: 10)),
backgroundColor: MaterialStateProperty.all(
selectedItems.items.isEmpty
? MyTheme.accent80
: MyTheme.accent,
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
isLocal
? EdgeInsets.only(left: 10)
: EdgeInsets.only(right: 10)),
backgroundColor: MaterialStateProperty.all(
selectedItems.items.isEmpty
? MyTheme.accent80
: MyTheme.accent,
),
),
),
onPressed: () => {webselectFiles(is_folder: true)},
icon: Offstage(),
label: Text(
translate('Upload folder'),
textAlign: TextAlign.right,
style: TextStyle(
color: Colors.white,
onPressed: () =>
{webselectFiles(is_folder: isUploadFolder.value)},
label: InkWell(
hoverColor: Colors.transparent,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
focusColor: Colors.transparent,
onTapDown: (e) {
final x = e.globalPosition.dx;
final y = e.globalPosition.dy;
uploadButtonTapPosition =
RelativeRect.fromLTRB(x, y, x, y);
},
onTap: () async {
final value = await showMenu<bool>(
context: context,
position: uploadButtonTapPosition,
items: [
PopupMenuItem<bool>(
value: false,
child: Text(translate('Upload files')),
),
PopupMenuItem<bool>(
value: true,
child: Text(translate('Upload folder')),
),
]);
if (value != null) {
isUploadFolder.value = value;
bind.mainSetLocalOption(
key: 'upload-folder-button',
value: value ? 'Y' : '');
webselectFiles(is_folder: value);
}
},
child: Icon(Icons.arrow_drop_down),
),
))).marginOnly(left: 16),
if (isWeb)
Obx(() => ElevatedButton.icon(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
isLocal
? EdgeInsets.only(left: 10)
: EdgeInsets.only(right: 10)),
backgroundColor: MaterialStateProperty.all(
selectedItems.items.isEmpty
? MyTheme.accent80
: MyTheme.accent,
),
),
onPressed: () => {webselectFiles(is_folder: false)},
icon: Offstage(),
label: Text(
translate('Upload files'),
textAlign: TextAlign.right,
style: TextStyle(
color: Colors.white,
),
))).marginOnly(left: 16),
icon: Text(
translate(isUploadFolder.isTrue
? 'Upload folder'
: 'Upload files'),
textAlign: TextAlign.right,
style: TextStyle(
color: Colors.white,
),
).marginOnly(left: 8),
)).marginOnly(left: 16),
Obx(() => ElevatedButton.icon(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(

View File

@@ -1209,7 +1209,12 @@ class RustdeskImpl {
}
Future<String> mainLoadAb({dynamic hint}) {
return Future(() => js.context.callMethod('getByName', ['load_ab']));
Completer<String> completer = Completer();
js.context["onLoadAbFinished"] = (String s) {
completer.complete(s);
};
js.context.callMethod('setByName', ['load_ab']);
return completer.future;
}
Future<void> mainSaveGroup({required String json, dynamic hint}) {
@@ -1222,7 +1227,12 @@ class RustdeskImpl {
}
Future<String> mainLoadGroup({dynamic hint}) {
return Future(() => js.context.callMethod('getByName', ['load_group']));
Completer<String> completer = Completer();
js.context["onLoadGroupFinished"] = (String s) {
completer.complete(s);
};
js.context.callMethod('setByName', ['load_group']);
return completer.future;
}
Future<void> sessionSendPointer(