删除主控 代码

This commit is contained in:
WoNiu 2024-04-04 14:27:52 +08:00
parent 8e8bf0d53c
commit 0f139adcdd
3 changed files with 6 additions and 128 deletions

View File

@ -78,48 +78,11 @@ class Socket {
if (data['op'] == 11){
}
// ip
if (data['Arr'] != null){
List arr = data['Arr'];
List<String> 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 {

View File

@ -18,10 +18,6 @@ class SynchronizationWebTool{
return _instance!;
}
bool webSync = false;
///
late WebviewController mainController;
///
List<WebviewController> _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<WebviewController> get childController{

View File

@ -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<ShowWebWidget> {
///
TextEditingController urlController = TextEditingController();
///
TextEditingController numController = TextEditingController();
/// ip
TextEditingController ipController = TextEditingController();
@ -152,27 +148,11 @@ class _ShowWebWidgetState extends State<ShowWebWidget> {
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<ShowWebWidget> {
);
}
///
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<int> 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('填入总金额')),
],
);
}
}