Compare commits

...

6 Commits

Author SHA1 Message Date
WoNiu f63ad460d5 Merge branch 'Dev' into 主控 2024-04-06 19:11:06 +08:00
WoNiu 525e10badc Merge branch 'Dev' into 主控 2024-04-06 17:01:09 +08:00
WoNiu b6b6e41e8b 修改 提示 2024-04-06 16:35:02 +08:00
WoNiu ff882a5e06 1 删除 开发者按钮
2 socket 连接时 先将旧连接关闭
3 恢复 主机 ic
2024-04-06 16:32:10 +08:00
WoNiu 30af057969 Merge branch '受控' into 主控 2024-04-06 16:20:51 +08:00
WoNiu e91a3a40af Revert "删除主控 代码"
This reverts commit 0f139adcdd.
2024-04-05 18:10:38 +08:00
3 changed files with 127 additions and 7 deletions

View File

@ -30,12 +30,13 @@ class SyncSocket {
RawDatagramSocket? socket;
// IC 0 1
int ic = 1;
int ic = 0;
/// ip
List<String> childrenIp = [];
connect() async {
socket?.close();
socket = await RawDatagramSocket.bind(InternetAddress.anyIPv4, 0);
//
@ -78,11 +79,48 @@ class SyncSocket {
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,6 +18,10 @@ class SynchronizationWebTool{
return _instance!;
}
bool webSync = false;
///
late WebviewController mainController;
///
List<WebviewController> _childControllers = [];
@ -29,11 +33,38 @@ class SynchronizationWebTool{
// controller.addScriptToExecuteOnDocumentCreated(WindowsJs.onloadZoom(90));
}
_childControllers = childControllers;
mainController = childControllers.first;
_childControllers = childControllers.sublist(1,10);
//
// 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,6 +1,9 @@
import 'package:common/utils/toast_utils.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/synchronization_web_tool.dart';
import 'package:web_synchronization_tool/windows/windowsJs.dart';
import 'package:webview_windows/webview_windows.dart';
class WebGridController {
@ -116,6 +119,8 @@ class _ShowWebWidgetState extends State<ShowWebWidget> {
///
TextEditingController urlController = TextEditingController();
///
TextEditingController numController = TextEditingController();
/// ip
TextEditingController ipController = TextEditingController();
@ -148,11 +153,22 @@ 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();
}
});
})
],
),
input(),
ipSet()
],
@ -188,6 +204,41 @@ 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}';
ToastUtils.showToast('金额不能太小');
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){
ToastUtils.showToast('请输入数字');
}
},
child: const Text('填入总金额')),
],
);
}
}