更新记录
1.0.0(2025-07-01)
初始化项目
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | 5.0 | × | × |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | - | × | × | × | × |
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | 5.0 | × | × | × |
acwy-adb
注意事项
因三方库问题,需要在manifest.json
的源码里添加packagingOptions
详见[packagingOptions配置](https://doc.dcloud.net.cn/uni-app-x/collocation/manifest-android.html#packagingoptions)
"android": {
"packagingOptions": [
"exclude 'META-INF/LICENSE.md'",
"exclude 'META-INF/LICENSE-notice.md'"
]
}
引入
import { adb } from '@/uni_modules/acwy-adb'
方法
初始化:在 uvue data 里初始化一个 classAdb: new adb()
getWifiIp
/**
* @description getWifiIp 获取本机IP,WIFI未连接返回''
* @returns Promise<string> ip
*/
this.classAdb.getWifiIp().then(ip=>{
// ip
}).catch(err=>{
// ''
})
scan
/**
* @description scan 扫描 IP:端口
* @param ip string ipv4
* @returns Promise<boolean> true/false
*/
this.classAdb.scan(ip, port=5555, timeout=1000).then((res: boolean)=>{
// true
}).catch(err=>{
// false
})
scanAll
/**
* @description scanAll 扫描指定IP所在网段1-255的IP:端口,无需处理IP
* @param ip string ipv4
* @returns Promise<string[]> 返回开放指定端口的所有IP
*/
this.classAdb.scanAll(ip : string, port : number = 5555, timeout : number = 300)
connect
/**
* @description connect 连接指定IP,后续命令必须先连接成功才能执行
* @param ip string ipv4
* @returns Promise<boolean> true/false
*/
this.classAdb.connect(ip : string)
exec
/**
* @description exec 对目标安卓设备执行adb shell命令
* @param command string shell命令,比如am pm和其他命令
* @returns Promise<string> 执行成功结果/错误信息
*/
this.classAdb.exec(command : string)
install
/**
* @description 安装指定路径的apk到目标安卓设备
* @param apkPath string apk真实路径,比如下载的res.tempFilePath或者UTSAndroid.convert2AbsFullPath()
* @param mode string adb安装模式,-r -g等,可自行搜索
* @returns Promise<string> true/false
*/
this.classAdb.install(apkPath: string, mode: string[]=['-r', '-g'])
uninstall
/**
* @description 卸载目标安卓设备APP
* @param packageName string apk包名
* @returns Promise<string> true/false
*/
uninstall(packageName: string)
this.classAdb.uninstall(packageName: string)
pushFile
/**
* @description 推送文件到目标设备
* @param localPath string 本机文件路径
* @param remotePath string 目标设备存放文件的路径
* @returns Promise<string> true/false
*/
this.classAdb.pushFile(localPath: string, remotePath: string)
pullFile
/**
* @description 拉取目标设备的文件
* @param remotePath string 目标设备存放文件的路径
* @param localPath string 拉取文件存放到本机的路径
* @returns Promise<string> true/false
*/
this.classAdb.pullFile(remotePath: string, localPath: string)