0.0.8 • Published 11 months ago
quickapp-async v0.0.8
quickapp-async
一个使用 Promise
封装的的快应用工具库。解决了快应用开发过程中调用框架提供的 API 不能使用 async
/await
的问题。
用法
安装
npm install quickapp-async -S
调用
以获取存储内容方法为例
import { asyncStorageGet } from 'quickapp-async';
export default {
async onInit() {
const test = await asyncStorageGet({
key: 'test'
})
}
}
方法索引
方法名通常是 async
+ 模块名 + 方法,例如 network.getType()
对应的方法名 asyncNetworkGetType
。
界面交互
分享 share
asyncShareShare
:share.share(OBJECT) 分享数据到其他 app
弹窗 prompt
asyncPromptShowDialog
:prompt.showDialog(OBJECT) 显示对话框asyncPromptShowContextMenu
:prompt.showContextMenu(OBJECT) 显示上下文菜单
打开网页 webview
asyncWebviewSetCookie
:webview.setCookie(OBJECT) 设置WebView的Cookie信息
网络访问
上传下载 request
asyncRequestUpload
:request.upload(OBJECT) 上传文件asyncRequestDownload
:request.download(OBJECT) 下载文件asyncRequestOnDownloadComplete
:request.onDownloadComplete(OBJECT) 监听下载任务
文件数据
数据存储 storage
asyncStorageGet
:storage.get(OBJECT) 读取存储内容asyncStorageSet
:storage.set(OBJECT) 修改存储内容asyncStorageClear
:storage.clear(OBJECT) 清空存储内容asyncStorageDelete
:storage.delete(OBJECT) 删除存储内容asyncStorageKey
:storage.key(OBJECT) 返回存储中某个index
的键名
文件存储 file
asyncStorageGet
:file.move(OBJECT) 将源文件移动到指定位置asyncFileCopy
:file.copy(OBJECT) 将源文件复制一份并存储到指定位置asyncFileList
:file.list(OBJECT) 获取指定目录下的文件列表asyncFileGet
:file.get(OBJECT) 获取本地文件的文件信息asyncFileDelete
:file.delete(OBJECT) 删除本地存储的文件asyncFileWriteText
:file.writeText(OBJECT) 写文本到文件asyncFileWriteArrayBuffer
:file.writeArrayBuffer(OBJECT) 写Buffer
到文件asyncFileReadText
:file.readText(OBJECT) 从文件中读取文本asyncFileReadArrayBuffer
:file.readArrayBuffer(OBJECT) 从文件中读取Buffer
asyncFileAccess
:file.access(OBJECT) 判断文件或目录是否存在asyncFileMkdir
:file.mkdir(OBJECT) 创建目录asyncFileRmdir
:file.rmdir(OBJECT) 删除目录
交换数据 exchange
asyncExchangeGet
:exchange.get(OBJECT) 读取快应用平台数据asyncExchangeSet
:exchange.set(OBJECT) 发布数据到快应用平台asyncExchangeRemove
:exchange.remove(OBJECT) 从快应用平台删除发布到应用空间(application
)的数据asyncExchangeClear
:exchange.clear(OBJECT) 从快应用平台清除当前快应用的应用空间的数据asyncExchangeGrantPermission
:exchange.grantPermission(OBJECT) 授予指定快应用读取get
、修改set
、删除remove
数据的权限asyncExchangeRevokePermission
:exchange.revokePermission(OBJECT) 取消授予指定快应用读取get
、修改set
、删除remove
数据的权限
系统能力
二维码 barcode
asyncBarcodeScan
:barcode.scan(OBJECT) 扫描二维码
剪贴板 clipboard
asyncClipboardSet
:clipboard.set(OBJECT) 修改剪贴板内容asyncClipboardGet
:clipboard.get(OBJECT) 读取剪贴板内容
地理位置 geolocation
asyncGeolocationGetLocation
:geolocation.getLocation(OBJECT) 获取地理位置asyncGeolocationOpenLocation
:geolocation.openLocation(OBJECT) 使用快应用内置地图查看位置,并且允许拉起第三方地图应用发起导航asyncGeolocationChooseLocation
:geolocation.chooseLocation(OBJECT) 打开快应用内置地图选择位置asyncGeolocationGetLocationType
:geolocation.getLocationType(OBJECT) 获取系统当前支持的定位类型asyncGeolocationGeocodeQuery
:geolocation.geocodeQuery(OBJECT) 地理编码,只支持国内地理位置asyncGeolocationReverseGeocodeQuery
:geolocation.reverseGeocodeQuery(OBJECT) 逆地理编码,只支持国内地理位置
桌面图标 shortcut
asyncShortcutHasInstalled
:shortcut.hasInstalled(OBJECT) 获取桌面图标是否创建asyncShortcuInstall
:shortcut.install(OBJECT) 创建桌面图标
日历事件 calendar
asyncCalendarInsert
:calendar.insert(OBJECT) 插入日历事件
网络状态 network
asyncNetworkGetType
:network.getType(OBJECT) 获取网络类型asyncNetworkGetSimOperators
:network.getSimOperators(OBJECT) 获取Sim卡的运营商信息
设备信息 device
asyncDeviceGetInfo
:device.getInfo(OBJECT) 获取设备信息asyncDeviceGetId
:device.getId(OBJECT) 批量获取设备标识asyncDeviceGetDeviceId
:device.getDeviceId(OBJECT) 获取设备唯一标识asyncDeviceGetUserId
:device.getUserId(OBJECT) 获取用户唯一标识asyncDeviceGetAdvertisingId
:device.getAdvertisingId(OBJECT) 获取广告唯一标识asyncDeviceGetSerial
:device.getSerial(OBJECT) 获取设备序列号asyncDeviceGetTotalStorage
:device.getTotalStorage(OBJECT) 获取存储空间的总大小asyncDeviceGetAvailableStorage
:device.getAvailableStorage(OBJECT) 获取存储空间的可用大小asyncDeviceGetCpuInfo
:device.getCpuInfo(OBJECT) 返回 CPU 信息asyncDeviceGetOAID
:device.getOAID(OBJECT) 返回厂商设备标识符中的 OAID(匿名设备标识符)
通信信息 telecom
asyncTelecomGetTelecomInfo
:telecom.getTelecomInfo(OBJECT) 获取设备通信信息
屏幕亮度 brightness
asyncBrightnessGetValue
:brightness.getValue(OBJECT) 获得当前屏幕亮度值asyncBrightnessSetValue
:brightness.setValue(OBJECT) 设置当前屏幕亮度值asyncBrightnessGetMode
:brightness.getMode(OBJECT) 获得当前屏幕亮度模式asyncBrightnessSetMode
:brightness.setMode(OBJECT) 设置当前屏幕亮度模式asyncBrightnessSetKeepScreenOn
:brightness.setKeepScreenOn(OBJECT) 设置是否保持常亮状态
系统音量 volume
asyncVolumeGetMediaValue
:volume.getMediaValue(OBJECT) 获取当前多媒体音量asyncVolumeSetMediaValue
:volume.setMediaValue(OBJECT) 设置当前多媒体音量
电量信息 battery
asyncBatteryGetStatus
:battery.getStatus(OBJECT) 获取当前设备的电量信息
应用管理 package
asyncPkgHasInstalled
:pkg.hasInstalled(OBJECT) 检测应用是否存在asyncPkgInstall
:pkg.install(OBJECT) 安装应用asyncPkgGetInfo
:pkg.getInfo(OBJECT) 获取应用版本号、版本名称信息asyncPkgGetSignatureDigests
:pkg.getSignatureDigests(OBJECT) 获取应用签名摘要信息
录音 record
asyncRecordStart
:record.start(OBJECT) 开始录音
联系人 contact
asyncContactPick
:contact.pick(OBJECT) 选择联系人asyncContactList
:contact.list(OBJECT) 获取通讯录所有联系人列表
发送短信 sms
asyncSmsSend
:sms.send(OBJECT) 发送短信asyncSmsReadSafely
:sms.readSafely(OBJECT) 获取手机短信内容
Wi-Fi wifi
asyncWifiConnect
:wifi.connect(OBJECT) 连接 Wi-FiasyncWifiScan
:wifi.scan(OBJECT) 请求获取 Wi-Fi 列表asyncWifiGetConnectedWifi
:wifi.getConnectedWifi(OBJECT) 获取已连接中的 Wi-Fi 信息
蓝牙 bluetooth
asyncBluetoothOpenAdapter
:bluetooth.openAdapter(OBJECT) 初始化蓝牙模块asyncBluetoothCloseAdapter
:bluetooth.closeAdapter(OBJECT) 关闭蓝牙模块asyncBluetoothGetAdapterState
:bluetooth.getAdapterState(OBJECT) 获取本机蓝牙适配器状态asyncBluetoothStartDevicesDiscovery
:bluetooth.startDevicesDiscovery(OBJECT) 开始搜寻附近的蓝牙外围设备asyncBluetoothStopDevicesDiscovery
:bluetooth.getAdapterState(OBJECT) 停止搜寻附近的蓝牙外围设备asyncBluetoothGetDevices
:bluetooth.getDevices(OBJECT) 获取在蓝牙模块生效期间所有已发现的蓝牙设备asyncBluetoothGetConnectedDevices
:bluetooth.getConnectedDevices(OBJECT) 根据 uuid 获取处于已连接状态的设备asyncBluetoothCreateBLEConnection
:bluetooth.createBLEConnection(OBJECT) 连接低功耗蓝牙设备asyncBluetoothCloseBLEConnection
:bluetooth.closeBLEConnection (OBJECT) 断开与低功耗蓝牙设备的连接asyncBluetoothGetBLEDeviceServices
:bluetooth.getBLEDeviceServices(OBJECT) 获取蓝牙设备所有服务(service)asyncBluetoothGetBLEDeviceCharacteristics
:bluetooth.getBLEDeviceCharacteristics(OBJECT) 获取蓝牙设备某个服务中所有特征值(characteristic)asyncBluetoothReadBLECharacteristicValue
:bluetooth.readBLECharacteristicValue(OBJECT) 读取低功耗蓝牙设备的特征值的二进制数据值asyncBluetoothWriteBLECharacteristicValue
:bluetooth.writeBLECharacteristicValue(OBJECT) 向低功耗蓝牙设备特征值中写入二进制数据asyncBluetootNotifyBLECharacteristicValueChange
:bluetooth.notifyBLECharacteristicValueChange(OBJECT) 启用低功耗蓝牙设备特征值变化时的 notify 功能,订阅特征值
闹钟 alarm
asyncAlarmSetAlarm
:alarm.setAlarm (OBJECT) 设置闹钟,每次添加弹出提示框,同意后调用接口添加asyncAlarmIsAvailable
:alarm.isAvailable(OBJECT) 获取闹钟能力可用状态
解压缩 zip
asyncZipDecompress
:zip.decompress(OBJECT) 解压文件
锁屏 keyguard
asyncKeyguardGetKeyguardLockedStatus
:keyguard.getKeyguardLockedStatus(OBJECT) 获取快应用当前环境是否为锁屏状态
更多方法稍后带来……
0.0.8
11 months ago
0.0.7
11 months ago
0.0.6
11 months ago
0.0.5
11 months ago
0.0.4
11 months ago
0.0.3
11 months ago
0.0.2
11 months ago
0.0.1-alpha.11
11 months ago
0.0.1-alpha.10
12 months ago
0.0.1-alpha.9
12 months ago
0.0.1-alpha.8
12 months ago
0.0.1-alpha.7
12 months ago
0.0.1-alpha.6
12 months ago
0.0.1-alpha.5
12 months ago
0.0.1-alpha.4
12 months ago
0.0.1-alpha.3
12 months ago
0.0.1-alpha.2
12 months ago
0.0.1-alpha.1
12 months ago