分包
This commit is contained in:
@@ -6,11 +6,9 @@
|
||||
<el-button class="Back" @click="Back(device.udid, index)"></el-button>
|
||||
<el-button class="Home" @click="Home(device.udid, index)"></el-button>
|
||||
<el-button class="Overview" @click="Overview(device.udid, index)"></el-button> -->
|
||||
|
||||
|
||||
<!-- <el-button @click="play(device.udid, index)">play</el-button> -->
|
||||
<!-- <el-button class="open" @click="slideDown(device.udid, index)"></el-button>
|
||||
<el-button class="open" @click="slideUp(device.udid, index)"></el-button>
|
||||
<el-button class="open" @click="slideUp(device.udid, index)"></el-button>
|
||||
<el-button class="open" @click="clickLike(device.udid, index)"></el-button> -->
|
||||
<div></div>
|
||||
<!-- <el-button @click="clickLikes(device.udid, index)">点赞</el-button> -->
|
||||
@@ -25,7 +23,7 @@
|
||||
<!-- <div></div>
|
||||
<el-button @click="clickPrivatetext(device.udid, index)">私信输入</el-button>
|
||||
<el-button @click="clickPrivatePush(device.udid, index)">私信发送</el-button> -->
|
||||
<el-button type="warning" @click="reloadfun()">刷新</el-button>
|
||||
<el-button type="warning" @click="reload()">刷新</el-button>
|
||||
<div></div>
|
||||
<!-- <el-button @click="wsActions.clickCopy(device.udid, index)">找私信</el-button> -->
|
||||
<!-- <el-button @click="wsActions.clickCopyList(device.udid, index)">私信列表</el-button> -->
|
||||
@@ -34,30 +32,25 @@
|
||||
<!-- <el-button @click="wsActions.getSize(device.udid, index)">获取屏幕尺寸</el-button> -->
|
||||
<!-- <el-button @click="wsActions.slideRight(device.udid, index)">右滑</el-button> -->
|
||||
<!-- <el-button @click="wsActions.isHost(device.udid, index)">一键养号</el-button> -->
|
||||
|
||||
<el-button type="success" @click="openTk()">打开tiktok</el-button>
|
||||
<el-button type="success" @click="showDialog = true; dialogTitle = '评论'; selectedDevice = 999">一键养号</el-button>
|
||||
<el-button type="success"
|
||||
@click="showDialog = true; dialogTitle = '主播ID'; selectedDevice = 999">一键关注</el-button>
|
||||
@click="showDialog = true; dialogTitle = '主播ID'; selectedDevice = 999">一键关注并打招呼</el-button>
|
||||
<el-button type="success" v-if="!isShowMes" @click="openMonitor()">开启监测消息</el-button>
|
||||
<el-button type="danger" v-else @click="cloesMonitor()">关闭监测消息</el-button>
|
||||
<el-button type="danger" @click="stop()">全部停止</el-button>
|
||||
<el-button type="danger" @click="router.push('/')">登出</el-button>
|
||||
<div></div>
|
||||
|
||||
<div></div>
|
||||
<!-- <el-button @click="wsActions.test(device.udid, index)">截屏</el-button> -->
|
||||
<div></div>
|
||||
<!-- <el-button @click="wsActions.search(device.udid, index)">搜索</el-button>
|
||||
<div></div>
|
||||
|
||||
<el-button @click="wsActions.searchHost(device.udid, index)">搜主播</el-button>
|
||||
<div></div>
|
||||
|
||||
<el-button @click="wsActions.toHost(device.udid, index)">主页</el-button>
|
||||
<div></div>
|
||||
<el-button @click="LikesToLikesToLikes(device.udid, index)">批量关注</el-button> -->
|
||||
|
||||
<div></div>
|
||||
<!-- <div style="display: flex;">
|
||||
<div style="width: 150px;">主播id</div>
|
||||
@@ -80,23 +73,19 @@
|
||||
<!-- <el-button @click="clickxy(284, 392, index, 9)">长按</el-button> -->
|
||||
<!-- <el-button @click="getText(index)">获取粘贴板内容</el-button> -->
|
||||
<div></div>
|
||||
|
||||
<!-- <el-button @click="LikesToCommentToComPush(device.udid, index)">设置自动化坐标</el-button> -->
|
||||
<!-- <el-button @click="start(device.udid, index)">开始执行</el-button> -->
|
||||
<!-- <el-button @click="stop(device.udid, index)">停止</el-button> -->
|
||||
<div></div>
|
||||
<!-- <el-button @click="wsActions.isVideoAndLive(device.udid, index)">判断视频还是直播</el-button> -->
|
||||
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<div class="content" @click.self="selectedDevice = 999">
|
||||
<div class="video-container" @click.self="selectedDevice = 999" v-for="(device, index) in deviceInformation"
|
||||
:key="device.udid" @mouseup="(e) => handleCanvasup(device.udid, e, index)">
|
||||
|
||||
<div class="video-canvas">
|
||||
<video :ref="(el) => (videoElement[device.udid] = el)" autoplay muted playsinline
|
||||
:style="getVideoStyle(index)" @click.stop="selectedDeviceFun(index)"></video>
|
||||
|
||||
:style="getVideoStyle(index)" @click.stop="selectedDevice = index"></video>
|
||||
<canvas class="canvas" v-show="selectedDevice == index" :ref="(el) => (canvasRef[device.udid] = el)"
|
||||
@mousemove.stop="(e) => handleMouseMove(device.udid, e, index)"
|
||||
@mousedown.stop="(e) => handleCanvasdown(device.udid, e, index)">
|
||||
@@ -106,49 +95,43 @@
|
||||
<!-- <div class="input-info" v-show="false"> -->
|
||||
<el-button @click="showDialog = true; dialogTitle = '主播ID';">批量关注</el-button>
|
||||
<div></div>
|
||||
<el-button @click="showDialog = true; dialogTitle = '评论';">导入评论</el-button>
|
||||
<!-- <el-button @click="showDialog = true; dialogTitle = '评论';">导入评论</el-button> -->
|
||||
<div></div>
|
||||
<el-button @click="getComArr(index, '评论')">查看评论</el-button>
|
||||
<div></div>
|
||||
<el-button @click="showDialog = true; dialogTitle = '私信';">导入私信</el-button>
|
||||
<!-- <el-button @click="showDialog = true; dialogTitle = '私信';">导入私信</el-button> -->
|
||||
<div></div>
|
||||
<el-button @click="getComArr(index, '私信')">查看私信</el-button>
|
||||
<el-button @click="wsActions.getmesNum(device.udid, index)">检测消息</el-button>
|
||||
<el-button @click="wsActions.clickMesage(device.udid, index)">进入消息</el-button>
|
||||
<el-button @click="wsActions.clickCopyList(device.udid, index)">获取聊天记录</el-button>
|
||||
<el-button @click="wsActions.getSize(device.udid, index)">获取屏幕尺寸</el-button>
|
||||
|
||||
<!-- <el-button @click="wsActions.clickMesage(device.udid, index)">进入消息</el-button> -->
|
||||
<el-button
|
||||
@click="wsActions.clickCopyList(device.udid, index); openShowChat = true; istranslate = true">翻译本页对话</el-button>
|
||||
<!-- <el-button @click="wsActions.getSize(device.udid, index)">获取屏幕尺寸</el-button> -->
|
||||
<div style="display: flex;">
|
||||
<el-input style="border: 1px solid #000;" v-model="textContent[index]" type="text"></el-input>
|
||||
<el-button @click="setComText(index)">发送</el-button>
|
||||
</div>
|
||||
<el-button @click="wsActions.test(device.udid, index)">截屏</el-button>
|
||||
<el-button @click="wsActions.killNow(device.udid, index)">关闭</el-button>
|
||||
<el-button @click="chooseFile(device.udid, index, 1, wsActions)">安装 APK 文件</el-button>
|
||||
<el-button @click="chooseFile(device.udid, index, 2, wsActions)">传送文件</el-button>
|
||||
<!-- <el-button @click="wsActions.isHost(device.udid, index)">一键养号</el-button> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="video-container" @click.self="selectedDevice = 999" v-for="item in 4" :style="getVideoStyle()"
|
||||
:class="{ 'bottom-row': item >= 2 }">
|
||||
<div style="position: relative;box-sizing: border-box; ">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="right">
|
||||
<el-button @click="openShowChat = !openShowChat">聊天</el-button>
|
||||
<ChatDialog :visible="openShowChat" leftMsg="123123" rightMsg="safdgasdfasdfasgasedyr5q3245214632452345tsdfgasdf"
|
||||
@close="show = false" />
|
||||
|
||||
<!-- <ChatDialog :visible="openShowChat" :leftMsg="chatContent.left" :rightMsg="chatContent.right"
|
||||
@close="show = false" /> -->
|
||||
<!-- <el-button @click="openShowChat = !openShowChat">聊天</el-button> -->
|
||||
<ChatDialog :visible="openShowChat" :messages="chatList" />
|
||||
</div>
|
||||
|
||||
<MultiLineInputDialog v-model:visible="showDialog" :initialText='""' :title="dialogTitle" :index="selectedDevice"
|
||||
@confirm="onDialogConfirm" @cancel="onDialogCancel" />
|
||||
@confirm="onDialogConfirm" />
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -161,26 +144,24 @@ import { set } from "lodash";
|
||||
import { toBufferBtn, stringToUtf8ByteArray, getClipboard, setClipboard, bufferToString, startsWithHeader, trimLongArray, base64ToBinary, toBuffer } from '@/utils/bufferUtils';
|
||||
import { createWsActions } from '@/utils/wsActions';
|
||||
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'
|
||||
import { chat } from "@/api/chat";
|
||||
import { chat, translation } from "@/api/chat";
|
||||
import MultiLineInputDialog from '@/components/MultiLineInputDialog.vue'; // 根据实际路径修改
|
||||
import ChatDialog from '@/components/ChatDialog.vue'
|
||||
|
||||
import { splitArray } from '@/utils/arrUtil'
|
||||
import { chooseFile } from '@/utils/fileUtil'
|
||||
const router = useRouter();
|
||||
let wsActions = null;
|
||||
|
||||
// 引入刷新方法
|
||||
const reload = inject("reload")
|
||||
let refresh = ref(true);
|
||||
|
||||
let phone = ref({ width: 207, height: 470 });
|
||||
const openStr = base64ToBinary("ZQBwAAAAAAA8CgLQAtAAAAAAAAAAAAD/AAAAAAAAAAAAAAAA"); //开启视频流的启动命令
|
||||
const eitwo = base64ToBinary("BAIAAABHVFJD"); //开启设备信息的命令
|
||||
let isshow = ref(true);
|
||||
let isshow = ref(true); //页面是否隐藏
|
||||
let playTimer = ref([{}, {}, {}, {}, {}, {}, {}, {}]); // 播放定时器
|
||||
let isdown = ref(false);
|
||||
const videoElement = ref({});
|
||||
let deviceInformation = ref([]);
|
||||
|
||||
let isdown = ref(false); //是否是按下鼠标状态
|
||||
const videoElement = ref({}); //视频流元素DOM
|
||||
let deviceInformation = ref([]); //设备信息列表
|
||||
//当前弹窗类型
|
||||
let dialogTitle = ref('');
|
||||
//评论文本内容
|
||||
@@ -193,13 +174,7 @@ let hostIdContentArr = ref([[], [], [], [], [], [], [], [], []]);
|
||||
let textContentpri = ref(['', '', '', '', '', '', '', '']);
|
||||
let textContentpriArr = ref([[], [], [], [], [], [], [], [], []]);
|
||||
//保存聊天内容
|
||||
let chatList = ref([{}, {}, {}, {}, {}, {}, {}, {}]);
|
||||
//传入弹窗的聊天内容
|
||||
let chatContent = ref({
|
||||
left: '',
|
||||
right: ''
|
||||
});
|
||||
|
||||
let chatList = ref([]);
|
||||
//选中设备
|
||||
let selectedDevice = ref(999);
|
||||
//ws列表
|
||||
@@ -234,10 +209,9 @@ const mouseData = {
|
||||
};
|
||||
//打开聊天窗口的状态
|
||||
let openShowChat = ref(false);
|
||||
|
||||
let istranslate = ref(false); //是否是翻译本页
|
||||
let phoneXYinfo = ref(getphoneXYinfo() == null ? [{}, {}, {}, {}, {}, {}, {}, {}] : getphoneXYinfo());
|
||||
console.log('phoneXYinfo.value', phoneXYinfo.value)
|
||||
|
||||
const wsCache = new Map();
|
||||
//``````````````````````````````````````````````````````````````````````````````````
|
||||
// 初始化 手机显示WebSocket 和视频流
|
||||
@@ -269,10 +243,8 @@ const initVideoStream = (udid, index) => {
|
||||
);
|
||||
wslist[index].binaryType = "arraybuffer";
|
||||
|
||||
|
||||
wslist[index].onopen = () => {
|
||||
console.log("手机显示ws已开启");
|
||||
|
||||
wsActions = createWsActions(wslist, isStopLike);
|
||||
// 发送 开启 视频流数据
|
||||
setTimeout(() => {
|
||||
@@ -285,13 +257,10 @@ const initVideoStream = (udid, index) => {
|
||||
wsCache.set(udid, instanceList.value[index]);
|
||||
//``````````````````````````````````````````````````````````````````````````````````
|
||||
};
|
||||
|
||||
const magicSize = stringToUtf8ByteArray('scrcpy_message');
|
||||
|
||||
// 3. 处理接收到的二进制数据
|
||||
wslist[index].onmessage = (event) => {
|
||||
const data = new Uint8Array(event.data);
|
||||
|
||||
//判断返回的如果是字符串为自定义返回
|
||||
if (typeof event.data == 'string') {
|
||||
if (isStopLike.value[index]) {
|
||||
@@ -302,7 +271,6 @@ const initVideoStream = (udid, index) => {
|
||||
//成功处理
|
||||
console.log('自定义返回', resData)
|
||||
if (resData.status === 'success') {
|
||||
|
||||
//触发长按该位置
|
||||
if (resData.type == 'clickCopy') {
|
||||
console.log('长按', resData.x * iponeCoefficient.value[index].width, resData.y * iponeCoefficient.value[index].height, index)
|
||||
@@ -325,31 +293,34 @@ const initVideoStream = (udid, index) => {
|
||||
wsActions.clickMesage(deviceInformation.value[index].udid, index) //点击消息进入对话框
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
} else if (resData.type == 'clickMesage') {
|
||||
wsActions.clickCopyList(deviceInformation.value[index].udid, index)
|
||||
|
||||
} else if (resData.type == 'isVideoAndLive') {
|
||||
console.log(resData.message)
|
||||
|
||||
} else if (resData.type == 'clickCopyList') { //获取到的消息列表
|
||||
//打印所有信息
|
||||
console.log('消息列表', resData.message)
|
||||
chatList.value = resData.message
|
||||
getTranslation(chatList.value)
|
||||
const mesBox = resData.message[resData.message.length - 1]
|
||||
//打印最新一条信息
|
||||
console.log('最新消息', mesBox)
|
||||
chat({ msg: mesBox.text }).then(res => {
|
||||
console.log(res)
|
||||
chatList.value[index].leftMsg = res.data.translationResult
|
||||
chatList.value[index].rightMsg = res.data.chineseResult
|
||||
// textContentpri.value[index] = res.data.finalResult
|
||||
// PrivatetexToPrivatePush(deviceInformation.value[index].udid, index)
|
||||
})
|
||||
console.log("翻译", istranslate.value)
|
||||
if (istranslate.value == false) {
|
||||
console.log("执行ai")
|
||||
chat({ msg: mesBox.text }).then(res => {
|
||||
console.log("ai返回", res)
|
||||
textContentpri.value[index] = res
|
||||
PrivatetexToPrivatePush(deviceInformation.value[index].udid, index)
|
||||
})
|
||||
} else {
|
||||
console.log("翻译本页")
|
||||
istranslate.value = false
|
||||
}
|
||||
} else if (resData.action == 'getSize') {
|
||||
console.log(iponeCoefficient.value, '手机尺寸宽度:', resData.width, '高度:', resData.height);
|
||||
iponeCoefficient.value[index].width = 320 / resData.width
|
||||
iponeCoefficient.value[index].height = 720 / resData.height
|
||||
|
||||
console.log('尺寸系数', iponeCoefficient.value[index])
|
||||
} else {
|
||||
console.log(resData.type, '坐标返回:x:', resData.x, 'y:', resData.y);
|
||||
@@ -358,7 +329,6 @@ const initVideoStream = (udid, index) => {
|
||||
phoneXYinfo.value[index].id = resData.udid
|
||||
if (resData.type == 'Likes') {//判断是否是 点赞
|
||||
phoneXYinfo.value[index].Likes = { x: resData.x * iponeCoefficient.value[index].width, y: resData.y * iponeCoefficient.value[index].height }
|
||||
|
||||
if (runType.value[index] == 'follow') {
|
||||
wsActions.slideDown(deviceInformation.value[index].udid, index)//是否继续下一个视频
|
||||
}
|
||||
@@ -386,7 +356,6 @@ const initVideoStream = (udid, index) => {
|
||||
}, 1000);
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
}, 800)
|
||||
} else if (resData.type == 'tomy') {//打开主页
|
||||
phoneXYinfo.value[index].tomy = { x: resData.x * iponeCoefficient.value[index].width, y: resData.y * iponeCoefficient.value[index].height }
|
||||
@@ -409,38 +378,30 @@ const initVideoStream = (udid, index) => {
|
||||
phoneXYinfo.value[index].Privatetex = { x: resData.x * iponeCoefficient.value[index].width, y: resData.y * iponeCoefficient.value[index].height }
|
||||
} else if (resData.type == 'PrivatePush') {//私信发送
|
||||
phoneXYinfo.value[index].PrivatePush = { x: resData.x * iponeCoefficient.value[index].width, y: resData.y * iponeCoefficient.value[index].height }
|
||||
|
||||
//如果是在关注主播的任务中
|
||||
if (runType.value[index] == 'follow') {
|
||||
runType.value[index] = ''
|
||||
}
|
||||
setTimeout(() => {
|
||||
Back('', index);
|
||||
|
||||
setTimeout(() => {
|
||||
Back('', index);
|
||||
if (runType.value[index] == 'listen') {
|
||||
|
||||
} else {
|
||||
} else if (runType.value[index] == 'like' || runType.value[index] == 'follow') {
|
||||
LikesToLikesToLikes(deviceInformation.value[index].udid, index, 2)
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
}, 1000);
|
||||
|
||||
} else if (resData.type == 'clickCopy') {//点击复制
|
||||
phoneXYinfo.value[index].clickCopy = { x: resData.x * iponeCoefficient.value[index].width, y: resData.y * iponeCoefficient.value[index].height }
|
||||
} else if (resData.type == 'hostVideo') {//点击复制
|
||||
phoneXYinfo.value[index].hostVideo = { x: resData.x * iponeCoefficient.value[index].width, y: resData.y * iponeCoefficient.value[index].height }
|
||||
|
||||
} else if (resData.type == 'isHost') {//视频关注主播
|
||||
phoneXYinfo.value[index].isHost = { x: resData.x * iponeCoefficient.value[index].width, y: resData.y * iponeCoefficient.value[index].height }
|
||||
|
||||
if (resData.message == 0) {
|
||||
console.log('无关注', index)
|
||||
Back(deviceInformation.value[index].udid, index)
|
||||
setTimeout(() => {
|
||||
|
||||
console.log('观看视频中', index)
|
||||
randomSeeVideo(deviceInformation.value[index].udid, index) //30-50秒后继续循环任务
|
||||
}, 1000);
|
||||
@@ -459,20 +420,16 @@ const initVideoStream = (udid, index) => {
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
setphoneXYinfo(phoneXYinfo.value)
|
||||
if (resData.type != 'isHost') {
|
||||
|
||||
if (resData.type == 'hostVideo' || resData.type == 'Likes') {
|
||||
setTimeout(() => {
|
||||
createTaskQueue(index).next(); // 继续队列中下一个任务
|
||||
}, 5000)
|
||||
} else {
|
||||
createTaskQueue(index).next(); // 继续队列中下一个任务
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// --------------------------------------------------------------------------报错处理
|
||||
@@ -487,7 +444,6 @@ const initVideoStream = (udid, index) => {
|
||||
setTimeout(() => {
|
||||
Back('', index)
|
||||
LikesToLikesToLikes(deviceInformation.value[index].udid, index, 2)
|
||||
|
||||
}, 1000)
|
||||
}, 1000)
|
||||
} else {
|
||||
@@ -497,7 +453,6 @@ const initVideoStream = (udid, index) => {
|
||||
Back('', index)
|
||||
setTimeout(() => {
|
||||
wsActions.isHost(deviceInformation.value[index].udid, index)
|
||||
|
||||
}, 1000)
|
||||
}, 1000)
|
||||
}
|
||||
@@ -525,24 +480,17 @@ const initVideoStream = (udid, index) => {
|
||||
ElMessage.error(resData.message);
|
||||
createTaskQueue(index).clear();//清除队伍中的任务
|
||||
}
|
||||
|
||||
// createTaskQueue(index).next(); // 继续队列中下一个任务
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//返回粘贴板内容
|
||||
if (startsWithHeader(magicSize, data)) {
|
||||
if (!isSend.value) {
|
||||
const buffer = trimLongArray(data, magicSize);
|
||||
const paste = bufferToString(buffer);
|
||||
console.log('获取粘贴板内容', paste)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//视频流处理
|
||||
if (instanceList.value[index].converter) {
|
||||
if (isshow.value) {
|
||||
@@ -564,20 +512,16 @@ const initVideoStream = (udid, index) => {
|
||||
|
||||
// 配置参数
|
||||
let canvasRef = ref({});
|
||||
|
||||
// 初始化画布
|
||||
const initCanvas = (udid) => {
|
||||
const canvas = canvasRef.value[udid];
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
|
||||
canvas.style.width = `${phone.value.width * 1.4}px`;
|
||||
canvas.style.height = `${phone.value.height * 1.4}px`;
|
||||
canvas.width = phone.value.width * 1.4 * dpr;
|
||||
canvas.height = phone.value.height * 1.4 * dpr;
|
||||
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.scale(dpr, dpr);
|
||||
|
||||
// 绘制参考网格(可选)
|
||||
ctx.strokeStyle = "#ffffff00";
|
||||
for (let x = 0; x <= phone.value.width; x += 100) {
|
||||
@@ -619,7 +563,6 @@ const handleCanvasup = (udid, event, index) => {
|
||||
mouseData.position.point.x = x;
|
||||
mouseData.position.point.y = y;
|
||||
// console.log(mouseData);
|
||||
|
||||
wslist[index].send(toBuffer(mouseData));
|
||||
};
|
||||
|
||||
@@ -686,7 +629,6 @@ const handleVisibilityChange = () => {
|
||||
playTimer.value.forEach(Timer => {
|
||||
clearInterval(Timer);
|
||||
});
|
||||
|
||||
playTimer.value = [{}, {}, {}, {}, {}, {}, {}, {}];
|
||||
}
|
||||
console.log("页面被隐藏");
|
||||
@@ -697,7 +639,6 @@ const handleVisibilityChange = () => {
|
||||
setTimeout(() => {
|
||||
isshow.value = true;
|
||||
// ObtainDeviceInformation();
|
||||
|
||||
}, 500);
|
||||
|
||||
}
|
||||
@@ -707,14 +648,12 @@ const handleVisibilityChange = () => {
|
||||
onMounted(() => {
|
||||
document.addEventListener("visibilitychange", handleVisibilityChange);
|
||||
ObtainDeviceInformation();
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
console.log('触发按键了 键盘事件有效', e)
|
||||
if (e.key == 'Backspace') {
|
||||
key(selectedDevice.value, 'down', 67)
|
||||
}
|
||||
})
|
||||
|
||||
window.addEventListener('keyup', (e) => {
|
||||
// console.log('触发按键了 键盘事件有效抬起', e.keyCode, e.key)
|
||||
if (e.key == 'Backspace') {
|
||||
@@ -722,7 +661,6 @@ onMounted(() => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '初始化中...',
|
||||
@@ -756,31 +694,24 @@ const ObtainDeviceInformation = () => {
|
||||
const data = JSON.parse(new TextDecoder('utf-8').decode(event.data).replace(/[^\x20-\x7F]/g, ''));
|
||||
try {
|
||||
console.log('数组', data)
|
||||
|
||||
|
||||
if (data.type == "devicelist") {
|
||||
deviceInformation.value = [];
|
||||
const filteredList = data.data.list.filter(item => item.state === 'device');
|
||||
//检测到设备列表时,渲染所有设备
|
||||
filteredList.forEach((item, index) => {
|
||||
console.log(item);
|
||||
|
||||
if (item.state === "device") {
|
||||
deviceInformation.value.push(item);
|
||||
console.log("deviceInformation", deviceInformation.value);
|
||||
|
||||
setTimeout(() => {
|
||||
initVideoStream(item.udid, index);
|
||||
initCanvas(item.udid);
|
||||
setTimeout(() => {
|
||||
wsActions.getSize(item.udid, index)
|
||||
|
||||
}, 2000)
|
||||
}, 300);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
} else if (data.type == "device") {
|
||||
if (data.data.device.state === "offline") {
|
||||
//监听设备信息,出现离线设备,则删除设备信息
|
||||
@@ -810,7 +741,6 @@ const ObtainDeviceInformation = () => {
|
||||
}
|
||||
})
|
||||
} else if (data.data.device.state === "device") {
|
||||
|
||||
let isrepeat = false;
|
||||
//监听设备信息,出现新设备,则添加设备信息
|
||||
deviceInformation.value.forEach((item, index) => {
|
||||
@@ -818,14 +748,12 @@ const ObtainDeviceInformation = () => {
|
||||
isrepeat = true;
|
||||
}
|
||||
})
|
||||
|
||||
if (!isrepeat) {
|
||||
deviceInformation.value.push(data.data.device);
|
||||
// setTimeout(() => {
|
||||
// initVideoStream(data.data.device.udid, deviceInformation.value.length - 1);
|
||||
// initCanvas(data.data.device.udid);
|
||||
// }, 300);
|
||||
|
||||
new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
@@ -837,7 +765,6 @@ const ObtainDeviceInformation = () => {
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -854,10 +781,9 @@ async function LikesToCommentToComPush(udid, index) {
|
||||
await sendWsTask(index, { udid, action: 'click', type: 'ComPush', index, resourceId: 'com.zhiliaoapp.musically:id/bqg' });
|
||||
}
|
||||
|
||||
|
||||
//点赞主页4个作品+评论最后一个作品并返回
|
||||
async function LikesToLikesToLikes(udid, index, type) {
|
||||
|
||||
isStopLike.value[index] = false;
|
||||
runType.value[index] = 'follow';
|
||||
if (type == 2) {
|
||||
await sendWsTask(index, { udid, action: 'click', type: 'searchTxt', index, resourceId: 'com.zhiliaoapp.musically:id/f0l' });
|
||||
@@ -893,7 +819,6 @@ function setComText(index) {
|
||||
isSend.value = true;
|
||||
setTimeout(() => {
|
||||
isSend.value = false;
|
||||
|
||||
}, 300);
|
||||
console.log('发送评论内容', index, textContent.value[index])
|
||||
wslist[index].send(setClipboard(textContent.value[index]));
|
||||
@@ -905,11 +830,9 @@ function setHostId(index) {
|
||||
isSend.value = true;
|
||||
setTimeout(() => {
|
||||
isSend.value = false;
|
||||
|
||||
}, 300);
|
||||
console.log('发送主播id内容', index, hostIdContent.value[index])
|
||||
wslist[index].send(setClipboard(hostIdContent.value[index])); //发送内容
|
||||
|
||||
//获取当前主播ID的下标
|
||||
const indexBom = hostIdContentArr.value[index].indexOf(hostIdContent.value[index]) + 1;
|
||||
console.log(hostIdContentArr.value[index].indexOf(hostIdContent.value[index]) + 1, '当前主播下标');
|
||||
@@ -920,7 +843,6 @@ function setHostId(index) {
|
||||
hostIdContent.value[index] = ''
|
||||
return
|
||||
}
|
||||
|
||||
hostIdContent.value[index] = hostIdContentArr.value[index][indexBom];
|
||||
console.log(hostIdContent.value[index], '下次搜索')
|
||||
}
|
||||
@@ -930,17 +852,14 @@ function setPrivateText(index) {
|
||||
isSend.value = true;
|
||||
setTimeout(() => {
|
||||
isSend.value = false;
|
||||
|
||||
}, 300);
|
||||
console.log('发送私信内容', index, textContentpri.value[index])
|
||||
wslist[index].send(setClipboard(textContentpri.value[index]));
|
||||
textContentpri.value[index] = textContentpriArr.value[index][getRandomNumber(textContentpriArr.value[index].length - 1)];
|
||||
|
||||
}
|
||||
//获取手机粘贴板方法
|
||||
function getText(index) {
|
||||
wslist[index].send(getClipboard());
|
||||
|
||||
}
|
||||
|
||||
function getComArr(index, type) {
|
||||
@@ -959,7 +878,6 @@ function getComArr(index, type) {
|
||||
function clickxy(x, y, index, type) {
|
||||
console.log('clickxy方法', x, y)
|
||||
if (type == 3) { //关注/私信 后的返回和下滑
|
||||
|
||||
mouseData.action = 0;
|
||||
mouseData.pressure = 1;
|
||||
mouseData.buttons = 1;
|
||||
@@ -982,7 +900,6 @@ function clickxy(x, y, index, type) {
|
||||
}, 300)
|
||||
}, 300)
|
||||
} else if (type == 2) { //评论过后的返回和右滑
|
||||
|
||||
mouseData.action = 0;
|
||||
mouseData.pressure = 1;
|
||||
mouseData.buttons = 1;
|
||||
@@ -1001,7 +918,6 @@ function clickxy(x, y, index, type) {
|
||||
}, 300)
|
||||
}, 300)
|
||||
} else if (type == 1) {//评论框点击后的发送内容
|
||||
|
||||
mouseData.action = 0;
|
||||
mouseData.pressure = 1;
|
||||
mouseData.buttons = 1;
|
||||
@@ -1029,7 +945,6 @@ function clickxy(x, y, index, type) {
|
||||
mouseData.action = 1;
|
||||
wslist[index].send(toBuffer(mouseData));
|
||||
console.log('抬起按下')
|
||||
|
||||
}, 1500)
|
||||
} else {
|
||||
mouseData.action = 0;
|
||||
@@ -1043,7 +958,6 @@ function clickxy(x, y, index, type) {
|
||||
wslist[index].send(toBuffer(mouseData));
|
||||
}, 100)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//创建任务实例
|
||||
@@ -1051,7 +965,6 @@ function createTaskQueue(index) {
|
||||
if (!taskQueues.has(index)) {
|
||||
taskQueues.set(index, []);
|
||||
}
|
||||
|
||||
return {
|
||||
enqueue(task) {
|
||||
taskQueues.get(index).push(task);
|
||||
@@ -1077,7 +990,6 @@ function sendWsTask(index, data) {
|
||||
console.log('发送任务', data.type);
|
||||
return new Promise((resolve) => {
|
||||
const queue = createTaskQueue(index);
|
||||
|
||||
const task = () => {
|
||||
//发送评论的文本粘贴事件
|
||||
if (data.type == 'Likes') {
|
||||
@@ -1090,19 +1002,16 @@ function sendWsTask(index, data) {
|
||||
if (runType.value[index] == 'follow') {
|
||||
clickxy(160, 360, index)
|
||||
}
|
||||
|
||||
}
|
||||
if (data.type == 'ComPush') {
|
||||
setTimeout(() => {
|
||||
setComText(index)//粘贴内容
|
||||
}, 500)
|
||||
|
||||
}
|
||||
if (data.type == 'searchHost') {
|
||||
setTimeout(() => {
|
||||
setHostId(index)//粘贴内容
|
||||
}, 500)
|
||||
|
||||
}
|
||||
//发送私信的文本粘贴事件
|
||||
if (data.type == 'PrivatePush') {
|
||||
@@ -1116,7 +1025,6 @@ function sendWsTask(index, data) {
|
||||
// wsActions.slideRight(data.udid, index)
|
||||
// }, 500);
|
||||
// }, 500);
|
||||
|
||||
}
|
||||
//发送关注之前的返回
|
||||
if (data.type == 'addHost') {
|
||||
@@ -1128,7 +1036,6 @@ function sendWsTask(index, data) {
|
||||
// }, 1000);
|
||||
// }, 500);
|
||||
}
|
||||
|
||||
//发送任务
|
||||
console.log('发送任务', data);
|
||||
if (data.type == 'Attention') {
|
||||
@@ -1143,7 +1050,6 @@ function sendWsTask(index, data) {
|
||||
// 表示当前任务“已发出”,但不是“已完成”
|
||||
// 实际完成由 onmessage 中的 success 决定并继续执行队列
|
||||
};
|
||||
|
||||
queue.enqueue(task);
|
||||
});
|
||||
}
|
||||
@@ -1164,7 +1070,6 @@ function randomSeeVideo(udid, index) {
|
||||
setTimeout(() => {
|
||||
console.log('观看结束', index);
|
||||
wsActions.isHost(udid, index)//检测
|
||||
|
||||
}, delay);
|
||||
}
|
||||
|
||||
@@ -1173,10 +1078,8 @@ function getVideoStyle(index) {
|
||||
const isSelected = selectedDevice.value === index;
|
||||
const baseWidth = phone.value.width;
|
||||
const baseHeight = phone.value.height;
|
||||
|
||||
// console.log(isSelected, '是否相等')
|
||||
return {
|
||||
|
||||
width: isSelected ? baseWidth * 1.4 + 'px' : baseWidth + 'px',
|
||||
height: isSelected ? baseHeight * 1.4 + 'px' : baseHeight + 'px',
|
||||
border: isSelected ? '2px solid blue' : '1px solid blue',
|
||||
@@ -1186,35 +1089,20 @@ function getVideoStyle(index) {
|
||||
zIndex: isSelected ? 1000 : 1,
|
||||
pointerEvents: isSelected ? 'none' : 'auto',
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function stop(udid, index) {
|
||||
// actions[index] = [];
|
||||
createTaskQueue(index).clear();//清除队伍中的任务
|
||||
cloesMonitor();
|
||||
isStopLike.value.forEach((item, i) => {
|
||||
isStopLike.value[i] = true;
|
||||
runType.value[index] = ''
|
||||
})
|
||||
console.log('停止', isStopLike.value);
|
||||
}
|
||||
|
||||
|
||||
//刷新页面方法
|
||||
function reloadfun() {
|
||||
reload()
|
||||
}
|
||||
|
||||
// //返回次数
|
||||
// function repeatBack(index, times, delay = 1000) {
|
||||
// if (typeof times !== 'number' || times <= 0) return;
|
||||
// for (let i = 1; i <= times; i++) {
|
||||
// setTimeout(() => {
|
||||
// Back('', index);
|
||||
// }, i * delay);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
function openTk() {
|
||||
deviceInformation.value.forEach((device, index) => {
|
||||
wsActions.open(device.udid, index)
|
||||
@@ -1227,7 +1115,6 @@ function openMonitor() {
|
||||
wsActions.getmesNum(device.udid, index)
|
||||
isStopLike.value[index] = false;
|
||||
runType.value[index] = 'listen'
|
||||
|
||||
})
|
||||
isShowMes.value = setInterval(() => {
|
||||
deviceInformation.value.forEach((device, index) => {
|
||||
@@ -1236,6 +1123,7 @@ function openMonitor() {
|
||||
})
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
//关闭监听
|
||||
function cloesMonitor() {
|
||||
deviceInformation.value.forEach((device, index) => {
|
||||
@@ -1247,19 +1135,13 @@ function cloesMonitor() {
|
||||
|
||||
//一键养号
|
||||
function parentNum() {
|
||||
|
||||
deviceInformation.value.forEach((device, index) => {
|
||||
isStopLike.value[index] = false;
|
||||
|
||||
runType.value[index] = 'like'
|
||||
wsActions.isHost(device.udid, index)
|
||||
})
|
||||
}
|
||||
|
||||
//取消弹窗
|
||||
function onDialogCancel() {
|
||||
|
||||
}
|
||||
|
||||
//确认多行文本框内容
|
||||
function onDialogConfirm(result, type, index) {
|
||||
console.log(result, type, index);
|
||||
@@ -1296,7 +1178,6 @@ function onDialogConfirm(result, type, index) {
|
||||
deviceInformation.value.forEach((device, indexB) => {
|
||||
LikesToLikesToLikes(device.udid, indexB, 1)
|
||||
})
|
||||
|
||||
} else {
|
||||
textContentpriArr.value[index] = result;
|
||||
textContentpri.value[index] = result[getRandomNumber(result.length - 1)];
|
||||
@@ -1310,7 +1191,6 @@ function onDialogConfirm(result, type, index) {
|
||||
hostIdContentArr.value[indexA] = hostIdArrList[indexA];
|
||||
hostIdContent.value[indexA] = hostIdContentArr.value[indexA][0];
|
||||
})
|
||||
|
||||
//打开评论弹窗
|
||||
selectedDevice.value = 998;
|
||||
dialogTitle.value = '评论';
|
||||
@@ -1327,183 +1207,19 @@ function onDialogConfirm(result, type, index) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//分割数组
|
||||
function splitArray(array, parts) {
|
||||
if (!Array.isArray(array)) {
|
||||
console.warn('splitArray: 第一个参数应为数组');
|
||||
return [];
|
||||
}
|
||||
const len = array.length;
|
||||
const n = parseInt(parts, 10);
|
||||
if (isNaN(n) || n <= 0) {
|
||||
console.warn('splitArray: 份数应为大于 0 的整数');
|
||||
return [];
|
||||
}
|
||||
const result = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
// 计算第 i 份的起始和结束索引
|
||||
const start = Math.floor(i * len / n);
|
||||
const end = Math.floor((i + 1) * len / n);
|
||||
result.push(array.slice(start, end));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function selectedDeviceFun(index) {
|
||||
selectedDevice.value = index
|
||||
chatContent.value.left = chatList.value[index].leftMsg
|
||||
chatContent.value.right = chatList.value[index].rightMsg
|
||||
console.log(chatList.value);
|
||||
console.log(chatContent.value);
|
||||
function getTranslation(list) {
|
||||
list.forEach((item, index) => {
|
||||
translation({ msg: item.text }).then(res => {
|
||||
console.log(res);
|
||||
chatList.value[index].text = res
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
body {
|
||||
user-select: none;
|
||||
|
||||
}
|
||||
|
||||
.main {
|
||||
display: flex;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: #222;
|
||||
|
||||
}
|
||||
|
||||
.left {
|
||||
background: #191c23;
|
||||
width: 20vw;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 50vw;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(160px, 320px));
|
||||
/* 每行 3 个,宽度自适应 */
|
||||
/* gap: 10px; */
|
||||
}
|
||||
|
||||
.right {
|
||||
width: 30vw;
|
||||
background-color: #272727;
|
||||
}
|
||||
|
||||
.video-container {
|
||||
position: relative;
|
||||
// padding: 10px;
|
||||
width: 100%;
|
||||
|
||||
width: auto;
|
||||
/* 取消 100%,避免换行 */
|
||||
display: inline-block;
|
||||
display: flex;
|
||||
transition: all 0.3s ease-in-out;
|
||||
|
||||
.video-canvas {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
.input-info {
|
||||
color: rgb(255, 255, 255);
|
||||
background-color: #424242;
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
}
|
||||
}
|
||||
|
||||
video {
|
||||
transition: all 0.3s ease-in-out;
|
||||
|
||||
/* 关键:让 video 不拦截鼠标事件 */
|
||||
|
||||
/* 添加动画 */
|
||||
}
|
||||
|
||||
.top-row {
|
||||
align-items: flex-start;
|
||||
/* 上对齐 */
|
||||
}
|
||||
|
||||
.bottom-row {
|
||||
align-items: flex-end;
|
||||
/* 下对齐 */
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
video {
|
||||
/* position: relative; */
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
/* object-fit: contain; */
|
||||
/* transform: scale(0.27); */
|
||||
/* 缩小到原始尺寸的50% */
|
||||
/* transform-origin: top left; */
|
||||
/* 控制缩放原点 */
|
||||
}
|
||||
|
||||
.canvas {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 9;
|
||||
/* transform: scale(0.27); */
|
||||
/* 缩小到原始尺寸的50% */
|
||||
/* transform-origin: top left; */
|
||||
/* 控制缩放原点 */
|
||||
}
|
||||
|
||||
.open {
|
||||
background: url(../assets/open.png) no-repeat center center;
|
||||
background-size: 60% 60%;
|
||||
|
||||
}
|
||||
|
||||
.Back {
|
||||
background: url(../assets/Back.png) no-repeat center center;
|
||||
background-size: 60% 60%;
|
||||
|
||||
}
|
||||
|
||||
.Home {
|
||||
background: url(../assets/Home.png) no-repeat center center;
|
||||
background-size: 60% 60%;
|
||||
|
||||
}
|
||||
|
||||
.Overview {
|
||||
background: url(../assets/Overview.png) no-repeat center center;
|
||||
background-size: 60% 60%;
|
||||
|
||||
}
|
||||
|
||||
.el-button {
|
||||
width: 200px;
|
||||
margin: 20px;
|
||||
// background-color: darkcyan;
|
||||
// color: white;
|
||||
position: relative;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.center-justify {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.center-line {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
// justify-content: center;
|
||||
}
|
||||
@import '../static/css/video.less';
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user