Compare commits
	
		
			No commits in common. "bda8bb557087de8af8fdf1142d030fddd4d2d805" and "cef32273752e8418dcac573f7c10880f7e4f8c60" have entirely different histories.
		
	
	
		
			bda8bb5570
			...
			cef3227375
		
	
		|  | @ -1,102 +1,20 @@ | |||
| class JavaScriptString { | ||||
|   /// 点击监听 | ||||
|   static String clickEventJSString = | ||||
|   static String clickEventkJSString = | ||||
|       '''document.addEventListener('click', function(event) { | ||||
|   var x = event.clientX; | ||||
|   var y = event.clientY; | ||||
| 
 | ||||
|   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) { | ||||
|     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) { | ||||
|     return ''' | ||||
|  | @ -106,7 +24,7 @@ var inputEvent = new Event('input', { | |||
|   cancelable: true, | ||||
| }); | ||||
| 
 | ||||
| var inputElement = document.querySelector(".input"); | ||||
| var inputElement = document.querySelector(".bet-money"); | ||||
| 
 | ||||
| inputElement.value = "$value"; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,12 +1,8 @@ | |||
| import 'package:flutter/material.dart'; | ||||
| import 'package:web_synchronization_tool/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()); | ||||
| } | ||||
| 
 | ||||
|  | @ -22,8 +18,8 @@ class MyApp extends StatelessWidget { | |||
|         colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), | ||||
|         useMaterial3: true, | ||||
|       ), | ||||
|       // home: const MainPage(), | ||||
|       home: const WindowsPage(), | ||||
|       home: const MainPage(), | ||||
|       // home: const WindowsPage(), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -1,145 +1,116 @@ | |||
| // | ||||
| // import 'package:flutter/material.dart'; | ||||
| // import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||||
| // import 'package:web_synchronization_tool/web_widget.dart'; | ||||
| // | ||||
| // import 'JavaScriptString.dart'; | ||||
| // | ||||
| // class MainPage extends StatefulWidget { | ||||
| //   const MainPage({super.key}); | ||||
| // | ||||
| //   @override | ||||
| //   State<MainPage> createState() => _MainPageState(); | ||||
| // } | ||||
| // | ||||
| // class _MainPageState extends State<MainPage> { | ||||
| // | ||||
| //   late InAppWebViewController mainController; | ||||
| //   late InAppWebViewController controller; | ||||
| // | ||||
| //   bool asyncState = false; | ||||
| // | ||||
| //   @override | ||||
| //   void initState() { | ||||
| //     super.initState(); | ||||
| // | ||||
| //   } | ||||
| // | ||||
| //   @override | ||||
| //   void dispose() { | ||||
| //     super.dispose(); | ||||
| // | ||||
| //     WebStorageManager.instance().deleteAllData(); | ||||
| //   } | ||||
| // | ||||
| //   /// 注入触摸监听 | ||||
| //   addTouchendEventJS(){ | ||||
| // | ||||
| //     final clickJsUS = UserScript(groupName: 'touchend',source: JavaScriptString.touchendEventJSString, injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START); | ||||
| //     mainController.addUserScript(userScript: clickJsUS); | ||||
| // | ||||
| //     mainController.addJavaScriptHandler(handlerName: 'touchend', callback: (args){ | ||||
| //       if (asyncState){ | ||||
| //         int x = double.parse(args.first.toString()).toInt(); | ||||
| //         int y = double.parse(args.last.toString()).toInt(); | ||||
| //         controller.evaluateJavascript(source: JavaScriptString.clickJSString(x, y) ); | ||||
| //         // controller.evaluateJavascript(source: JavaScriptString.touchendJsString(x, y) ); | ||||
| //         // controller.evaluateJavascript(source: JavaScriptString.getClassTouchendJsString(x, y) ); | ||||
| //       } | ||||
| //     }); | ||||
| // | ||||
| //   } | ||||
| // | ||||
| //   @override | ||||
| //   Widget build(BuildContext context) { | ||||
| //     return Scaffold( | ||||
| //       body: Column( | ||||
| //         crossAxisAlignment: CrossAxisAlignment.stretch, | ||||
| //         children: [ | ||||
| //           Container( | ||||
| //             height: 50, | ||||
| //             color: Colors.white, | ||||
| //             padding: const EdgeInsets.symmetric(horizontal: 50), | ||||
| //             child: Row( | ||||
| //               children: [ | ||||
| //                 TextButton( | ||||
| //                     onPressed: () { | ||||
| //                       controller.evaluateJavascript(source: JavaScriptString.clickJSString(50, 100) ); | ||||
| //                     }, | ||||
| //                     child: const Text('模拟点击测试')), | ||||
| //                 TextButton( | ||||
| //                     onPressed: () { | ||||
| //                       mainController.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); | ||||
| //                       controller.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); | ||||
| //                     }, | ||||
| //                     child: const Text('模拟输入测试')), | ||||
| //                 Row( | ||||
| //                   children: [ | ||||
| //                     const Text('同步'), | ||||
| //                     Switch(value: asyncState, onChanged: (value){ | ||||
| //                       setState(() { | ||||
| //                         asyncState = value; | ||||
| //                       }); | ||||
| //                     }) | ||||
| //                   ], | ||||
| //                 ) | ||||
| //               ], | ||||
| //             ), | ||||
| //           ), | ||||
| //           Expanded(child: pageViewWidget()), | ||||
| //         ], | ||||
| //       ), | ||||
| //     ); | ||||
| //   } | ||||
| // | ||||
| //   Widget pageViewWidget() { | ||||
| //     return Row( | ||||
| //       children: <Widget>[ | ||||
| //         Expanded( | ||||
| //           child: Container( | ||||
| //             color: Colors.yellow, | ||||
| //             child: KeepAlivePage( | ||||
| //               child: WebWidget(controlerCallBack: (_mainController) { | ||||
| //                 mainController = _mainController; | ||||
| // | ||||
| //                 addTouchendEventJS(); | ||||
| // | ||||
| //               }), | ||||
| //             ), | ||||
| //           ), | ||||
| //         ), | ||||
| //         Expanded( | ||||
| //           child: Container( | ||||
| //             color: Colors.blue, | ||||
| //             child: KeepAlivePage( | ||||
| //               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; | ||||
| //   } | ||||
| // } | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||||
| import 'package:web_synchronization_tool/web_widget.dart'; | ||||
| 
 | ||||
| import 'JavaScriptString.dart'; | ||||
| 
 | ||||
| class MainPage extends StatefulWidget { | ||||
|   const MainPage({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   State<MainPage> createState() => _MainPageState(); | ||||
| } | ||||
| 
 | ||||
| class _MainPageState extends State<MainPage> { | ||||
| 
 | ||||
|   late InAppWebViewController mainController; | ||||
|   late InAppWebViewController controller; | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
| 
 | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   /// 注入点击监听 | ||||
|   addClickEventJS(){ | ||||
| 
 | ||||
|     final clickJsUS = UserScript(groupName: 'click',source: JavaScriptString.clickEventkJSString, injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START); | ||||
| 
 | ||||
|     mainController.addUserScript(userScript: clickJsUS); | ||||
| 
 | ||||
|     mainController.addJavaScriptHandler(handlerName: 'Click', callback: (args){ | ||||
|       controller.evaluateJavascript(source: JavaScriptString.clickJSString(args.first, args.last) ); | ||||
|     }); | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Scaffold( | ||||
|       body: Column( | ||||
|         children: [ | ||||
|           Container( | ||||
|             height: 50, | ||||
|             color: Colors.white, | ||||
|             padding: const EdgeInsets.symmetric(horizontal: 50), | ||||
|             child: Row( | ||||
|               children: [ | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       controller.evaluateJavascript(source: JavaScriptString.clickJSString(600, 280) ); | ||||
|                     }, | ||||
|                     child: const Text('模拟点击测试')), | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       mainController.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); | ||||
|                       controller.evaluateJavascript(source: JavaScriptString.inputJsString(45) ); | ||||
|                     }, | ||||
|                     child: const Text('模拟输入测试')), | ||||
|                 const SizedBox( | ||||
|                   width: 50, | ||||
|                   child: TextField( | ||||
|                     keyboardType: TextInputType.number, | ||||
|                     decoration: InputDecoration(prefixText: '网页数量'), | ||||
|                   ), | ||||
|                 ) | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|           Expanded(child: pageViewWidget()), | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Widget pageViewWidget() { | ||||
|     return PageView( | ||||
|       children: <Widget>[ | ||||
|         KeepAlivePage( | ||||
|           child: WebWidget(controlerCallBack: (_mainController) { | ||||
|             mainController = _mainController; | ||||
|            | ||||
|             addClickEventJS(); | ||||
|           }), | ||||
|         ), | ||||
|         KeepAlivePage( | ||||
|           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_inappwebview/flutter_inappwebview.dart'; | ||||
| // import 'package:web_synchronization_tool/JavaScriptString.dart'; | ||||
| // | ||||
| // class WebWidget extends StatefulWidget { | ||||
| //   WebWidget({super.key, required this.controlerCallBack}); | ||||
| // | ||||
| //   final Function(InAppWebViewController) controlerCallBack; | ||||
| // | ||||
| //   @override | ||||
| //   State<WebWidget> createState() => _WebWidgetState(); | ||||
| // } | ||||
| // | ||||
| // class _WebWidgetState extends State<WebWidget> { | ||||
| //   @override | ||||
| //   void initState() { | ||||
| //     super.initState(); | ||||
| //   } | ||||
| // | ||||
| //   @override | ||||
| //   Widget build(BuildContext context) { | ||||
| //     return InAppWebView( | ||||
| //       initialUrlRequest: | ||||
| //       URLRequest(url: WebUri('http://www.df6831.com/mobile')),// | ||||
| //       initialSettings: InAppWebViewSettings( | ||||
| //         // initialScale: 180, | ||||
| //         loadWithOverviewMode: false, | ||||
| //         useWideViewPort: false, | ||||
| //         // preferredContentMode: UserPreferredContentMode.MOBILE, | ||||
| //         // cacheEnabled: false, //启用缓存 | ||||
| //         // clearSessionCache: true,//清除会话缓存 | ||||
| //         // databaseEnabled:false, // 启用数据库 | ||||
| //         // domStorageEnabled: false,//启用 dom 存储 | ||||
| //         incognito: true, //隐身模式 | ||||
| //         sharedCookiesEnabled: false, // 共享Cookie | ||||
| //       ), | ||||
| //       onWebViewCreated: (_controller) { | ||||
| //         widget.controlerCallBack(_controller); | ||||
| //       }, | ||||
| //     ); | ||||
| //   } | ||||
| // } | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||||
| import 'package:web_synchronization_tool/JavaScriptString.dart'; | ||||
| 
 | ||||
| class WebWidget extends StatefulWidget { | ||||
|   WebWidget({super.key, required this.controlerCallBack}); | ||||
| 
 | ||||
|   final Function(InAppWebViewController) controlerCallBack; | ||||
| 
 | ||||
|   @override | ||||
|   State<WebWidget> createState() => _WebWidgetState(); | ||||
| } | ||||
| 
 | ||||
| class _WebWidgetState extends State<WebWidget> { | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return InAppWebView( | ||||
|       initialUrlRequest: | ||||
|           URLRequest(url: WebUri('http://www.df6831.com/game/')), | ||||
|       initialSettings: InAppWebViewSettings(initialScale: 200,loadWithOverviewMode: false,useWideViewPort: false), | ||||
|       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:web_synchronization_tool/windows/windowsJs.dart'; | ||||
| import 'windows_web_page.dart'; | ||||
| import 'package:webview_windows/webview_windows.dart'; | ||||
| 
 | ||||
|  | @ -26,7 +25,6 @@ class _WindowsPageState extends State<WindowsPage> { | |||
|   } | ||||
| 
 | ||||
|   Future controllerInit() async { | ||||
| 
 | ||||
|     await mainController.initialize(); | ||||
|     await controller.initialize(); | ||||
| 
 | ||||
|  | @ -35,6 +33,7 @@ class _WindowsPageState extends State<WindowsPage> { | |||
|     controller.clearCache(); | ||||
|     controller.clearCookies(); | ||||
| 
 | ||||
| 
 | ||||
|     mainController.loadUrl('http://www.df6831.com/'); | ||||
|     controller.loadUrl('http://www.df6831.com/'); | ||||
| 
 | ||||
|  | @ -43,27 +42,22 @@ class _WindowsPageState extends State<WindowsPage> { | |||
|     setState(() { | ||||
|       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() { | ||||
|     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 | ||||
|  | @ -81,39 +75,33 @@ class _WindowsPageState extends State<WindowsPage> { | |||
|               children: [ | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       mainController.executeScript(WindowsJs.clickJs(200, 900)); | ||||
|                       // controller.executeScript(WindowsJs.clickJs(600, 100)); | ||||
|                       controller.executeScript( | ||||
|                           JavaScriptString.clickJSString(600, 280)).then((value){ | ||||
|                             print(value); | ||||
|                       }); | ||||
|                     }, | ||||
|                     child: const Text('模拟点击测试')), | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       mainController.executeScript(WindowsJs.inputJsString(45)); | ||||
|                       controller.executeScript(WindowsJs.inputJsString(45)); | ||||
|                       mainController | ||||
|                           .executeScript(JavaScriptString.inputJsString(45)); | ||||
|                       controller | ||||
|                           .executeScript(JavaScriptString.inputJsString(45)); | ||||
|                     }, | ||||
|                     child: const Text('模拟输入测试')), | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       mainController.loadUrl('http://www.df6831.com/'); | ||||
|                       mainController.loadUrl('http://www.df6831.com/game/'); | ||||
|                       // controller.loadUrl('http://www.df6831.com/game/'); | ||||
|                     }, | ||||
|                     child: const Text('跳转首页')), | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       mainController.executeScript(WindowsJs.zoom(70)); | ||||
|                       controller.executeScript(WindowsJs.zoom(40)); | ||||
|                     }, | ||||
|                     child: const Text('缩放')), | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       mainController.openDevTools(); | ||||
|                     }, | ||||
|                     child: const Text('开发者')), | ||||
|                 TextButton( | ||||
|                     onPressed: () { | ||||
|                       mainController.clearCookies(); | ||||
|                       mainController.clearCache(); | ||||
|                     }, | ||||
|                     child: const Text('清除缓存')), | ||||
| 
 | ||||
|                     child: const Text('跳转')), | ||||
|                 const SizedBox( | ||||
|                   width: 50, | ||||
|                   child: TextField( | ||||
|                     keyboardType: TextInputType.number, | ||||
|                     decoration: InputDecoration(prefixText: '网页数量'), | ||||
|                   ), | ||||
|                 ) | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|  | @ -127,16 +115,12 @@ class _WindowsPageState extends State<WindowsPage> { | |||
|   Widget pageViewWidget() { | ||||
|     return Row( | ||||
|       children: [ | ||||
|         SizedBox( | ||||
|           width: 1000, | ||||
|           height: 1000, | ||||
|         Expanded( | ||||
|           child: WindowsWebWidget( | ||||
|             controller: mainController, | ||||
|           ), | ||||
|         ), | ||||
|         SizedBox( | ||||
|           width: 500, | ||||
|           height:400, | ||||
|         Expanded( | ||||
|           child: WindowsWebWidget( | ||||
|             controller: controller, | ||||
|           ), | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ class _WindowsWebWidgetState extends State<WindowsWebWidget> { | |||
|   } | ||||
| 
 | ||||
|   Widget inWindowsWebView(){ | ||||
|     return Webview(widget.controller); | ||||
|     return Webview(widget.controller,); | ||||
|   } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -12,9 +12,8 @@ dependencies: | |||
|     sdk: flutter | ||||
| 
 | ||||
|   cupertino_icons: ^1.0.2 | ||||
|   webview_windows: | ||||
|     path: ../flutter-webview-windows-main | ||||
|   window_manager: | ||||
|   flutter_inappwebview: ^6.0.0 | ||||
|   webview_windows: ^0.4.0 | ||||
| 
 | ||||
| dev_dependencies: | ||||
|   flutter_test: | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue