Web password source (#9618)

* ensure window init finish

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

* web password source

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

---------

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-10-11 09:52:09 +08:00 committed by GitHub
parent 22c84bbbd1
commit 97f02ed25e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 10 deletions

View File

@ -2383,7 +2383,7 @@ connect(BuildContext context, String id,
), ),
); );
} else { } else {
if (isWebDesktop) { if (isWeb) {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(

View File

@ -372,7 +372,7 @@ class FfiModel with ChangeNotifier {
} else if (name == 'plugin_option') { } else if (name == 'plugin_option') {
handleOption(evt); handleOption(evt);
} else if (name == "sync_peer_hash_password_to_personal_ab") { } else if (name == "sync_peer_hash_password_to_personal_ab") {
if (desktopType == DesktopType.main) { if (desktopType == DesktopType.main || isWeb) {
final id = evt['id']; final id = evt['id'];
final hash = evt['hash']; final hash = evt['hash'];
if (id != null && hash != null) { if (id != null && hash != null) {

View File

@ -1,6 +1,7 @@
// ignore_for_file: avoid_web_libraries_in_flutter // ignore_for_file: avoid_web_libraries_in_flutter
import 'dart:convert'; import 'dart:convert';
import 'dart:js_interop';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:js'; import 'dart:js';
import 'dart:html'; import 'dart:html';
@ -107,6 +108,10 @@ class PlatformFFI {
sessionId: sessionId, display: display, ptr: ptr); sessionId: sessionId, display: display, ptr: ptr);
Future<void> init(String appType) async { Future<void> init(String appType) async {
Completer completer = Completer();
context["onInitFinished"] = () {
completer.complete();
};
context.callMethod('init'); context.callMethod('init');
version = getByName('version'); version = getByName('version');
window.onContextMenu.listen((event) { window.onContextMenu.listen((event) {
@ -121,6 +126,7 @@ class PlatformFFI {
print('json.decode fail(): $e'); print('json.decode fail(): $e');
} }
}; };
return completer.future;
} }
void setEventCallback(void Function(Map<String, dynamic>) fun) { void setEventCallback(void Function(Map<String, dynamic>) fun) {

View File

@ -85,7 +85,11 @@ class RustdeskImpl {
dynamic hint}) { dynamic hint}) {
return js.context.callMethod('setByName', [ return js.context.callMethod('setByName', [
'session_add_sync', 'session_add_sync',
jsonEncode({'id': id, 'password': password}) jsonEncode({
'id': id,
'password': password,
'is_shared_password': isSharedPassword
})
]); ]);
} }
@ -1118,7 +1122,8 @@ class RustdeskImpl {
} }
Future<void> mainRemovePeer({required String id, dynamic hint}) { Future<void> 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}) { bool mainHasHwcodec({dynamic hint}) {
@ -1146,27 +1151,28 @@ class RustdeskImpl {
} }
Future<void> mainSaveAb({required String json, dynamic hint}) { Future<void> mainSaveAb({required String json, dynamic hint}) {
throw UnimplementedError(); return Future(() => js.context.callMethod('setByName', ['save_ab', json]));
} }
Future<void> mainClearAb({dynamic hint}) { Future<void> mainClearAb({dynamic hint}) {
throw UnimplementedError(); return Future(() => js.context.callMethod('setByName', ['clear_ab']));
} }
Future<String> mainLoadAb({dynamic hint}) { Future<String> mainLoadAb({dynamic hint}) {
throw UnimplementedError(); return Future(() => js.context.callMethod('getByName', ['load_ab']));
} }
Future<void> mainSaveGroup({required String json, dynamic hint}) { Future<void> mainSaveGroup({required String json, dynamic hint}) {
throw UnimplementedError(); return Future(
() => js.context.callMethod('setByName', ['save_group', json]));
} }
Future<void> mainClearGroup({dynamic hint}) { Future<void> mainClearGroup({dynamic hint}) {
throw UnimplementedError(); return Future(() => js.context.callMethod('setByName', ['clear_group']));
} }
Future<String> mainLoadGroup({dynamic hint}) { Future<String> mainLoadGroup({dynamic hint}) {
throw UnimplementedError(); return Future(() => js.context.callMethod('getByName', ['load_group']));
} }
Future<void> sessionSendPointer( Future<void> sessionSendPointer(