diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 99a24781b..8feb2402f 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -2383,7 +2383,7 @@ connect(BuildContext context, String id, ), ); } else { - if (isWebDesktop) { + if (isWeb) { Navigator.push( context, MaterialPageRoute( diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 3f2dcade9..8466443ee 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -372,7 +372,7 @@ class FfiModel with ChangeNotifier { } else if (name == 'plugin_option') { handleOption(evt); } else if (name == "sync_peer_hash_password_to_personal_ab") { - if (desktopType == DesktopType.main) { + if (desktopType == DesktopType.main || isWeb) { final id = evt['id']; final hash = evt['hash']; if (id != null && hash != null) { diff --git a/flutter/lib/models/web_model.dart b/flutter/lib/models/web_model.dart index a5740af61..a4312d959 100644 --- a/flutter/lib/models/web_model.dart +++ b/flutter/lib/models/web_model.dart @@ -1,6 +1,7 @@ // ignore_for_file: avoid_web_libraries_in_flutter import 'dart:convert'; +import 'dart:js_interop'; import 'dart:typed_data'; import 'dart:js'; import 'dart:html'; @@ -107,6 +108,10 @@ class PlatformFFI { sessionId: sessionId, display: display, ptr: ptr); Future init(String appType) async { + Completer completer = Completer(); + context["onInitFinished"] = () { + completer.complete(); + }; context.callMethod('init'); version = getByName('version'); window.onContextMenu.listen((event) { @@ -121,6 +126,7 @@ class PlatformFFI { print('json.decode fail(): $e'); } }; + return completer.future; } void setEventCallback(void Function(Map) fun) { diff --git a/flutter/lib/web/bridge.dart b/flutter/lib/web/bridge.dart index 2c8d6b4b0..adcbadb30 100644 --- a/flutter/lib/web/bridge.dart +++ b/flutter/lib/web/bridge.dart @@ -85,7 +85,11 @@ class RustdeskImpl { dynamic hint}) { return js.context.callMethod('setByName', [ 'session_add_sync', - jsonEncode({'id': id, 'password': password}) + jsonEncode({ + 'id': id, + 'password': password, + 'is_shared_password': isSharedPassword + }) ]); } @@ -1118,7 +1122,8 @@ class RustdeskImpl { } Future mainRemovePeer({required String id, dynamic hint}) { - return Future(() => js.context.callMethod('setByName', ['remove', id])); + return Future( + () => js.context.callMethod('setByName', ['remove_peer', id])); } bool mainHasHwcodec({dynamic hint}) { @@ -1146,27 +1151,28 @@ class RustdeskImpl { } Future mainSaveAb({required String json, dynamic hint}) { - throw UnimplementedError(); + return Future(() => js.context.callMethod('setByName', ['save_ab', json])); } Future mainClearAb({dynamic hint}) { - throw UnimplementedError(); + return Future(() => js.context.callMethod('setByName', ['clear_ab'])); } Future mainLoadAb({dynamic hint}) { - throw UnimplementedError(); + return Future(() => js.context.callMethod('getByName', ['load_ab'])); } Future mainSaveGroup({required String json, dynamic hint}) { - throw UnimplementedError(); + return Future( + () => js.context.callMethod('setByName', ['save_group', json])); } Future mainClearGroup({dynamic hint}) { - throw UnimplementedError(); + return Future(() => js.context.callMethod('setByName', ['clear_group'])); } Future mainLoadGroup({dynamic hint}) { - throw UnimplementedError(); + return Future(() => js.context.callMethod('getByName', ['load_group'])); } Future sessionSendPointer(