parent
f6af40701c
commit
e91a3a40af
|
|
@ -78,11 +78,48 @@ class Socket {
|
||||||
if (data['op'] == 11){
|
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(){
|
heartbeat(){
|
||||||
Timer timer = Timer(const Duration(seconds: 10), () async {
|
Timer timer = Timer(const Duration(seconds: 10), () async {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@ class SynchronizationWebTool{
|
||||||
return _instance!;
|
return _instance!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool webSync = false;
|
||||||
|
|
||||||
|
/// 主控
|
||||||
|
late WebviewController mainController;
|
||||||
/// 受控
|
/// 受控
|
||||||
List<WebviewController> _childControllers = [];
|
List<WebviewController> _childControllers = [];
|
||||||
|
|
||||||
|
|
@ -29,11 +33,38 @@ class SynchronizationWebTool{
|
||||||
// controller.addScriptToExecuteOnDocumentCreated(WindowsJs.onloadZoom(90));
|
// controller.addScriptToExecuteOnDocumentCreated(WindowsJs.onloadZoom(90));
|
||||||
}
|
}
|
||||||
|
|
||||||
_childControllers = childControllers;
|
mainController = childControllers.first;
|
||||||
|
_childControllers = childControllers.sublist(1,10);
|
||||||
|
|
||||||
// 滚动监听
|
// 滚动监听
|
||||||
// mainController.addScriptToExecuteOnDocumentCreated(WindowsJs.scrollEventJs);
|
// 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{
|
List<WebviewController> get childController{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
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/socket_tool.dart';
|
||||||
import 'package:web_synchronization_tool/windows/synchronization_web_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';
|
import 'package:webview_windows/webview_windows.dart';
|
||||||
|
|
||||||
class WebGridController {
|
class WebGridController {
|
||||||
|
|
@ -116,6 +118,8 @@ class _ShowWebWidgetState extends State<ShowWebWidget> {
|
||||||
|
|
||||||
/// 网址
|
/// 网址
|
||||||
TextEditingController urlController = TextEditingController();
|
TextEditingController urlController = TextEditingController();
|
||||||
|
/// 总金额
|
||||||
|
TextEditingController numController = TextEditingController();
|
||||||
/// 服务器ip
|
/// 服务器ip
|
||||||
TextEditingController ipController = TextEditingController();
|
TextEditingController ipController = TextEditingController();
|
||||||
|
|
||||||
|
|
@ -148,11 +152,27 @@ class _ShowWebWidgetState extends State<ShowWebWidget> {
|
||||||
if (widget.main == false) return input();
|
if (widget.main == false) return input();
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
// TextButton(
|
TextButton(
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// widget.controller.openDevTools();
|
widget.controller.openDevTools();
|
||||||
// },
|
},
|
||||||
// child: const Text('开发者')),
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
input(),
|
input(),
|
||||||
ipSet()
|
ipSet()
|
||||||
],
|
],
|
||||||
|
|
@ -188,6 +208,40 @@ 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('填入总金额')),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue