更新记录
1.0.4(2024-08-28)
1.文档修改
1.0.3(2024-08-27)
1.增加分页搜索查询 listInstalledApps
1.0.2(2024-08-27)
1.增加versionCode返回
查看更多平台兼容性
Vue2 | Vue3 |
---|---|
√ | √ |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 3.8.12,Android:5.0,iOS:不支持,HarmonyNext:不确定 | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 |
---|---|---|---|
× | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × |
使用文档
方法
startListener
启动监听APP安装卸载
// uniapp中使用
import { startListener } from '@/uni_modules/dd-packages'
startListener(res => {
/**
* {
* flag: false, // true 安装 false 卸载
* data: {
* "appPath": "/system/priv-app/HSDR/HSDR.apk",
* "versionName": "14.0.0.300",
* "versionCode": 1400000300,
* "name": "HSDR",
* "packageName": "com.huawei.security.hsdr",
* "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg…",
* "isSystemApp": true
* }
* }
*/
})
// uniappx中使用
import { startListener,AppFlagInfo } from '@/uni_modules/dd-packages'
startListener((res:AppFlagInfo) => {
/**
* {
* flag: false, // true 安装 false 卸载
* data: {
* "appPath": "/system/priv-app/HSDR/HSDR.apk",
* "versionName": "14.0.0.300",
* "versionCode": 1400000300,
* "name": "HSDR",
* "packageName": "com.huawei.security.hsdr",
* "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg…",
* "isSystemApp": true
* }
* }
*/
})
stopListener
停止监听
import { stopListener } from '@/uni_modules/dd-packages'
stopListener()
getInstalledApps
获取已安装的app列表
// uniapp中使用
import { getInstalledApps } from '@/uni_modules/dd-packages'
getInstalledApps(res => {
/**[
* {
* "appPath": "/system/priv-app/HSDR/HSDR.apk",
* "versionName": "14.0.0.300",
* "versionCode": 1400000300,
* "name": "HSDR",
* "packageName": "com.huawei.security.hsdr",
* "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg…",
* "isSystemApp": true
* },
* ……
* ]
*/
})
// uniappx中使用
import { getInstalledApps,AppInfo } from '@/uni_modules/dd-packages'
getInstalledApps((res:AppInfo[]) => {
/**[
* {
* "appPath": "/system/priv-app/HSDR/HSDR.apk",
* "versionName": "14.0.0.300",
* "versionCode": 1400000300,
* "name": "HSDR",
* "packageName": "com.huawei.security.hsdr",
* "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg…",
* "isSystemApp": true
* },
* ……
* ]
*/
})
listInstalledApps
获取已安装的app列表(分页)
// uniapp中使用
import { listInstalledApps } from '@/uni_modules/dd-packages'
listInstalledApps({
page: 1,
pagesize: 20, //不传默认为10
isSystem: false, // 不传默认所有类型,true 仅包含系统APP,false 仅包含非系统APP
name: 'HS', // APP名称,可为空
success: result => {
/**
* {
* page: 1,
* pagesize: 20,
* total: 15,
* list: [
* {
* "appPath": "/system/priv-app/HSDR/HSDR.apk",
* "versionName": "14.0.0.300",
* "versionCode": 1400000300,
* "name": "HSDR",
* "packageName": "com.huawei.security.hsdr",
* "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg…",
* "isSystemApp": true
* },
* ……
* ]
* }
*/
}
})
// uniappx中使用
import { getInstalledApps,ListInstalledAppsOptions,ListInstalledAppsSuccess } from '@/uni_modules/dd-packages'
listInstalledApps({
page: 1,
pagesize: 20, //不传默认为10
isSystem: false, // 不传默认所有类型,true 仅包含系统APP,false 仅包含非系统APP
name: 'HS', // APP名称,可为空
success: (result: ListInstalledAppsSuccess) => {
/**
* {
* page: 1,
* pagesize: 20,
* total: 15,
* list: [
* {
* "appPath": "/system/priv-app/HSDR/HSDR.apk",
* "versionName": "14.0.0.300",
* "versionCode": 1400000300,
* "name": "HSDR",
* "packageName": "com.huawei.security.hsdr",
* "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg…",
* "isSystemApp": true
* },
* ……
* ]
* }
*/
}
} as ListInstalledAppsOptions)
searchAppInfo
查询app信息
// uniapp中使用
import { searchAppInfo } from '@/uni_modules/dd-packages'
const packageName = 'com.huawei.security.hsdr'
const res = searchAppInfo(packageName)
// uniappx中使用
import { searchAppInfo,AppInfo } from '@/uni_modules/dd-packages'
const packageName = 'com.huawei.security.hsdr'
const res:AppInfo|null = searchAppInfo(packageName)
/**
* 如果包存在则返回信息,不存在则返回null
* {
* "appPath": "/system/priv-app/HSDR/HSDR.apk",
* "versionName": "14.0.0.300",
* "versionCode": 1400000300,
* "name": "HSDR",
* "packageName": "com.huawei.security.hsdr",
* "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg…",
* "isSystemApp": true
* }
*/