Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
ad61ae01
U
uni-api
项目概览
DCloud
/
uni-api
通知
674
Star
23
Fork
12
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ad61ae01
编写于
9月 05, 2023
作者:
DCloud_iOS_WZT
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://gitcode.net/dcloud/uni-api
into dev
上级
a43b7911
bfe51f67
变更
31
显示空白变更内容
内联
并排
Showing
31 changed file
with
1303 addition
and
278 deletion
+1303
-278
.gitignore
.gitignore
+8
-1
jest.config.js
jest.config.js
+0
-11
manifest.json
manifest.json
+71
-71
pages/index/index.vue
pages/index/index.vue
+7
-0
uni_modules/uni-getLocation-tencent/changelog.md
uni_modules/uni-getLocation-tencent/changelog.md
+0
-0
uni_modules/uni-getLocation-tencent/package.json
uni_modules/uni-getLocation-tencent/package.json
+84
-0
uni_modules/uni-getLocation-tencent/readme.md
uni_modules/uni-getLocation-tencent/readme.md
+50
-0
uni_modules/uni-getLocation-tencent/utssdk/app-android/AndroidManifest.xml
...etLocation-tencent/utssdk/app-android/AndroidManifest.xml
+31
-0
uni_modules/uni-getLocation-tencent/utssdk/app-android/config.json
...es/uni-getLocation-tencent/utssdk/app-android/config.json
+7
-0
uni_modules/uni-getLocation-tencent/utssdk/app-android/index.uts
...ules/uni-getLocation-tencent/utssdk/app-android/index.uts
+219
-0
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
+93
-0
uni_modules/uni-getbatteryinfo/package.json
uni_modules/uni-getbatteryinfo/package.json
+6
-1
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
+38
-2
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
+14
-1
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
+116
-38
uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js
uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js
+3
-0
uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js
uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js
+3
-0
uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js
uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js
+3
-0
uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js
uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js
+3
-0
uni_modules/uni-memorywarning/package.json
uni_modules/uni-memorywarning/package.json
+14
-16
uni_modules/uni-memorywarning/utssdk/app-android/index.uts
uni_modules/uni-memorywarning/utssdk/app-android/index.uts
+3
-3
uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
+4
-2
uni_modules/uni-memorywarning/utssdk/interface.uts
uni_modules/uni-memorywarning/utssdk/interface.uts
+55
-0
uni_modules/uni-usercapturescreen/package.json
uni_modules/uni-usercapturescreen/package.json
+10
-3
uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
...odules/uni-usercapturescreen/utssdk/app-android/index.uts
+5
-5
uni_modules/uni-usercapturescreen/utssdk/interface.uts
uni_modules/uni-usercapturescreen/utssdk/interface.uts
+71
-32
uni_modules/uni-wifi/package.json
uni_modules/uni-wifi/package.json
+41
-19
uni_modules/uni-wifi/utssdk/app-android/index.uts
uni_modules/uni-wifi/utssdk/app-android/index.uts
+1
-1
uni_modules/uni-wifi/utssdk/app-ios/config.json
uni_modules/uni-wifi/utssdk/app-ios/config.json
+8
-7
uni_modules/uni-wifi/utssdk/interface.uts
uni_modules/uni-wifi/utssdk/interface.uts
+318
-48
uni_modules/uni-wifi/utssdk/uni.autotest.js
uni_modules/uni-wifi/utssdk/uni.autotest.js
+17
-17
未找到文件。
.gitignore
浏览文件 @
ad61ae01
...
...
@@ -2,3 +2,10 @@
/.hbuilderx
/.vite
.DS_Store
env.js
jest.config.js
autotest.reporter.js
autotest.utils.js
pages/autotest/
node_modules/
vite.config.js
\ No newline at end of file
jest.config.js
已删除
100644 → 0
浏览文件 @
a43b7911
module
.
exports
=
{
testTimeout
:
10000
,
reporters
:
[
'
default
'
],
watchPathIgnorePatterns
:
[
'
/node_modules/
'
,
'
/dist/
'
,
'
/.git/
'
],
moduleFileExtensions
:
[
'
js
'
,
'
json
'
],
rootDir
:
__dirname
,
testMatch
:
[
"
<rootDir>/pages/**/*test.[jt]s?(x)
"
],
testPathIgnorePatterns
:
[
'
/node_modules/
'
]
}
manifest.json
浏览文件 @
ad61ae01
{
"name"
:
"uni-api"
,
"appid"
:
"__UNI__ED9218B"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
"transformPx"
:
false
,
"name"
:
"uni-api"
,
"appid"
:
"__UNI__ED9218B"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
"transformPx"
:
false
,
/*
5
+App特有相关
*/
"app-plus"
:
{
"usingComponents"
:
true
,
"nvueStyleCompiler"
:
"uni-app"
,
"compilerVersion"
:
3
,
"splashscreen"
:
{
"alwaysShowBeforeRender"
:
true
,
"waiting"
:
true
,
"autoclose"
:
true
,
"delay"
:
0
"app-plus"
:
{
"usingComponents"
:
true
,
"nvueStyleCompiler"
:
"uni-app"
,
"compilerVersion"
:
3
,
"splashscreen"
:
{
"alwaysShowBeforeRender"
:
true
,
"waiting"
:
true
,
"autoclose"
:
true
,
"delay"
:
0
},
/*
模块配置
*/
"modules"
:
{},
"modules"
:
{},
/*
应用发布信息
*/
"distribute"
:
{
"distribute"
:
{
/*
android打包配置
*/
"android"
:
{
"permissions"
:
[
"android"
:
{
"permissions"
:
[
"<uses-permission android:name=
\"
android.permission.CHANGE_NETWORK_STATE
\"
/>"
,
"<uses-permission android:name=
\"
android.permission.MOUNT_UNMOUNT_FILESYSTEMS
\"
/>"
,
"<uses-permission android:name=
\"
android.permission.VIBRATE
\"
/>"
,
...
...
@@ -41,32 +41,32 @@
]
},
/*
ios打包配置
*/
"ios"
:
{},
"ios"
:
{},
/*
SDK配置
*/
"sdkConfigs"
:
{}
"sdkConfigs"
:
{}
}
},
/*
快应用特有相关
*/
"quickapp"
:
{},
"quickapp"
:
{},
/*
小程序特有相关
*/
"mp-weixin"
:
{
"appid"
:
""
,
"setting"
:
{
"urlCheck"
:
false
"mp-weixin"
:
{
"appid"
:
""
,
"setting"
:
{
"urlCheck"
:
false
},
"usingComponents"
:
true
"usingComponents"
:
true
},
"mp-alipay"
:
{
"usingComponents"
:
true
"mp-alipay"
:
{
"usingComponents"
:
true
},
"mp-baidu"
:
{
"usingComponents"
:
true
"mp-baidu"
:
{
"usingComponents"
:
true
},
"mp-toutiao"
:
{
"usingComponents"
:
true
"mp-toutiao"
:
{
"usingComponents"
:
true
},
"uniStatistics"
:
{
"enable"
:
false
"uniStatistics"
:
{
"enable"
:
false
},
"vueVersion"
:
"2"
"vueVersion"
:
"3"
}
pages/index/index.vue
浏览文件 @
ad61ae01
...
...
@@ -16,6 +16,7 @@
<button
@
tap=
"testSetUserCaptureScreen"
>
{{
setUserCaptureScreenText
}}
</button>
<button
@
tap=
"testGetBatteryInfo"
>
获取电池电量
</button>
<button
@
tap=
"testGetBatteryInfoSync"
>
同步获取电池电量
</button>
<button
@
tap=
"testonMemoryWarning"
>
开启内存不足告警监听
</button>
<button
@
tap=
"testoffMemoryWarning"
>
关闭内存不足告警监听
</button>
...
...
@@ -222,6 +223,12 @@
}
})
},
testGetBatteryInfoSync
()
{
let
ret
=
uni
.
getBatteryInfoSync
()
console
.
log
(
ret
)
},
testSetUserCaptureScreen
()
{
let
flag
=
this
.
setUserCaptureScreenFlag
;
uni
.
setUserCaptureScreen
({
...
...
uni_modules/uni-getLocation-tencent/changelog.md
0 → 100644
浏览文件 @
ad61ae01
uni_modules/uni-getLocation-tencent/package.json
0 → 100644
浏览文件 @
ad61ae01
{
"id"
:
"uni-getLocation-tencent"
,
"displayName"
:
"uni-getLocation-tencent"
,
"version"
:
"1.0.0"
,
"description"
:
"uni-getLocation-tencent"
,
"keywords"
:
[
"uni-getLocation-tencent"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.11"
},
"dcloudext"
:
{
"type"
:
"uts"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
""
,
"data"
:
""
,
"permissions"
:
""
},
"npmurl"
:
""
},
"uni_modules"
:
{
"uni-ext-api"
:
{
"uni"
:
[
"getLocation"
]
},
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"u"
,
"aliyun"
:
"u"
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"n"
,
"vue3"
:
"y"
},
"App"
:
{
"app-android"
:
"u"
,
"app-ios"
:
"u"
},
"H5-mobile"
:
{
"Safari"
:
"u"
,
"Android Browser"
:
"u"
,
"微信浏览器(Android)"
:
"u"
,
"QQ浏览器(Android)"
:
"u"
},
"H5-pc"
:
{
"Chrome"
:
"u"
,
"IE"
:
"u"
,
"Edge"
:
"u"
,
"Firefox"
:
"u"
,
"Safari"
:
"u"
},
"小程序"
:
{
"微信"
:
"u"
,
"阿里"
:
"u"
,
"百度"
:
"u"
,
"字节跳动"
:
"u"
,
"QQ"
:
"u"
,
"钉钉"
:
"u"
,
"快手"
:
"u"
,
"飞书"
:
"u"
,
"京东"
:
"u"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-getLocation-tencent/readme.md
0 → 100644
浏览文件 @
ad61ae01
# uts-tencentgeolocation腾讯定位插件使用文档
## Android 平台
1.
申请腾讯地图key
[
申请网址
](
https://lbs.qq.com/mobile/androidMapSDK/developerGuide/getKey
)
2.
配置key到插件中
修改项目根目录下 AndroidManifest.xml
`<meta-data android:name="TencentMapSDK" android:value="您申请的Key" />`
3.
打包自定义基座
注意将
`uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar`
先移到其他目录。
4.
运行自定义基座
注意打包自定义基座后将androix-core-1.0.0.jar移回原位,然后真机运行自定义基座。这个临时的移出移入问题后续会升级解决,详见uts插件开发文档的
[
临时注意
](
https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#tempnotice
)
。
## iOS 平台
1.
申请腾讯地图key
[
申请网址
](
https://lbs.qq.com/mobile/androidMapSDK/developerGuide/getKey
)
2.
配置key到插件中
将申请的key配置到插件目录下 app-ios -> info.plist 中 TencentLBSAPIKey 对应的值
```
xml
<key>
TencentLBSAPIKey
</key>
<string>
您申请的Key
</string>
```
3.
配置访问位置权限描述信息
选中工程中的 manifest.json -> App权限配置 -> iOS隐私信息访问的许可描述,分别配置下列权限描述信息
-
NSLocationAlwaysUsageDescription
-
NSLocationWhenInUseUsageDescription
-
NSLocationAlwaysAndWhenInUseUsageDescription
4.
制作自定义基座运行后生效
## 相关开发文档
-
[
UTS 语法
](
https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html
)
-
[
UTS 原生插件
](
https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
)
\ No newline at end of file
uni_modules/uni-getLocation-tencent/utssdk/app-android/AndroidManifest.xml
0 → 100644
浏览文件 @
ad61ae01
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"io.dcloud.nativeresouce"
>
<!--permissions-->
<!-- 通过GPS得到精确位置 -->
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<!-- 通过网络得到粗略位置 -->
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<!-- 访问网络,某些位置信息需要从网络服务器获取 -->
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<!-- 访问WiFi状态,需要WiFi信息用于网络定位 -->
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<!-- 修改WiFi状态,发起WiFi扫描, 需要WiFi信息用于网络定位 -->
<uses-permission
android:name=
"android.permission.CHANGE_WIFI_STATE"
/>
<!-- 访问网络状态, 检测网络的可用性,需要网络运营商相关信息用于网络定位 -->
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<!-- 访问网络的变化, 需要某些信息用于网络定位 -->
<uses-permission
android:name=
"android.permission.CHANGE_NETWORK_STATE"
/>
<!-- 蓝牙扫描权限 -->
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH_ADMIN"
/>
<!-- 前台service权限 -->
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<!-- 后台定位权限 -->
<uses-permission
android:name=
"android.permission.ACCESS_BACKGROUND_LOCATION"
/>
<!-- A-GPS辅助定位权限,方便GPS快速准确定位 -->
<uses-permission
android:name=
"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
/>
</manifest>
uni_modules/uni-getLocation-tencent/utssdk/app-android/config.json
0 → 100644
浏览文件 @
ad61ae01
{
"dependencies"
:
[
"com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.3.0"
],
"minSdkVersion"
:
21
}
uni_modules/uni-getLocation-tencent/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
ad61ae01
import {
UTSAndroid
} from "io.dcloud.uts";
import ActivityCompat from "androidx.core.app.ActivityCompat";
import Manifest from "android.Manifest";
import Looper from "android.os.Looper";
import TencentLocationManager from "com.tencent.map.geolocation.TencentLocationManager";
import TencentLocationListener from "com.tencent.map.geolocation.TencentLocationListener";
import TencentLocation from "com.tencent.map.geolocation.TencentLocation";
import TencentLocationRequest from "com.tencent.map.geolocation.TencentLocationRequest";
import PackageManager from "android.content.pm.PackageManager";
import Class from 'java.lang.Class';
import Exception from 'java.lang.Exception';
import { GetLocation, GetLocationOptions, GetLocationSuccess,GetLocationFail } from "../interface.uts"
export const getLocation : GetLocation = function (options : GetLocationOptions) {
if(!checkHasIntegration()){
// 当前没有集成腾讯sdk,提示需要打包
let ret : GetLocationFail = {
errCode: -10,
errMsg: "需要打自定义基座",
errSubject: "uni-getLocation-tencent"
}
options.fail?.(ret)
options.complete?.(ret)
return;
}
if (!checkLocationConfig()) {
let ret : GetLocationFail = {
errCode: -20,
errMsg: "未通过配置预校验,通常是app key 配置错误",
errSubject: "uni-getLocation-tencent"
}
options.fail?.(ret)
options.complete?.(ret)
return;
}
/**
* 准备权限
*/
let permissionNeed : string[] = utsArrayOf("android.permission.ACCESS_FINE_LOCATION");
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight:boolean,_grantedList:string[]) {
if (allRight) {
// 交给目前的location 引擎,真实执行
getLocationImpl(options)
}
}, function (_doNotAskAgain:boolean,_grantedList:string[]) {
console.log("用户拒绝了部分权限:")
let ret : GetLocationFail = {
errCode: -30,
errMsg: "permission missed.",
errSubject: "uni-getLocation-tencent"
}
options.fail?.(ret)
options.complete?.(ret)
})
}
/****************************************内部功能实现****************************************************/
/**
* 定位监听结果包装类
*/
class LocationOptionsWapper {
hostOption : GetLocationOptions;
constructor(option : GetLocationOptions) {
this.hostOption = option
}
onLocationChanged(location : TencentLocation, _error : Int,
_reason : string) {
let ret : GetLocationSuccess = {
latitude: location.latitude,
longitude: location.longitude,
speed: 0,
accuracy: location.accuracy,
altitude: location.altitude,
verticalAccuracy: 0,
horizontalAccuracy: location.accuracy,
address: location.address
}
this.hostOption.success?.(ret)
// 包装数据结构返回
}
onStatusUpdate(_name : string, _status : Int, _desc : string) {
// 定位状态发生变化
}
};
/**
* Tencent 定位监听实现类
*/
class SingleLocationListener extends TencentLocationListener {
hostOptionWraper : LocationOptionsWapper;
constructor(option : LocationOptionsWapper) {
super();
this.hostOptionWraper = option
}
override onLocationChanged(location : TencentLocation, error : Int,
reason : string) : void {
this.hostOptionWraper.onLocationChanged(location, error, reason);
}
override onStatusUpdate(name : string, status : Int, desc : string) : void {
this.hostOptionWraper.onStatusUpdate(name, status, desc);
}
}
/**
* 判断当前的基座是否已经集成了sdk, 即是否是自定义基座
*/
function checkHasIntegration() : boolean {
let hasIntegration = true
try {
let xClass = Class.forName("com.tencent.map.geolocation.TencentLocationListener")
} catch (e : Exception) {
hasIntegration = false;
}
if (!hasIntegration) {
return false;
}
return true
}
/**
* 检查定位的相关配置是否正确
*/
function checkLocationConfig() : boolean {
let packageName = UTSAndroid.getAppContext()!.getPackageName();
let appInfo = UTSAndroid.getAppContext()!.getPackageManager()!.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
let metaData = appInfo.metaData
if (metaData == null) {
return false;
}
let adId = metaData.getString("TencentMapSDK")
if (adId == null) {
return false;
}
let splitArray = adId!.split("-")
let keyCharNum = splitArray.size
if (keyCharNum > 5) {
// 存在超过5个-,说明是符合规则的appkey
return true;
}
// 不符合校验规则,打回
return false;
}
/**
* 腾讯地图获取定位信息
* 参考文档:https://lbs.qq.com/mobile/androidLocationSDK/androidGeoGuide/androidGeoAdapt
*/
function getLocationImpl(locationOptions : GetLocationOptions) {
if(locationOptions.type != null && locationOptions.type!.toUpperCase() != 'GCJ-02' && locationOptions.type!.toUpperCase() != 'GCJ02'){
// 腾讯定位只支持GCJ-02,如果不是则报错
let ret : GetLocationFail = {
errCode: -1,
errMsg: "GCJ-02 support only.",
errSubject: "uni-getLocation-tencent"
}
locationOptions.fail?.(ret)
locationOptions.complete?.(ret)
return
}
let mLocationManager = TencentLocationManager.getInstance(UTSAndroid.getAppContext());
// 定位监听器封装
let locationOptionWrapper = new LocationOptionsWapper(locationOptions);
let mLocationListener = new SingleLocationListener(locationOptionWrapper);
// 发起单次请求
let locationRequest = TencentLocationRequest.create()
// 是否需要逆地理编码
if (locationOptions.geocode != null && locationOptions.geocode == true) {
locationRequest.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_NAME);
} else {
locationRequest.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_GEO);
}
// 是否开启了高精度
if (locationOptions.isHighAccuracy != null && locationOptions.isHighAccuracy == true) {
locationRequest.setAllowGPS(true)
}
/**
* 高度信息,腾讯没有明确的api设置
*/
if (locationOptions.altitude != null && locationOptions.altitude == true) {
locationRequest.setAllowGPS(true)
}
mLocationManager.requestSingleFreshLocation(locationRequest, mLocationListener, Looper.getMainLooper());
}
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
0 → 100644
浏览文件 @
ad61ae01
export interface Uni {
/**
* 获取当前的地理位置、速度
*
* @tutorial http://uniapp.dcloud.io/api/location/location?id=getlocation
*/
getLocation: GetLocation;
}
export type GetLocation = (options: GetLocationOptions) => void;
export type GetLocationSuccess = {
/**
* 纬度,浮点数,范围为-90~90,负数表示南纬
*/
latitude: number,
/**
* 经度,范围为-180~180,负数表示西经
*/
longitude: number,
/**
* 速度,浮点数,单位m/s
*/
speed: number,
/**
* 位置的精确度
*/
accuracy: number,
/**
* 高度,单位 m
*/
altitude: number,
/**
* 垂直精度,单位 m(Android 无法获取,返回 0)
*/
verticalAccuracy: number,
/**
* 水平精度,单位 m
*/
horizontalAccuracy: number,
/**
* 地址信息
*/
address: any | null
};
type GetLocationSuccessCallback = (result: GetLocationSuccess) => void;
export type GetLocationFail = UniError;
type UniError = {
errSubject: string,
errCode: number,
errMsg: string,
data: object | null,
cause: any | null
};
type GetLocationFailCallback = (result: GetLocationFail) => void;
type GetLocationComplete = any;
type GetLocationCompleteCallback = (result: GetLocationComplete) => void;
export type GetLocationOptions = {
/**
* 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于uni.openLocation的坐标
*/
type?: string | null,
/**
* 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度
* @type boolean
*/
altitude?: boolean | null,
/**
* 传入 true 会解析地址
* @type boolean
*/
geocode?: boolean | null,
/**
* 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果
*/
highAccuracyExpireTime?: number | null,
/**
* 开启高精度定位
* @type boolean
*/
isHighAccuracy?: boolean | null,
/**
* 接口调用成功的回调函数
*/
success?: GetLocationSuccessCallback | null,
/**
* 接口调用失败的回调函数
*/
fail?: GetLocationFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
*/
complete?: GetLocationCompleteCallback | null
};
uni_modules/uni-getbatteryinfo/package.json
浏览文件 @
ad61ae01
...
...
@@ -32,7 +32,12 @@
},
"uni_modules"
:
{
"uni-ext-api"
:
{
"uni"
:
[
"getBatteryInfo"
]
"uni"
:
{
"getBatteryInfo"
:
"getBatteryInfo"
,
"getBatteryInfoSync"
:
{
"web"
:
false
}
}
},
"dependencies"
:
[],
"encrypt"
:
[],
...
...
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
浏览文件 @
ad61ae01
...
...
@@ -2,8 +2,11 @@ import Context from "android.content.Context";
import BatteryManager from "android.os.BatteryManager";
import { UTSAndroid } from "io.dcloud.uts";
import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoFail, GetBatteryInfoOptions } from '../interface.uts'
import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoFail, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts'
/**
* 异步获取电量
* @param {Object} options
*/
export const getBatteryInfo : GetBatteryInfo = function (options) {
const context = UTSAndroid.getAppContext();
if (context != null) {
...
...
@@ -31,3 +34,36 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
options.complete?.(res)
}
}
/**
* 同步获取电量示例
*/
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
const context = UTSAndroid.getAppContext();
if (context != null) {
const manager = context.getSystemService(
Context.BATTERY_SERVICE
) as BatteryManager;
const level = manager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CAPACITY
);
const res : GetBatteryInfoResult = {
level: level,
isCharging: manager.isCharging()
};
return res;
} else {
/**
* 无有效上下文
*/
const res : GetBatteryInfoResult = {
level: -1,
isCharging: false
};
return res;
}
}
\ No newline at end of file
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
浏览文件 @
ad61ae01
...
...
@@ -2,7 +2,7 @@
import { UIDevice } from "UIKit";
import { Int } from 'Swift';
import { GetBatteryInfo, GetBatteryInfoSuccess } from '../interface.uts';
import { GetBatteryInfo, GetBatteryInfoSuccess
, GetBatteryInfoResult, GetBatteryInfoSync
} from '../interface.uts';
/**
* 导出 获取电量方法
...
...
@@ -21,3 +21,16 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
options.success?.(res);
options.complete?.(res);
}
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
// 开启电量检测
UIDevice.current.isBatteryMonitoringEnabled = true
// 返回数据
const res : GetBatteryInfoResult = {
level: Number(UIDevice.current.batteryLevel * 100),
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
};
return res;
}
\ No newline at end of file
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
浏览文件 @
ad61ae01
...
...
@@ -46,6 +46,17 @@ export type GetBatteryInfoOptions = {
complete ?: (res : any) => void
}
export type GetBatteryInfoResult = {
/**
* 设备电量,范围1 - 100
*/
level : number,
/**
* 是否正在充电中
*/
isCharging : boolean
}
/**
* 获取电量信息
* @param {GetBatteryInfoOptions} options
...
...
@@ -59,3 +70,70 @@ export type GetBatteryInfoOptions = {
* @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" })
*/
export type GetBatteryInfo = (options : GetBatteryInfoOptions) => void
export type GetBatteryInfoSync = () => GetBatteryInfoResult
interface Uni {
/**
* 获取电池电量信息
* @description 获取电池电量信息
* @param {GetBatteryInfoOptions} options
* @example
* ```typescript
* uni.getBatteryInfo({
* success(res) {
* console.log(res);
* }
* })
* ```
* @remark
* - 该接口需要同步调用
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.6.11",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.6.11",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVueVersion 2,3 //支持的vue版本
*
*/
getBatteryInfo : GetBatteryInfo,
/**
* 同步获取电池电量信息
* @description 获取电池电量信息
* @example
* ```typescript
* uni.getBatteryInfo()
* ```
* @remark
* - 该接口需要同步调用
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.6.11",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.6.11",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVueVersion 2,3 //支持的vue版本
*
*/
getBatteryInfoSync: GetBatteryInfoSync
}
\ No newline at end of file
uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js
浏览文件 @
ad61ae01
export
function
getBatteryInfo
(
options
)
{
return
my
.
getBatteryInfo
(
options
)
}
export
function
getBatteryInfoSync
(
options
)
{
return
my
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js
浏览文件 @
ad61ae01
export
function
getBatteryInfo
(
options
)
{
return
swan
.
getBatteryInfo
(
options
)
}
export
function
getBatteryInfoSync
(
options
)
{
return
swan
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js
浏览文件 @
ad61ae01
export
function
getBatteryInfo
(
options
)
{
return
qq
.
getBatteryInfo
(
options
)
}
export
function
getBatteryInfoSync
(
options
)
{
return
qq
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js
浏览文件 @
ad61ae01
export
function
getBatteryInfo
(
options
)
{
return
wx
.
getBatteryInfo
(
options
)
}
export
function
getBatteryInfoSync
(
options
)
{
return
wx
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-memorywarning/package.json
浏览文件 @
ad61ae01
...
...
@@ -5,7 +5,7 @@
"description"
:
"UTS 实现内存警告监听"
,
"keywords"
:
[
"onMemoryWarning"
],
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.11"
...
...
@@ -31,17 +31,15 @@
"npmurl"
:
""
},
"uni_modules"
:
{
"uni-ext-api"
:
{
"uni-ext-api"
:
{
"uni"
:
{
"onMemoryWarning"
:
"onMemoryWarning"
,
"offMemoryWarning"
:
"offMemoryWarning"
"onMemoryWarning"
:
{
"web"
:
false
},
"mp-weixin"
:
false
,
"mp-alipay"
:
false
,
"mp-baidu"
:
false
,
"mp-qq"
:
false
,
"mp-kuaishou"
:
false
,
"mp-jd"
:
false
"offMemoryWarning"
:
{
"web"
:
false
}
}
},
"dependencies"
:
[],
"encrypt"
:
[],
...
...
uni_modules/uni-memorywarning/utssdk/app-android/index.uts
浏览文件 @
ad61ae01
import { UTSAndroid } from "io.dcloud.uts"
import { OnMemoryWarning, OffMemoryWarning } from "../interface.uts"
let listeners: UTSCallback[] = []
...
...
@@ -14,7 +14,7 @@ const onAppTrimMemoryListener = (ret: number) => {
@Suppress("DEPRECATION")
export
function onMemoryWarning
(callback: UTSCallback) {
export
const onMemoryWarning : OnMemoryWarning = function
(callback: UTSCallback) {
if (listeners.length == 0) {
// 仅首次执行底层的实际监听
UTSAndroid.onAppTrimMemory(onAppTrimMemoryListener)
...
...
@@ -28,7 +28,7 @@ export function onMemoryWarning(callback: UTSCallback) {
@Suppress("DEPRECATION")
export
function offMemoryWarning
(callback: UTSCallback | null) {
export
const offMemoryWarning : OffMemoryWarning = function
(callback: UTSCallback | null) {
if(callback == null){
// 清除全部回调
...
...
uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
浏览文件 @
ad61ae01
import { NotificationCenter } from 'Foundation';
import { UIApplication } from "UIKit"
import { Selector } from "ObjectiveC"
import { OnMemoryWarning, OffMemoryWarning } from "../interface.uts"
class MemoryWarningTool {
static listeners: UTSCallback[] = []
...
...
@@ -45,12 +46,13 @@ class MemoryWarningTool {
}
}
// 开启监听内存警告
export
function onMemoryWarning
(callback: UTSCallback) {
export
const onMemoryWarning : OnMemoryWarning = function
(callback: UTSCallback) {
MemoryWarningTool.listenMemoryWarning(callback)
}
// 关闭监听内存警告
export
function offMemoryWarning
(callback: UTSCallback | null) {
export
const offMemoryWarning : OffMemoryWarning = function
(callback: UTSCallback | null) {
MemoryWarningTool.removeListen(callback)
}
\ No newline at end of file
uni_modules/uni-memorywarning/utssdk/interface.uts
0 → 100644
浏览文件 @
ad61ae01
export type OnMemoryWarning = (callback: UTSCallback) => void
export type OffMemoryWarning = (callback : UTSCallback | null) => void
export interface Uni {
/**
* 开启监听内存警告
*
* @param {UTSCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/memory.html#onmemorywarning
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
onMemoryWarning : OnMemoryWarning,
/**
* 取消监听内存不足告警事件
*
* @param {UTSCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/memory.html#offmemorywarning
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
offMemoryWarning : OffMemoryWarning
}
\ No newline at end of file
uni_modules/uni-usercapturescreen/package.json
浏览文件 @
ad61ae01
...
...
@@ -33,9 +33,16 @@
"uni_modules"
:
{
"uni-ext-api"
:{
"uni"
:
{
"onUserCaptureScreen"
:
"onUserCaptureScreen"
,
"offUserCaptureScreen"
:
"offUserCaptureScreen"
,
"setUserCaptureScreen"
:
"setUserCaptureScreen"
"onUserCaptureScreen"
:
{
"web"
:
false
},
"offUserCaptureScreen"
:
{
"web"
:
false
},
"setUserCaptureScreen"
:
{
"web"
:
false
,
"mp-weixin"
:
false
}
}
},
"dependencies"
:
[],
...
...
uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
浏览文件 @
ad61ae01
...
...
@@ -9,6 +9,7 @@ import Environment from "android.os.Environment";
import System from 'java.lang.System';
import WindowManager from 'android.view.WindowManager';
import { OnUserCaptureScreenCallbackResult, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreenSuccess, SetUserCaptureScreenOptions, SetUserCaptureScreen } from "../interface.uts";
import string from 'android.R.string';
/**
...
...
@@ -34,9 +35,9 @@ class ScreenFileObserver extends FileObserver {
*/
private screenFile : File;
constructor(screenFile
: File
) {
super(screenFile);
this.screenFile =
screenFile
;
constructor(screenFile
Str : string
) {
super(screenFile
Str
);
this.screenFile =
new File(screenFileStr)
;
}
override onEvent(event : Int, path : string | null) : void {
...
...
@@ -83,7 +84,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
}
// 先结束监听 再开启监听
observer?.stopWatching();
observer = new ScreenFileObserver(directory_screenshot);
observer = new ScreenFileObserver(directory_screenshot
.getPath()
);
observer?.startWatching();
...
...
@@ -92,7 +93,6 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
observer = null
})
}
/**
...
...
uni_modules/uni-usercapturescreen/utssdk/interface.uts
浏览文件 @
ad61ae01
...
...
@@ -13,26 +13,8 @@ export type OnUserCaptureScreenCallbackResult = {
*/
export type UserCaptureScreenCallback = (res : OnUserCaptureScreenCallbackResult) => void
/**
* uni.onUserCaptureScreen函数定义
* 开启截屏监听
*
* @param {UserCaptureScreenCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen
* @platforms APP-IOS = ^9.0,APP-ANDROID = ^4.4
* @since 3.7.7
*/
export type OnUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void
/**
* uni.offUserCaptureScreen函数定义
* 关闭截屏监听
*
* @param {UserCaptureScreenCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen
* @platforms APP-IOS = ^9.0,APP-ANDROID = ^4.4
* @since 3.7.7
*/
export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void
/**
...
...
@@ -102,21 +84,78 @@ export type SetUserCaptureScreenOptions = {
complete ?: SetUserCaptureScreenCompleteCallback
}
export type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void
/**
* * uni.setUserCaptureScreen函数定义
export interface Uni {
/**
* 开启截屏监听
*
* @param {UserCaptureScreenCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
onUserCaptureScreen : OnUserCaptureScreen,
/**
* 关闭截屏监听
*
* @param {UserCaptureScreenCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
offUserCaptureScreen : OffUserCaptureScreen,
/**
* 设置防截屏
*
* @param {SetUserCaptureScreenOptions} options
* @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen
* @platforms APP-IOS = ^13.0,APP-ANDROID = ^4.4
* @since 3.7.7
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "13.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
*/
export type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void
export interface Uni {
onUserCaptureScreen : OnUserCaptureScreen,
offUserCaptureScreen : OffUserCaptureScreen,
setUserCaptureScreen : SetUserCaptureScreen
}
\ No newline at end of file
uni_modules/uni-wifi/package.json
浏览文件 @
ad61ae01
...
...
@@ -5,7 +5,7 @@
"description"
:
"wifi管理"
,
"keywords"
:
[
"wifi"
],
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.11"
...
...
@@ -31,19 +31,41 @@
"npmurl"
:
""
},
"uni_modules"
:
{
"uni-ext-api"
:
{
"uni-ext-api"
:
{
"uni"
:
{
"startWifi"
:
"startWifi"
,
"stopWifi"
:
"stopWifi"
,
"connectWifi"
:
"connectWifi"
,
"getConnectedWifi"
:
"getConnectedWifi"
,
"getWifiList"
:
"getWifiList"
,
"onGetWifiList"
:
"onGetWifiList"
,
"offGetWifiList"
:
"offGetWifiList"
,
"onWifiConnected"
:
"onWifiConnected"
,
"offWifiConnected"
:
"offWifiConnected"
,
"onWifiConnectedWithPartialInfo"
:
"onWifiConnectedWithPartialInfo"
,
"offWifiConnectedWithPartialInfo"
:
"offWifiConnectedWithPartialInfo"
"startWifi"
:
{
"web"
:
false
},
"stopWifi"
:
{
"web"
:
false
},
"connectWifi"
:
{
"web"
:
false
},
"getConnectedWifi"
:
{
"web"
:
false
},
"getWifiList"
:
{
"web"
:
false
},
"onGetWifiList"
:
{
"web"
:
false
},
"offGetWifiList"
:
{
"web"
:
false
},
"onWifiConnected"
:
{
"web"
:
false
},
"offWifiConnected"
:
{
"web"
:
false
},
"onWifiConnectedWithPartialInfo"
:
{
"web"
:
false
},
"offWifiConnectedWithPartialInfo"
:
{
"web"
:
false
}
}
},
"dependencies"
:
[],
...
...
uni_modules/uni-wifi/utssdk/app-android/index.uts
浏览文件 @
ad61ae01
...
...
@@ -378,7 +378,7 @@ export function startWifi(option : WifiOption) {
// 检查权限
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, permissionWifi, requestCode)
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, permissionWifi, requestCode
.toInt()
)
// 尚不具备权限,返回错误
option.fail?.(result)
option.complete?.(result)
...
...
uni_modules/uni-wifi/utssdk/app-ios/config.json
浏览文件 @
ad61ae01
{
"frameworks"
:
[
"CoreLocation
"
,
"SystemConfiguration
"
"CoreLocation
.framework"
,
"SystemConfiguration
.framework"
],
"validArchitectures"
:
[
"arm64"
,
"armv7"
]
"arm64"
,
"armv7"
]
}
\ No newline at end of file
uni_modules/uni-wifi/utssdk/interface.uts
浏览文件 @
ad61ae01
/**
* Wifi 函数通用入参封装
*/
export type WifiOption = {
success
?: (res
: UniWifiResult) => void;
fail
?: (res
: UniWifiResult) => void;
complete
?: (res
: UniWifiResult) => void;
export type WifiOption = {
success
?: (res
: UniWifiResult) => void;
fail
?: (res
: UniWifiResult) => void;
complete
?: (res
: UniWifiResult) => void;
};
/**
* Wifi 链接参数封装
*/
export type WifiConnectOption = {
SSID?: string;
BSSID?: string;
password?: string;
maunal?: boolean;
partialInfo?: boolean; //ios不生效
success
?: (res
: UniWifiResult) => void;
fail
?: (res
: UniWifiResult) => void;
complete
?: (res
: UniWifiResult) => void;
SSID
?: string;
BSSID
?: string;
password
?: string;
maunal
?: boolean;
partialInfo
?: boolean; //ios不生效
success
?: (res
: UniWifiResult) => void;
fail
?: (res
: UniWifiResult) => void;
complete
?: (res
: UniWifiResult) => void;
}
/**
* 获取当前链接的wifi信息
*/
export type GetConnectedWifiOptions = {
partialInfo?: boolean
success
?: (res
: UniWifiResult) => void
fail
?: (res
: UniWifiResult) => void
complete
?: (res
: UniWifiResult) => void
partialInfo
?: boolean
success
?: (res
: UniWifiResult) => void
fail
?: (res
: UniWifiResult) => void
complete
?: (res
: UniWifiResult) => void
}
/*
* 对外暴露的wifi信息
*/
export type UniWifiInfo = {
SSID: string;
BSSID?: string;
secure?: boolean;
signalStrength?: number;
frequency?: number;
SSID
: string;
BSSID
?: string;
secure
?: boolean;
signalStrength
?: number;
frequency
?: number;
}
...
...
@@ -47,40 +47,104 @@ export type UniWifiResult = {
errCode : number,
errSubject : string,
errMsg : string,
wifi: UniWifiInfo | null
wifi
: UniWifiInfo | null
}
export type UniWifiCallback = () => void
export type StartWifi = (option: WifiOption) => void
export type StartWifi = (option
: WifiOption) => void
export type StopWifi = (option: WifiOption) => void
export type StopWifi = (option
: WifiOption) => void
export type GetWifiList = (option: WifiOption) => void
export type GetWifiList = (option
: WifiOption) => void
export type OnGetWifiList = (callback: UniWifiCallback) => void
export type OnGetWifiList = (callback
: UniWifiCallback) => void
export type OffGetWifiList = (callback: UniWifiCallback) => void
export type OffGetWifiList = (callback
: UniWifiCallback) => void
export type GetConnectedWifi = (option: GetConnectedWifiOptions) => void
export type GetConnectedWifi = (option
: GetConnectedWifiOptions) => void
export type ConnectWifi = (option: WifiConnectOption) => void
export type ConnectWifi = (option
: WifiConnectOption) => void
export type OnWifiConnected = (callback: UniWifiCallback) => void
export type OnWifiConnected = (callback
: UniWifiCallback) => void
export type OnWifiConnectedWithPartialInfo = (callback: UniWifiCallback) => void
export type OnWifiConnectedWithPartialInfo = (callback
: UniWifiCallback) => void
export type OffWifiConnected = (callback: UniWifiCallback | null) => void
export type OffWifiConnected = (callback
: UniWifiCallback | null) => void
export type OnOffWifiConnectedWithPartialInfo = (callback: UniWifiCallback | null) => void
export type OnOffWifiConnectedWithPartialInfo = (callback
: UniWifiCallback | null) => void
export type SetWifiList = (option: WifiOption) => void
export type SetWifiList = (option
: WifiOption) => void
interface Uni {
/**
* 初始化Wi-Fi模块
*
* @param {WifiOption} option
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { after: 'stopWifi' }
*/
startWifi : StartWifi,
/**
* 关闭 Wi-Fi 模块
*
* @param {WifiOption} option
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { before: 'startWifi' }
*/
stopWifi : StopWifi,
/**
* @param {WifiConnectOption} option
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi
* @uniPlatform {
* "app": {
* "android": {
* "osVer": ">=4.4 && <10.0",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest {
generated: false,
pollution: false,
...
...
@@ -101,25 +165,231 @@ interface Uni {
]
}
*/
connectWifi: ConnectWifi,
connectWifi : ConnectWifi,
/**
* 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。
* @param {WifiOption} option
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getWifiList
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { before: 'startWifi', after: 'stopWifi' }
*/
getWifiList : GetWifiList,
/**
* 监听获取到 Wi-Fi 列表数据事件。
*
* @param {UniWifiCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onGetWifiList
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
* @autotest {
generated: false,
cases:[
{
pollution: false,
expectCallback: true,
before: 'startWifi',
after: 'stopWifi'
after: 'onGetWifiListAfter',
cases: [
{
output: {
value: 0,
returnKey: '.wifiList.length',
jestExpectSyntax: 'toBeGreaterThan'
},
}
]
}
*/
getWifiList : GetWifiList,
onGetWifiList : OnGetWifiList,
/**
* 移除获取到 Wi-Fi 列表数据事件的监听函数。
*
* @param {UniWifiCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offGetWifiList
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
offGetWifiList : OffGetWifiList,
/**
* 获取已连接的 Wi-Fi 信息
*
* @param {GetConnectedWifiOptions} option
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getConnectedWifi
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { before: 'startWifi', after: 'stopWifi' }
*/
getConnectedWifi : GetConnectedWifi,
/**
* 监听连接上 Wi-Fi 的事件
*
* @param {UniWifiCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnected
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
onWifiConnected : OnWifiConnected,
/**
* 监听连接上 Wi-Fi 的事件。
*
* @param {UniWifiCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnectedWithPartialInfo
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
onWifiConnectedWithPartialInfo : OnWifiConnectedWithPartialInfo,
/**
* 移除连接上 Wi-Fi 的事件的监听函数。
*
* @param {UniWifiCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnected
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.7.7",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
offWifiConnected : OffWifiConnected,
/**
* 移除连接上 Wi-Fi 的事件的监听函数。
*
* @param {UniWifiCallback} callback
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onOffWifiConnectedWithPartialInfo
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
onOffWifiConnectedWithPartialInfo : OnOffWifiConnectedWithPartialInfo,
/**
* SetWifiList 暂未实现
*
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
*/
setWifiList : SetWifiList,
}
\ No newline at end of file
uni_modules/uni-wifi/utssdk/uni.autotest.js
浏览文件 @
ad61ae01
function
startWifi
()
{
export
function
startWifi
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
startWifi
({
success
:
()
=>
{
console
.
log
(
'
startWifi success
'
);
resolve
()
},
fail
:
()
=>
{
complete
:
()
=>
{
console
.
log
(
'
startWifi fail
'
);
re
ject
()
re
solve
()
}
})
})
}
function
stopWifi
()
{
export
function
stopWifi
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
stopWifi
({
success
:
()
=>
{
console
.
log
(
'
stopWifi success
'
);
resolve
()
},
fail
:
()
=>
{
console
.
log
(
'
stopWifi success
'
);
fail
()
}
complete
:
resolve
})
})
}
module
.
exports
=
{
startWifi
,
stopWifi
export
function
onGetWifiListAfter
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
getWifiList
({
success
()
{
setTimeout
(
resolve
,
500
)
},
complete
()
{
stopWifi
().
finally
(
resolve
)
}
})
})
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录