import 'package:flutter/material.dart'; import 'package:web_synchronization_tool/windows/socket_tool.dart'; import 'package:web_synchronization_tool/windows/synchronization_web_tool.dart'; import 'package:web_synchronization_tool/windows/web_grid_view.dart'; import 'package:web_synchronization_tool/windows/windowsJs.dart'; import 'windows_web_page.dart'; import 'package:webview_windows/webview_windows.dart'; class WindowsPage extends StatefulWidget { const WindowsPage({super.key}); @override State createState() => _WindowsPageState(); } class _WindowsPageState extends State { Widget? windowsWebWidget; WebviewController mainController = WebviewController(); final gridController = WebGridController(); bool initDone = false; String clickId = ''; String zoomId = ''; @override void initState() { super.initState(); controllerInit(); } Future controllerInit() async { await mainController.initialize(); mainController.loadUrl('http://www.df6831.com/'); gridController.addWebController(mainController); setState(() { initDone = true; }); } @override Widget build(BuildContext context) { SocketTool().connect(); if (initDone == false) return Container(); return Scaffold( body: Column( children: [ Container( height: 50, color: Colors.white, padding: const EdgeInsets.symmetric(horizontal: 50), child: Row( children: [ // TextButton( // onPressed: () { // mainController.executeScript(WindowsJs.clickJs(200, 900)); // }, // child: const Text('模拟点击测试')), TextButton( onPressed: () { mainController.executeScript(WindowsJs.inputJs(45)); // controller.executeScript(WindowsJs.inputJs(45)); }, child: const Text('模拟输入测试')), TextButton( onPressed: () { mainController.loadUrl('https://www.baidu.com/'); }, child: const Text('跳转首页')), TextButton( onPressed: () { SynchronizationWebTool.getInstance().childController.forEach((controller) { controller.executeScript(WindowsJs.zoom(35)); }); // 468, 72 // controller.executeScript(WindowsJs.zoom(40));// 239,39 }, child: const Text('缩放')), // TextButton( onPressed: () { mainController .executeScript('window.resizeBy(-100, -100);'); }, child: const Text('减少尺寸')), // TextButton( // onPressed: () { // mainController.openDevTools(); // }, // child: const Text('开发者')), // TextButton( // onPressed: () { // mainController.executeScript(WindowsJs.message); // }, // child: const Text('发送消息')), Row( children: [ const Text('同步'), Switch( value: SynchronizationWebTool.getInstance().webSync, onChanged: (value) { setState(() { SynchronizationWebTool.getInstance().webSync = value; }); }) ], ) ], ), ), // pageViewWidget() Expanded(child: pageViewWidget()), ], ), ); } Widget pageViewWidget() { return Row( children: [ // SizedBox( // width: 1000, // height: 1000, // child: inWindowsWebView(), // ), Expanded( child: WebGridWidget( controller: gridController, )) ], ); } Widget inWindowsWebView() { return Webview(mainController); } }