7 Star 70 Fork 31

大菜卵/Aircontroller-scrcpy

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
devicesWorker.js 957 Bytes
Copy Edit Raw Blame History
yanghang authored 2021-12-25 19:32 . 首次提交
var cmd = require('node-cmd');
const path = require('path');
const adb_path = path.join(__dirname, '../adb/adb.exe');
var lastData = [];
loadDevices();
setInterval(loadDevices, 10000);
function loadDevices(){
let stateMap = {
device:'已连接电脑',
offline:'无法链接',
unauthorized:'未授权'
};
let data2 = [];
cmd.get(adb_path + " devices", (e, d, s) => {
res = d.split("\n");
res.forEach((item, index) => {
if (index < 1 || !(item.replace(/[ ]*/g, '')) || item.length == 1) {
return
}
var deviceInfo = item.replace("\r","").split(" ");
data2.push({ client: deviceInfo[0],stateName:stateMap[deviceInfo[1]] });
});
// if(JSON.stringify(lastData)!=JSON.stringify(data2)){
// lastData = data2;
// postMessage(data2);
// }
postMessage(data2);
});
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sycsky/aircontroller-scrcpy.git
git@gitee.com:sycsky/aircontroller-scrcpy.git
sycsky
aircontroller-scrcpy
Aircontroller-scrcpy
master

Search