Compare commits
	
		
			No commits in common. "bda8bb557087de8af8fdf1142d030fddd4d2d805" and "cef32273752e8418dcac573f7c10880f7e4f8c60" have entirely different histories.
		
	
	
		
			bda8bb5570
			...
			cef3227375
		
	
		|  | @ -1,102 +1,20 @@ | ||||||
| class JavaScriptString { | class JavaScriptString { | ||||||
|   /// 点击监听 |   /// 点击监听 | ||||||
|   static String clickEventJSString = |   static String clickEventkJSString = | ||||||
|       '''document.addEventListener('click', function(event) { |       '''document.addEventListener('click', function(event) { | ||||||
|   var x = event.clientX; |   var x = event.clientX; | ||||||
|   var y = event.clientY; |   var y = event.clientY; | ||||||
| 
 | 
 | ||||||
|   console.log('点击坐标:x=' + x + ', y=' + y); |   console.log('点击坐标:x=' + x + ', y=' + y); | ||||||
|   window.flutter_inappwebview.callHandler('click', x, y); |   window.flutter_inappwebview.callHandler('Click', x, y); | ||||||
|    |    | ||||||
| });'''; | });'''; | ||||||
| 
 | 
 | ||||||
|   /// 触摸监听 |  | ||||||
|   static String touchendEventJSString = |  | ||||||
|       '''document.addEventListener('touchend', function(event) { |  | ||||||
|   var x = event.changedTouches[0].clientX; |  | ||||||
|   var y = event.changedTouches[0].clientY; |  | ||||||
|    |  | ||||||
|   // 获取目标元素 |  | ||||||
|     var target = event.target; |  | ||||||
|      |  | ||||||
|     // 获取目标元素的class和id |  | ||||||
|     var targetClass = target.className; |  | ||||||
|     var targetId = target.id; |  | ||||||
|      |  | ||||||
|     console.log('Class: ' + targetClass); |  | ||||||
|     console.log('Id: ' + targetId); |  | ||||||
| 
 |  | ||||||
|   console.log('触摸坐标:x=' + x + ', y=' + y); |  | ||||||
|   window.flutter_inappwebview.callHandler('touchend', x, y); |  | ||||||
|    |  | ||||||
| });'''; |  | ||||||
| 
 |  | ||||||
|   /// 退出登录 |  | ||||||
|   static String loginOutJsString = ''' |  | ||||||
|         \$.ajax({ |  | ||||||
|             type: "GET", |  | ||||||
|             url: "/api/logout.do", |  | ||||||
|             success: function(t) { |  | ||||||
|                 "index.html" != location.pathname ? window.location.href = "index.html" : location.reload() |  | ||||||
|             }, |  | ||||||
|             error: function(t) { |  | ||||||
|                 var e = \$.parseJSON(t.responseText + ""); |  | ||||||
|                 alert(e.msg, 2) |  | ||||||
|             } |  | ||||||
|         }) |  | ||||||
|     '''; |  | ||||||
| 
 |  | ||||||
|   /// 模拟点击 |   /// 模拟点击 | ||||||
|   static String clickJSString(int x, int y) { |   static String clickJSString(int x, int y) { | ||||||
|     return 'document.elementFromPoint($x, $y).click();'; |     return 'document.elementFromPoint($x, $y).click();'; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /// 模拟触摸 |  | ||||||
|   static String touchendJsString(int x, int y) { |  | ||||||
|     return ''' |  | ||||||
|      |  | ||||||
|     '''; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   /// 模拟触摸 |  | ||||||
|   static String getClassTouchendJsString(int x, int y) { |  | ||||||
|     return ''' |  | ||||||
|     try{ |  | ||||||
|     // 获取鼠标点击位置的坐标 |  | ||||||
| var x = $x; |  | ||||||
| var y = $y; |  | ||||||
| 
 |  | ||||||
| // 创建一个touchstart事件 |  | ||||||
| var touchstartEvent = new TouchEvent('touchstart', { |  | ||||||
|   bubbles: true, |  | ||||||
|   cancelable: true, |  | ||||||
|   view: window, |  | ||||||
|   changedTouches: [new Touch({ identifier: Date.now(), target: document.body, clientX: x, clientY: y })], |  | ||||||
|   targetTouches: [new Touch({ identifier: Date.now(), target: document.body, clientX: x, clientY: y })] |  | ||||||
| }); |  | ||||||
| 
 |  | ||||||
| // touchstartEvent |  | ||||||
| document.body.dispatchEvent(touchstartEvent); |  | ||||||
| 
 |  | ||||||
| // 创建一个touchend事件 |  | ||||||
| var touchendEvent = new TouchEvent('touchend', { |  | ||||||
|   bubbles: true, |  | ||||||
|   cancelable: true, |  | ||||||
|   view: window, |  | ||||||
|   changedTouches: [new Touch({ identifier: Date.now(), target: document.body, clientX: x, clientY: y })], |  | ||||||
|   targetTouches: [new Touch({ identifier: Date.now(), target: document.body, clientX: x, clientY: y })] |  | ||||||
| }); |  | ||||||
| 
 |  | ||||||
| // 触发touchend事件 |  | ||||||
| document.body.dispatchEvent(touchendEvent); |  | ||||||
| 
 |  | ||||||
| } catch (t) { |  | ||||||
|                 console.log('模拟触摸错误 -- ' + t); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|     '''; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   /// 输入 |   /// 输入 | ||||||
|   static String inputJsString(int value) { |   static String inputJsString(int value) { | ||||||
|     return ''' |     return ''' | ||||||
|  | @ -106,7 +24,7 @@ var inputEvent = new Event('input', { | ||||||
|   cancelable: true, |   cancelable: true, | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| var inputElement = document.querySelector(".input"); | var inputElement = document.querySelector(".bet-money"); | ||||||
| 
 | 
 | ||||||
| inputElement.value = "$value"; | inputElement.value = "$value"; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,12 +1,8 @@ | ||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| import 'package:web_synchronization_tool/main_page.dart'; | import 'package:web_synchronization_tool/main_page.dart'; | ||||||
| import 'package:web_synchronization_tool/windows/windows_main_page.dart'; | import 'package:web_synchronization_tool/windows/windows_main_page.dart'; | ||||||
| import 'package:webview_windows/webview_windows.dart'; |  | ||||||
| 
 |  | ||||||
| void main() async { |  | ||||||
| 
 |  | ||||||
|   // await InAppWebViewController.setWebContentsDebuggingEnabled(true); |  | ||||||
| 
 | 
 | ||||||
|  | void main() { | ||||||
|   runApp(const MyApp()); |   runApp(const MyApp()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -22,8 +18,8 @@ class MyApp extends StatelessWidget { | ||||||
|         colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), |         colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), | ||||||
|         useMaterial3: true, |         useMaterial3: true, | ||||||
|       ), |       ), | ||||||
|       // home: const MainPage(), |       home: const MainPage(), | ||||||
|       home: const WindowsPage(), |       // home: const WindowsPage(), | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,145 +1,116 @@ | ||||||
| // | import 'package:flutter/material.dart'; | ||||||
| // import 'package:flutter/material.dart'; | import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||||||
| // import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | import 'package:web_synchronization_tool/web_widget.dart'; | ||||||
| // import 'package:web_synchronization_tool/web_widget.dart'; | 
 | ||||||
| // | import 'JavaScriptString.dart'; | ||||||
| // import 'JavaScriptString.dart'; | 
 | ||||||
| // | class MainPage extends StatefulWidget { | ||||||
| // class MainPage extends StatefulWidget { |   const MainPage({super.key}); | ||||||
| //   const MainPage({super.key}); | 
 | ||||||
| // |   @override | ||||||
| //   @override |   State<MainPage> createState() => _MainPageState(); | ||||||
| //   State<MainPage> createState() => _MainPageState(); | } | ||||||
| // } | 
 | ||||||
| // | class _MainPageState extends State<MainPage> { | ||||||
| // class _MainPageState extends State<MainPage> { | 
 | ||||||
| // |   late InAppWebViewController mainController; | ||||||
| //   late InAppWebViewController mainController; |   late InAppWebViewController controller; | ||||||
| //   late InAppWebViewController controller; | 
 | ||||||
| // |   @override | ||||||
| //   bool asyncState = false; |   void initState() { | ||||||
| // |     super.initState(); | ||||||
| //   @override | 
 | ||||||
| //   void initState() { | 
 | ||||||
| //     super.initState(); |   } | ||||||
| // | 
 | ||||||
| //   } |   /// 注入点击监听 | ||||||
| // |   addClickEventJS(){ | ||||||
| //   @override | 
 | ||||||
| //   void dispose() { |     final clickJsUS = UserScript(groupName: 'click',source: JavaScriptString.clickEventkJSString, injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START); | ||||||
| //     super.dispose(); | 
 | ||||||
| // |     mainController.addUserScript(userScript: clickJsUS); | ||||||
| //     WebStorageManager.instance().deleteAllData(); | 
 | ||||||
| //   } |     mainController.addJavaScriptHandler(handlerName: 'Click', callback: (args){ | ||||||
| // |       controller.evaluateJavascript(source: JavaScriptString.clickJSString(args.first, args.last) ); | ||||||
| //   /// 注入触摸监听 |     }); | ||||||
| //   addTouchendEventJS(){ | 
 | ||||||
| // |   } | ||||||
| //     final clickJsUS = UserScript(groupName: 'touchend',source: JavaScriptString.touchendEventJSString, injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START); | 
 | ||||||
| //     mainController.addUserScript(userScript: clickJsUS); |   @override | ||||||
| // |   Widget build(BuildContext context) { | ||||||
| //     mainController.addJavaScriptHandler(handlerName: 'touchend', callback: (args){ |     return Scaffold( | ||||||
| //       if (asyncState){ |       body: Column( | ||||||
| //         int x = double.parse(args.first.toString()).toInt(); |         children: [ | ||||||
| //         int y = double.parse(args.last.toString()).toInt(); |           Container( | ||||||
| //         controller.evaluateJavascript(source: JavaScriptString.clickJSString(x, y) ); |             height: 50, | ||||||
| //         // controller.evaluateJavascript(source: JavaScriptString.touchendJsString(x, y) ); |             color: Colors.white, | ||||||
| //         // controller.evaluateJavascript(source: JavaScriptString.getClassTouchendJsString(x, y) ); |             padding: const EdgeInsets.symmetric(horizontal: 50), | ||||||
| //       } |             child: Row( | ||||||
| //     }); |               children: [ | ||||||
| // |                 TextButton( | ||||||
| //   } |                     onPressed: () { | ||||||
| // |                       controller.evaluateJavascript(source: JavaScriptString.clickJSString(600, 280) ); | ||||||
| //   @override |                     }, | ||||||
| //   Widget build(BuildContext context) { |                     child: const Text('模拟点击测试')), | ||||||
| //     return Scaffold( |                 TextButton( | ||||||
| //       body: Column( |                     onPressed: () { | ||||||
| //         crossAxisAlignment: CrossAxisAlignment.stretch, |                       mainController.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); | ||||||
| //         children: [ |                       controller.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); | ||||||
| //           Container( |                     }, | ||||||
| //             height: 50, |                     child: const Text('模拟输入测试')), | ||||||
| //             color: Colors.white, |                 const SizedBox( | ||||||
| //             padding: const EdgeInsets.symmetric(horizontal: 50), |                   width: 50, | ||||||
| //             child: Row( |                   child: TextField( | ||||||
| //               children: [ |                     keyboardType: TextInputType.number, | ||||||
| //                 TextButton( |                     decoration: InputDecoration(prefixText: '网页数量'), | ||||||
| //                     onPressed: () { |                   ), | ||||||
| //                       controller.evaluateJavascript(source: JavaScriptString.clickJSString(50, 100) ); |                 ) | ||||||
| //                     }, |               ], | ||||||
| //                     child: const Text('模拟点击测试')), |             ), | ||||||
| //                 TextButton( |           ), | ||||||
| //                     onPressed: () { |           Expanded(child: pageViewWidget()), | ||||||
| //                       mainController.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); |         ], | ||||||
| //                       controller.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); |       ), | ||||||
| //                     }, |     ); | ||||||
| //                     child: const Text('模拟输入测试')), |   } | ||||||
| //                 Row( | 
 | ||||||
| //                   children: [ |   Widget pageViewWidget() { | ||||||
| //                     const Text('同步'), |     return PageView( | ||||||
| //                     Switch(value: asyncState, onChanged: (value){ |       children: <Widget>[ | ||||||
| //                       setState(() { |         KeepAlivePage( | ||||||
| //                         asyncState = value; |           child: WebWidget(controlerCallBack: (_mainController) { | ||||||
| //                       }); |             mainController = _mainController; | ||||||
| //                     }) |            | ||||||
| //                   ], |             addClickEventJS(); | ||||||
| //                 ) |           }), | ||||||
| //               ], |         ), | ||||||
| //             ), |         KeepAlivePage( | ||||||
| //           ), |           child: WebWidget(controlerCallBack: (_controller) { | ||||||
| //           Expanded(child: pageViewWidget()), |             controller = _controller; | ||||||
| //         ], |           }), | ||||||
| //       ), |         ) | ||||||
| //     ); |       ], | ||||||
| //   } |     ); | ||||||
| // |   } | ||||||
| //   Widget pageViewWidget() { | 
 | ||||||
| //     return Row( | } | ||||||
| //       children: <Widget>[ | 
 | ||||||
| //         Expanded( | class KeepAlivePage extends StatefulWidget { | ||||||
| //           child: Container( |   final Widget child; | ||||||
| //             color: Colors.yellow, | 
 | ||||||
| //             child: KeepAlivePage( |   KeepAlivePage({super.key , required this.child}); | ||||||
| //               child: WebWidget(controlerCallBack: (_mainController) { | 
 | ||||||
| //                 mainController = _mainController; |   @override | ||||||
| // |   _KeepAlivePageState createState() => _KeepAlivePageState(); | ||||||
| //                 addTouchendEventJS(); | } | ||||||
| // | 
 | ||||||
| //               }), | class _KeepAlivePageState extends State<KeepAlivePage> with AutomaticKeepAliveClientMixin { | ||||||
| //             ), |   @override | ||||||
| //           ), |   bool get wantKeepAlive => true; | ||||||
| //         ), | 
 | ||||||
| //         Expanded( |   @override | ||||||
| //           child: Container( |   Widget build(BuildContext context) { | ||||||
| //             color: Colors.blue, |     super.build(context); | ||||||
| //             child: KeepAlivePage( |     return widget.child; | ||||||
| //               child: WebWidget(controlerCallBack: (_controller) { |   } | ||||||
| //                 controller = _controller; | } | ||||||
| //               }), |  | ||||||
| //             ), |  | ||||||
| //           ), |  | ||||||
| //         ) |  | ||||||
| //       ], |  | ||||||
| //     ); |  | ||||||
| //   } |  | ||||||
| // |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // class KeepAlivePage extends StatefulWidget { |  | ||||||
| //   final Widget child; |  | ||||||
| // |  | ||||||
| //   KeepAlivePage({super.key , required this.child}); |  | ||||||
| // |  | ||||||
| //   @override |  | ||||||
| //   _KeepAlivePageState createState() => _KeepAlivePageState(); |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // class _KeepAlivePageState extends State<KeepAlivePage> with AutomaticKeepAliveClientMixin { |  | ||||||
| //   @override |  | ||||||
| //   bool get wantKeepAlive => true; |  | ||||||
| // |  | ||||||
| //   @override |  | ||||||
| //   Widget build(BuildContext context) { |  | ||||||
| //     super.build(context); |  | ||||||
| //     return widget.child; |  | ||||||
| //   } |  | ||||||
| // } |  | ||||||
|  |  | ||||||
|  | @ -1,42 +1,31 @@ | ||||||
| // import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| // import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||||||
| // import 'package:web_synchronization_tool/JavaScriptString.dart'; | import 'package:web_synchronization_tool/JavaScriptString.dart'; | ||||||
| // | 
 | ||||||
| // class WebWidget extends StatefulWidget { | class WebWidget extends StatefulWidget { | ||||||
| //   WebWidget({super.key, required this.controlerCallBack}); |   WebWidget({super.key, required this.controlerCallBack}); | ||||||
| // | 
 | ||||||
| //   final Function(InAppWebViewController) controlerCallBack; |   final Function(InAppWebViewController) controlerCallBack; | ||||||
| // | 
 | ||||||
| //   @override |   @override | ||||||
| //   State<WebWidget> createState() => _WebWidgetState(); |   State<WebWidget> createState() => _WebWidgetState(); | ||||||
| // } | } | ||||||
| // | 
 | ||||||
| // class _WebWidgetState extends State<WebWidget> { | class _WebWidgetState extends State<WebWidget> { | ||||||
| //   @override |   @override | ||||||
| //   void initState() { |   void initState() { | ||||||
| //     super.initState(); |     super.initState(); | ||||||
| //   } |   } | ||||||
| // | 
 | ||||||
| //   @override |   @override | ||||||
| //   Widget build(BuildContext context) { |   Widget build(BuildContext context) { | ||||||
| //     return InAppWebView( |     return InAppWebView( | ||||||
| //       initialUrlRequest: |       initialUrlRequest: | ||||||
| //       URLRequest(url: WebUri('http://www.df6831.com/mobile')),// |           URLRequest(url: WebUri('http://www.df6831.com/game/')), | ||||||
| //       initialSettings: InAppWebViewSettings( |       initialSettings: InAppWebViewSettings(initialScale: 200,loadWithOverviewMode: false,useWideViewPort: false), | ||||||
| //         // initialScale: 180, |       onWebViewCreated: (_controller) { | ||||||
| //         loadWithOverviewMode: false, |         widget.controlerCallBack(_controller); | ||||||
| //         useWideViewPort: false, |       }, | ||||||
| //         // preferredContentMode: UserPreferredContentMode.MOBILE, |     ); | ||||||
| //         // cacheEnabled: false, //启用缓存 |   } | ||||||
| //         // clearSessionCache: true,//清除会话缓存 | } | ||||||
| //         // databaseEnabled:false, // 启用数据库 |  | ||||||
| //         // domStorageEnabled: false,//启用 dom 存储 |  | ||||||
| //         incognito: true, //隐身模式 |  | ||||||
| //         sharedCookiesEnabled: false, // 共享Cookie |  | ||||||
| //       ), |  | ||||||
| //       onWebViewCreated: (_controller) { |  | ||||||
| //         widget.controlerCallBack(_controller); |  | ||||||
| //       }, |  | ||||||
| //     ); |  | ||||||
| //   } |  | ||||||
| // } |  | ||||||
|  |  | ||||||
|  | @ -1,56 +0,0 @@ | ||||||
| class WindowsJs { |  | ||||||
|   /// 点击监听 |  | ||||||
|   static String clickEventJs = ''' |  | ||||||
|     document.addEventListener('click', function(event) { |  | ||||||
|     var x = event.clientX; |  | ||||||
|     var y = event.clientY; |  | ||||||
| 
 |  | ||||||
|     var value = {"x":x,"y":y}; |  | ||||||
|     window.chrome.webview.postMessage(value); |  | ||||||
|      |  | ||||||
|     // 检查点击的元素是否有类名为 'btn' |  | ||||||
|   if (event.target.classList.contains('btn')) { |  | ||||||
|     // 获取按钮上显示的文本内容 |  | ||||||
|     var buttonText = event.target.innerText; |  | ||||||
|      |  | ||||||
|     var btn = {"x":"成功获取到btn","y":buttonText}; |  | ||||||
|     window.chrome.webview.postMessage(btn); |  | ||||||
|      |  | ||||||
|     // 阻止默认的链接跳转行为 |  | ||||||
|     event.preventDefault(); |  | ||||||
|      |  | ||||||
|     // 在当前窗口打开目标地址 |  | ||||||
|     window.location.href = "http://www.df6831.com/game/"; |  | ||||||
|      |  | ||||||
|   } |  | ||||||
|      |  | ||||||
|   });'''; |  | ||||||
| 
 |  | ||||||
|   /// 模拟点击 |  | ||||||
|   static String clickJs(int x, int y) { |  | ||||||
|     return 'document.elementFromPoint($x, $y).click();'; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   /// 输入 |  | ||||||
|   static String inputJsString(int value) { |  | ||||||
|     return ''' |  | ||||||
|       var inputEvent = new Event('input', { |  | ||||||
|         bubbles: true, |  | ||||||
|         cancelable: true, |  | ||||||
|       }); |  | ||||||
|       var inputElement = document.querySelector(".input"); |  | ||||||
|       inputElement.value = "$value"; |  | ||||||
|       inputElement.dispatchEvent(inputEvent); |  | ||||||
|     '''; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   static String zoom(int zoom){ |  | ||||||
|     assert(zoom >= 1 && zoom <= 100, 'zoom 1 到 100'); |  | ||||||
|     return ''' |  | ||||||
|       // document.body.style.zoom = "$zoom%"; |  | ||||||
|       document.body.style.transformOrigin = 'top left'; |  | ||||||
|       document.body.style.transform = 'scale(${zoom / 100})'; |  | ||||||
|     '''; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| import 'package:web_synchronization_tool/windows/windowsJs.dart'; |  | ||||||
| import 'windows_web_page.dart'; | import 'windows_web_page.dart'; | ||||||
| import 'package:webview_windows/webview_windows.dart'; | import 'package:webview_windows/webview_windows.dart'; | ||||||
| 
 | 
 | ||||||
|  | @ -26,7 +25,6 @@ class _WindowsPageState extends State<WindowsPage> { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Future controllerInit() async { |   Future controllerInit() async { | ||||||
| 
 |  | ||||||
|     await mainController.initialize(); |     await mainController.initialize(); | ||||||
|     await controller.initialize(); |     await controller.initialize(); | ||||||
| 
 | 
 | ||||||
|  | @ -35,6 +33,7 @@ class _WindowsPageState extends State<WindowsPage> { | ||||||
|     controller.clearCache(); |     controller.clearCache(); | ||||||
|     controller.clearCookies(); |     controller.clearCookies(); | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|     mainController.loadUrl('http://www.df6831.com/'); |     mainController.loadUrl('http://www.df6831.com/'); | ||||||
|     controller.loadUrl('http://www.df6831.com/'); |     controller.loadUrl('http://www.df6831.com/'); | ||||||
| 
 | 
 | ||||||
|  | @ -43,27 +42,22 @@ class _WindowsPageState extends State<WindowsPage> { | ||||||
|     setState(() { |     setState(() { | ||||||
|       initDone = true; |       initDone = true; | ||||||
|     }); |     }); | ||||||
| 
 |  | ||||||
|     // controller.setUserAgent('Mobile'); |  | ||||||
| 
 |  | ||||||
|     /// 通道消息 |  | ||||||
|     mainController.webMessage.listen((event) { |  | ||||||
|       print('mainController listen -- $event'); |  | ||||||
|       controller.executeScript(WindowsJs.clickJs(event['x'], event['y'])); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     /// 通道消息 |  | ||||||
|     controller.webMessage.listen((event) { |  | ||||||
|       // print('controller listen -- $event'); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /// 注入点击监听 |   /// 注入点击监听 | ||||||
|   addClickEventJS() { |   addClickEventJS() { | ||||||
|     mainController.addScriptToExecuteOnDocumentCreated(WindowsJs.clickEventJs); | 
 | ||||||
|     controller.addScriptToExecuteOnDocumentCreated(WindowsJs.clickEventJs); |     controller.executeScript('document.documentElement.innerHTML').then((value){ | ||||||
|  |       print(value); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     mainController.addScriptToExecuteOnDocumentCreated( | ||||||
|  |         JavaScriptString.clickEventkJSString).then((value){ | ||||||
|  |           print(value); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|  | @ -81,39 +75,33 @@ class _WindowsPageState extends State<WindowsPage> { | ||||||
|               children: [ |               children: [ | ||||||
|                 TextButton( |                 TextButton( | ||||||
|                     onPressed: () { |                     onPressed: () { | ||||||
|                       mainController.executeScript(WindowsJs.clickJs(200, 900)); |                       controller.executeScript( | ||||||
|                       // controller.executeScript(WindowsJs.clickJs(600, 100)); |                           JavaScriptString.clickJSString(600, 280)).then((value){ | ||||||
|  |                             print(value); | ||||||
|  |                       }); | ||||||
|                     }, |                     }, | ||||||
|                     child: const Text('模拟点击测试')), |                     child: const Text('模拟点击测试')), | ||||||
|                 TextButton( |                 TextButton( | ||||||
|                     onPressed: () { |                     onPressed: () { | ||||||
|                       mainController.executeScript(WindowsJs.inputJsString(45)); |                       mainController | ||||||
|                       controller.executeScript(WindowsJs.inputJsString(45)); |                           .executeScript(JavaScriptString.inputJsString(45)); | ||||||
|  |                       controller | ||||||
|  |                           .executeScript(JavaScriptString.inputJsString(45)); | ||||||
|                     }, |                     }, | ||||||
|                     child: const Text('模拟输入测试')), |                     child: const Text('模拟输入测试')), | ||||||
|                 TextButton( |                 TextButton( | ||||||
|                     onPressed: () { |                     onPressed: () { | ||||||
|                       mainController.loadUrl('http://www.df6831.com/'); |                       mainController.loadUrl('http://www.df6831.com/game/'); | ||||||
|  |                       // controller.loadUrl('http://www.df6831.com/game/'); | ||||||
|                     }, |                     }, | ||||||
|                     child: const Text('跳转首页')), |                     child: const Text('跳转')), | ||||||
|                 TextButton( |                 const SizedBox( | ||||||
|                     onPressed: () { |                   width: 50, | ||||||
|                       mainController.executeScript(WindowsJs.zoom(70)); |                   child: TextField( | ||||||
|                       controller.executeScript(WindowsJs.zoom(40)); |                     keyboardType: TextInputType.number, | ||||||
|                     }, |                     decoration: InputDecoration(prefixText: '网页数量'), | ||||||
|                     child: const Text('缩放')), |                   ), | ||||||
|                 TextButton( |                 ) | ||||||
|                     onPressed: () { |  | ||||||
|                       mainController.openDevTools(); |  | ||||||
|                     }, |  | ||||||
|                     child: const Text('开发者')), |  | ||||||
|                 TextButton( |  | ||||||
|                     onPressed: () { |  | ||||||
|                       mainController.clearCookies(); |  | ||||||
|                       mainController.clearCache(); |  | ||||||
|                     }, |  | ||||||
|                     child: const Text('清除缓存')), |  | ||||||
| 
 |  | ||||||
|               ], |               ], | ||||||
|             ), |             ), | ||||||
|           ), |           ), | ||||||
|  | @ -127,16 +115,12 @@ class _WindowsPageState extends State<WindowsPage> { | ||||||
|   Widget pageViewWidget() { |   Widget pageViewWidget() { | ||||||
|     return Row( |     return Row( | ||||||
|       children: [ |       children: [ | ||||||
|         SizedBox( |         Expanded( | ||||||
|           width: 1000, |  | ||||||
|           height: 1000, |  | ||||||
|           child: WindowsWebWidget( |           child: WindowsWebWidget( | ||||||
|             controller: mainController, |             controller: mainController, | ||||||
|           ), |           ), | ||||||
|         ), |         ), | ||||||
|         SizedBox( |         Expanded( | ||||||
|           width: 500, |  | ||||||
|           height:400, |  | ||||||
|           child: WindowsWebWidget( |           child: WindowsWebWidget( | ||||||
|             controller: controller, |             controller: controller, | ||||||
|           ), |           ), | ||||||
|  |  | ||||||
|  | @ -21,7 +21,7 @@ class _WindowsWebWidgetState extends State<WindowsWebWidget> { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Widget inWindowsWebView(){ |   Widget inWindowsWebView(){ | ||||||
|     return Webview(widget.controller); |     return Webview(widget.controller,); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,9 +12,8 @@ dependencies: | ||||||
|     sdk: flutter |     sdk: flutter | ||||||
| 
 | 
 | ||||||
|   cupertino_icons: ^1.0.2 |   cupertino_icons: ^1.0.2 | ||||||
|   webview_windows: |   flutter_inappwebview: ^6.0.0 | ||||||
|     path: ../flutter-webview-windows-main |   webview_windows: ^0.4.0 | ||||||
|   window_manager: |  | ||||||
| 
 | 
 | ||||||
| dev_dependencies: | dev_dependencies: | ||||||
|   flutter_test: |   flutter_test: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue