1.5.0版本
This commit is contained in:
@@ -100,7 +100,7 @@ export class WebsocketProxy extends Mw {
|
||||
try {
|
||||
// 尝试将字符串解析为对象
|
||||
const parsedMessage = JSON.parse(message) as { udid: string, action: string, index: number, resourceId: string, type: string, num: number }; // 添加index字段
|
||||
console.log('执行指令', parsedMessage);
|
||||
console.log('执行指令', parsedMessage.index, parsedMessage.type);
|
||||
// 执行ADB命令
|
||||
const { exec } = require('child_process');
|
||||
// const fs = require('fs');
|
||||
@@ -178,7 +178,7 @@ export class WebsocketProxy extends Mw {
|
||||
}));
|
||||
return;
|
||||
}
|
||||
console.log('安装app');
|
||||
console.log('传输文件');
|
||||
// this.ws.send(JSON.stringify({
|
||||
// status: 'success',
|
||||
// data: stdout
|
||||
@@ -232,7 +232,7 @@ export class WebsocketProxy extends Mw {
|
||||
}));
|
||||
return;
|
||||
}
|
||||
console.log('滑动向上');
|
||||
console.log('滑动向右');
|
||||
// this.ws.send(JSON.stringify({
|
||||
// status: 'success',
|
||||
// data: stdout
|
||||
@@ -242,7 +242,7 @@ export class WebsocketProxy extends Mw {
|
||||
exec(`adb -s ${parsedMessage.udid} shell wm size`,
|
||||
// (error: Error, stdout: string, stderr: string) => {
|
||||
(error: Error, stdout: string) => {
|
||||
console.log(stdout);
|
||||
// console.log(stdout);
|
||||
if (error) {
|
||||
console.error('执行失败:', error);
|
||||
this.ws.send(
|
||||
@@ -259,7 +259,7 @@ export class WebsocketProxy extends Mw {
|
||||
if (sizeMatch) {
|
||||
const width = parseInt(sizeMatch[1]);
|
||||
const height = parseInt(sizeMatch[2]);
|
||||
console.log(`设备 ${parsedMessage.udid} 的屏幕尺寸: ${width}x${height}`);
|
||||
console.log(`设备 ${parsedMessage.udid}+${parsedMessage.index} 的屏幕尺寸: ${width}x${height}`);
|
||||
|
||||
this.ws.send(
|
||||
JSON.stringify({
|
||||
@@ -295,7 +295,7 @@ export class WebsocketProxy extends Mw {
|
||||
|
||||
console.log("time", time)
|
||||
watchNode(parsedMessage.udid, parsedMessage.resourceId, time).then((data) => {
|
||||
console.log('节点出现', data)
|
||||
// console.log('节点出现', data)
|
||||
if (data.found) {
|
||||
|
||||
try {
|
||||
@@ -303,20 +303,20 @@ export class WebsocketProxy extends Mw {
|
||||
//节点列表
|
||||
const targetNodeList = data.nodes;
|
||||
|
||||
console.log('节点列表', targetNodeList)
|
||||
// console.log('节点列表', targetNodeList)
|
||||
let bounds = targetNodeList[0].bounds; // 选择节点列表中的第一个节点
|
||||
if (parsedMessage.type == 'clickCopy' || parsedMessage.type == 'search') {
|
||||
console.log('最后一个节点')
|
||||
// console.log('最后一个节点')
|
||||
|
||||
bounds = targetNodeList[targetNodeList.length - 1].bounds; // 选择节点列表中的最后一个节点
|
||||
} else if (parsedMessage.type == 'clickCopyText') {
|
||||
console.log('最后2个节点')
|
||||
// console.log('最后2个节点')
|
||||
|
||||
bounds = targetNodeList[2].bounds; // 选择节点列表中的第3个节点
|
||||
} else if (parsedMessage.type == 'clickMesage') {
|
||||
const targetNode = targetNodeList.find((item: any) =>
|
||||
(item as any).childCount > 0);
|
||||
console.log('targetNode', targetNode)
|
||||
// console.log('targetNode', targetNode)
|
||||
if (targetNode) {
|
||||
// console.log('noticeMes执行1', noticeMes)
|
||||
bounds = targetNode.bounds; // 使用第一个满足条件的元素
|
||||
@@ -330,11 +330,11 @@ export class WebsocketProxy extends Mw {
|
||||
} else if (parsedMessage.type == 'isVideoAndLive') {
|
||||
|
||||
const VideoType = targetNodeList[0]['content-desc']; // 选择节点列表中的第一个节点
|
||||
console.log('类型', VideoType)
|
||||
// console.log('类型', VideoType)
|
||||
this.ws.send(JSON.stringify({ type: parsedMessage.type, status: 'success', message: VideoType, udid: parsedMessage.udid, index: parsedMessage.index }));
|
||||
return;
|
||||
} else if (parsedMessage.type == 'isHost') {
|
||||
console.log(parsedMessage.index, '关注的内容', targetNodeList[0])
|
||||
console.log(parsedMessage.index, '是否有关注', targetNodeList[0])
|
||||
if (targetNodeList[0]) {
|
||||
console.log('有关注')
|
||||
this.ws.send(JSON.stringify({ type: parsedMessage.type, status: 'success', message: 1, udid: parsedMessage.udid, index: parsedMessage.index }));
|
||||
@@ -349,7 +349,7 @@ export class WebsocketProxy extends Mw {
|
||||
this.ws.send(JSON.stringify({ type: parsedMessage.type, status: 'success', message: 1, udid: parsedMessage.udid, index: parsedMessage.index }));
|
||||
return;
|
||||
} else {
|
||||
console.log('第一个节点')
|
||||
// console.log('第一个节点')
|
||||
bounds = targetNodeList[0].bounds; // 选择节点列表中的第一个节点
|
||||
}
|
||||
// const match = bounds.match(/\[(\d+),(\d+)]\[(\d+),(\d+)]/);
|
||||
@@ -360,16 +360,16 @@ export class WebsocketProxy extends Mw {
|
||||
const y2 = parseInt(bounds.bottom);
|
||||
const clickX = Math.floor((x1 + x2) / 2);
|
||||
const clickY = Math.floor((y1 + y2) / 2);
|
||||
console.log(clickX, clickY, '坐标');
|
||||
// console.log(clickX, clickY, '坐标');
|
||||
// Step 4: Click
|
||||
console.log(parsedMessage.udid, '设备id');
|
||||
// console.log(parsedMessage.udid, '设备id');
|
||||
if (parsedMessage.type == 'clickCopy') {
|
||||
console.log('复制坐标');
|
||||
// console.log('复制坐标');
|
||||
this.ws.send(JSON.stringify({ type: parsedMessage.type, status: 'success', message: '坐标返回', udid: parsedMessage.udid, index: parsedMessage.index, x: clickX, y: clickY }));
|
||||
return;
|
||||
}
|
||||
if (parsedMessage.type == 'isOneLive') {
|
||||
console.log('复制坐标');
|
||||
// console.log('复制坐标');
|
||||
this.ws.send(JSON.stringify({ type: parsedMessage.type, status: 'success', message: 1, udid: parsedMessage.udid, index: parsedMessage.index, x: clickX, y: clickY }));
|
||||
return;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ export class WebsocketProxy extends Mw {
|
||||
console.log('点击失败:' + clickErr.message);
|
||||
return;
|
||||
}
|
||||
console.log('点击了按钮');
|
||||
console.log('点击了按钮' + parsedMessage.type);
|
||||
this.ws.send(JSON.stringify({ type: parsedMessage.type, status: 'success', message: '点击成功', udid: parsedMessage.udid, index: parsedMessage.index, x: clickX, y: clickY }));
|
||||
});
|
||||
} else {
|
||||
@@ -436,10 +436,10 @@ export class WebsocketProxy extends Mw {
|
||||
//节点列表
|
||||
const targetNodeList = data.nodes;
|
||||
|
||||
console.log('节点列表', targetNodeList)
|
||||
// console.log('节点列表', targetNodeList)
|
||||
let bounds = targetNodeList[0].bounds; // 选择节点列表中的第一个节点
|
||||
if (parsedMessage.type == 'clickCopy' || parsedMessage.type == 'search') {
|
||||
console.log('最后一个节点')
|
||||
// console.log('最后一个节点')
|
||||
|
||||
bounds = targetNodeList[targetNodeList.length - 1].bounds; // 选择节点列表中的最后一个节点
|
||||
} else if (parsedMessage.type == 'clickCopyList') {
|
||||
@@ -455,7 +455,7 @@ export class WebsocketProxy extends Mw {
|
||||
return;
|
||||
} else if (parsedMessage.type == 'getmesNum') {
|
||||
let hasMessage = false;
|
||||
console.log('获取消息数量', 1)
|
||||
// console.log('获取消息数量', 1)
|
||||
for (const child of targetNodeList[0].children) {
|
||||
if (
|
||||
child.class === 'android.widget.TextView' &&
|
||||
@@ -480,11 +480,11 @@ export class WebsocketProxy extends Mw {
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('第一个节点')
|
||||
// console.log('第一个节点')
|
||||
bounds = targetNodeList[0].bounds; // 选择节点列表中的第一个节点
|
||||
}
|
||||
const match = bounds.match(/\[(\d+),(\d+)]\[(\d+),(\d+)]/);
|
||||
console.log(match, 'match')
|
||||
// console.log(match, 'match')
|
||||
if (bounds) {
|
||||
const x1 = parseInt(match[1]);
|
||||
const y1 = parseInt(match[2]);
|
||||
@@ -492,11 +492,11 @@ export class WebsocketProxy extends Mw {
|
||||
const y2 = parseInt(match[4]);
|
||||
const clickX = Math.floor((x1 + x2) / 2);
|
||||
const clickY = Math.floor((y1 + y2) / 2);
|
||||
console.log(clickX, clickY, '坐标');
|
||||
// console.log(clickX, clickY, '坐标');
|
||||
// Step 4: Click
|
||||
console.log(parsedMessage.udid, '设备id');
|
||||
// console.log(parsedMessage.udid, '设备id');
|
||||
if (parsedMessage.type == 'clickCopy') {
|
||||
console.log('复制坐标');
|
||||
// console.log('复制坐标');
|
||||
this.ws.send(JSON.stringify({ type: parsedMessage.type, status: 'success', message: '坐标返回', udid: parsedMessage.udid, index: parsedMessage.index, x: clickX, y: clickY }));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user