|
|
@@ -0,0 +1,39 @@
|
|
|
+import 'package:dsbridge_flutter/dsbridge_flutter.dart';
|
|
|
+import 'package:electronic_assistant/base/base_controller.dart';
|
|
|
+import 'package:electronic_assistant/module/talk/mindview/js_api.dart';
|
|
|
+import 'package:webview_flutter/webview_flutter.dart';
|
|
|
+import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';
|
|
|
+
|
|
|
+class MindViewController extends BaseController {
|
|
|
+ late final DWebViewController webViewController;
|
|
|
+
|
|
|
+ @override
|
|
|
+ void onInit() {
|
|
|
+ super.onInit();
|
|
|
+ late final PlatformWebViewControllerCreationParams params;
|
|
|
+ if (WebViewPlatform.instance is WebKitWebViewPlatform) {
|
|
|
+ params = WebKitWebViewControllerCreationParams(
|
|
|
+ allowsInlineMediaPlayback: true,
|
|
|
+ mediaTypesRequiringUserAction: const <PlaybackMediaTypes>{},
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ params = const PlatformWebViewControllerCreationParams();
|
|
|
+ }
|
|
|
+ webViewController = DWebViewController.fromPlatformCreationParams(params);
|
|
|
+ webViewController.setJavaScriptMode(JavaScriptMode.unrestricted);
|
|
|
+ webViewController.enableZoom(false);
|
|
|
+ webViewController.loadRequest(Uri.parse('http://192.168.10.144:9528'));
|
|
|
+
|
|
|
+ webViewController.addJavaScriptObject(JsMindApi());
|
|
|
+ // webViewController.callHandler(JsMindApi.functionUpdateMind, args: []);
|
|
|
+ Future.delayed(const Duration(seconds: 1), () {
|
|
|
+ webViewController
|
|
|
+ .callHandler(JsMindApi.functionExport, args: ['test.svg']);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ void onReady() {
|
|
|
+ super.onReady();
|
|
|
+ }
|
|
|
+}
|