From 0f139adcdd7ecf8b5fde7515759020e6f6b39661 Mon Sep 17 00:00:00 2001 From: WoNiu Date: Thu, 4 Apr 2024 14:27:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=BB=E6=8E=A7=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/windows/socket_tool.dart | 37 ------------- lib/windows/synchronization_web_tool.dart | 33 +----------- lib/windows/web_grid_view.dart | 64 ++--------------------- 3 files changed, 6 insertions(+), 128 deletions(-) diff --git a/lib/windows/socket_tool.dart b/lib/windows/socket_tool.dart index 84165fb..11f606d 100644 --- a/lib/windows/socket_tool.dart +++ b/lib/windows/socket_tool.dart @@ -78,48 +78,11 @@ class Socket { if (data['op'] == 11){ } - // 服务器 已连接的ip - if (data['Arr'] != null){ - List arr = data['Arr']; - List ips = []; - arr.forEach((clientMap) { - String ip = clientMap['Client']; - ips.add(ip); - }); - childrenIp = ips; - } }); } - /// 发送消息 - sendClickMessage(Map data){ - Map messageMap = { - "op": 2, - "click": data - }; - socket?.send(dataMake(messageMap), InternetAddress(url), port); - } - - /// 发送获取从机 消息 - sendGetChilds(){ - Map messageMap = { - "op": 3, - }; - socket?.send(dataMake(messageMap), InternetAddress(url), port); - } - - - /// 发送输入喜消息 - sendInpuMessage(int num){ - Map messageMap = { - "op": 2, - "input": num - }; - socket?.send(dataMake(messageMap), InternetAddress(url), port); - } - /// 心跳 heartbeat(){ Timer timer = Timer(const Duration(seconds: 10), () async { diff --git a/lib/windows/synchronization_web_tool.dart b/lib/windows/synchronization_web_tool.dart index 5c3aeea..7f0b670 100644 --- a/lib/windows/synchronization_web_tool.dart +++ b/lib/windows/synchronization_web_tool.dart @@ -18,10 +18,6 @@ class SynchronizationWebTool{ return _instance!; } - bool webSync = false; - - /// 主控 - late WebviewController mainController; /// 受控 List _childControllers = []; @@ -33,38 +29,11 @@ class SynchronizationWebTool{ // controller.addScriptToExecuteOnDocumentCreated(WindowsJs.onloadZoom(90)); } - mainController = childControllers.first; - _childControllers = childControllers.sublist(1,10); + _childControllers = childControllers; // 滚动监听 // mainController.addScriptToExecuteOnDocumentCreated(WindowsJs.scrollEventJs); - mainController.webMessage.listen((event) { - print('mainController listen --'); - - if (event['scroll'] != null ) { - print(event); - } - - if (!webSync) return; - - if (event['click'] != null) { - Map click = event['click']; - int x = click['x'] as int; - int y = click['y'] as int; - - clickSynchronization(x, y); - SocketUtils.getInstance().sendClickMessage(click); - } - - if (event['scroll'] != null ) { - print(event); - int y = event['y'] as int; - scrollSynchronization(y); - } - - }); - } List get childController{ diff --git a/lib/windows/web_grid_view.dart b/lib/windows/web_grid_view.dart index 0e3a44e..ee85b6d 100644 --- a/lib/windows/web_grid_view.dart +++ b/lib/windows/web_grid_view.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:web_synchronization_tool/windows/number_tool.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/windowsJs.dart'; import 'package:webview_windows/webview_windows.dart'; class WebGridController { @@ -118,8 +116,6 @@ class _ShowWebWidgetState extends State { /// 网址 TextEditingController urlController = TextEditingController(); - /// 总金额 - TextEditingController numController = TextEditingController(); /// 服务器ip TextEditingController ipController = TextEditingController(); @@ -152,27 +148,11 @@ class _ShowWebWidgetState extends State { if (widget.main == false) return input(); return Row( children: [ - TextButton( - onPressed: () { - widget.controller.openDevTools(); - }, - child: const Text('开发者')), - inputNumber(), - Row( - children: [ - const Text('同步'), - Switch( - value: SynchronizationWebTool.getInstance().webSync, - onChanged: (value) { - setState(() { - SynchronizationWebTool.getInstance().webSync = value; - if (value){ // 打开同步获取 从机 - SocketUtils.getInstance().sendGetChilds(); - } - }); - }) - ], - ), + // TextButton( + // onPressed: () { + // widget.controller.openDevTools(); + // }, + // child: const Text('开发者')), input(), ipSet() ], @@ -208,40 +188,6 @@ class _ShowWebWidgetState extends State { ); } - /// 输入总金额 - inputNumber(){ - return Row( - children: [ - SizedBox(width: 100, child: TextField(style: const TextStyle(fontSize: 14),controller: numController,)), - TextButton( - onPressed: () { - try{ - int num = int.parse(numController.text); - - int chidNum = SocketUtils.getInstance().childrenIp.length + 1; - - if (num <= chidNum * 10){ - numController.text = '金额不能小于${chidNum*10}'; - return; - } - - int maxNum = num ~/ chidNum; - SocketUtils.getInstance().sendInpuMessage(maxNum); - - // 本地处理 - List nums = NumberTool().randomNum(maxNum); - widget.controller.executeScript(WindowsJs.inputJs(nums.first)); - nums.removeAt(0); - SynchronizationWebTool.getInstance().input(nums); - }catch(e){ - numController.text = '请输入数字'; - } - }, - child: const Text('填入总金额')), - ], - ); - } - }