first commit

This commit is contained in:
编码猿
2024-09-27 01:26:21 +08:00
commit 63459fdc40
12 changed files with 148 additions and 0 deletions

55
utils/index.js Normal file
View File

@@ -0,0 +1,55 @@
const exec = require('child_process').exec;
const config = require('../config');
class Utils{
/**
* 运行命令
* @param cmdStr
* @returns {Promise<unknown>}
*/
execShell (cmdStr) {
return new Promise((resolve,reject)=> {
exec(cmdStr, function(err,stdout,stderr) {
if(err) {
console.log('shell is run: '+ stderr);
} else {
resolve(stdout)
}
});
})
}
/**
* 检查是否安装 ADBKeyboard.apk app
* 否则无法输入中文
* @constructor
*/
async CheckAdbKeyboard() {
let res = await this.execShell(config.baseShell.adbkeyboard);
if (res.indexOf("com.android.adbkeyboard") > -1) {
return true
} else {
console.error("请先安装 ADBKeyboard.apk")
return false
}
}
/**
* 检查是否安装adb
* @returns {Promise<void>}
* @constructor
*/
async CheckInstallAdb() {
let res = await this.execShell(config.baseShell.adb)
if (res.indexOf("Android Debug Bridge version") > -1) {
return true
} else {
console.error("请先在PC电脑上安装adb工具")
return false
}
}
}
module.exports = new Utils();