first commit
This commit is contained in:
1
utils/.pydio
Normal file
1
utils/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
358a802d-b623-4739-bde0-48834194aec5
|
||||
55
utils/index.js
Normal file
55
utils/index.js
Normal 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();
|
||||
Reference in New Issue
Block a user