Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
c4d182b7
U
uni-api
项目概览
DCloud
/
uni-api
通知
670
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看板
提交
c4d182b7
编写于
10月 18, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
差异文件
手动合并dev 到 alpha
上级
9852b3ce
c95a0c0e
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
496 addition
and
390 deletion
+496
-390
.gitignore
.gitignore
+3
-0
pages/index/index.vue
pages/index/index.vue
+33
-19
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
+1
-1
uni_modules/uni-getbatteryinfo/changelog.md
uni_modules/uni-getbatteryinfo/changelog.md
+7
-0
uni_modules/uni-getbatteryinfo/package.json
uni_modules/uni-getbatteryinfo/package.json
+8
-3
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
+46
-32
uni_modules/uni-getbatteryinfo/utssdk/app-ios/config.json
uni_modules/uni-getbatteryinfo/utssdk/app-ios/config.json
+3
-0
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
+4
-4
uni_modules/uni-getbatteryinfo/utssdk/index.d.ts
uni_modules/uni-getbatteryinfo/utssdk/index.d.ts
+5
-0
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
+25
-25
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-ios/index.uts
uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
+1
-0
uni_modules/uni-memorywarning/utssdk/interface.uts
uni_modules/uni-memorywarning/utssdk/interface.uts
+6
-4
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/app-ios/index.uts
uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts
+3
-11
uni_modules/uni-usercapturescreen/utssdk/interface.uts
uni_modules/uni-usercapturescreen/utssdk/interface.uts
+8
-25
uni_modules/uni-wifi/package.json
uni_modules/uni-wifi/package.json
+41
-19
uni_modules/uni-wifi/utssdk/app-android/config.json
uni_modules/uni-wifi/utssdk/app-android/config.json
+3
-0
uni_modules/uni-wifi/utssdk/app-android/index.uts
uni_modules/uni-wifi/utssdk/app-android/index.uts
+102
-103
uni_modules/uni-wifi/utssdk/app-ios/index.uts
uni_modules/uni-wifi/utssdk/app-ios/index.uts
+23
-57
uni_modules/uni-wifi/utssdk/interface.uts
uni_modules/uni-wifi/utssdk/interface.uts
+98
-63
uni_modules/uni-wifi/utssdk/uni.autotest.js
uni_modules/uni-wifi/utssdk/uni.autotest.js
+35
-0
未找到文件。
.gitignore
浏览文件 @
c4d182b7
...
@@ -2,7 +2,10 @@
...
@@ -2,7 +2,10 @@
/.hbuilderx
/.hbuilderx
/.vite
/.vite
.DS_Store
.DS_Store
<<<<<<< HEAD
=======
>>>>>>> dev
env.js
env.js
jest.config.js
jest.config.js
autotest.reporter.js
autotest.reporter.js
...
...
pages/index/index.vue
浏览文件 @
c4d182b7
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<button
@
tap=
"testGetBatteryInfoSync"
>
同步获取电池电量
</button>
<button
@
tap=
"testGetBatteryInfoSync"
>
同步获取电池电量
</button>
<button
@
tap=
"testonMemoryWarning"
>
开启内存不足告警监听
</button>
<button
@
tap=
"testonMemoryWarning"
>
开启内存不足告警监听
</button>
<button
@
tap=
"testoffMemoryWarning"
>
关闭内存不足告警监听
</button>
<button
@
tap=
"testoffMemoryWarning"
>
关闭内存不足告警监听
</button>
<button
@
tap=
"getLocationTest"
style=
"width: 100%;"
>
获取定位
</button>
</view>
</view>
</
template
>
</
template
>
...
@@ -32,7 +32,8 @@
...
@@ -32,7 +32,8 @@
memListener
:
null
,
memListener
:
null
,
setUserCaptureScreenFlag
:
false
,
setUserCaptureScreenFlag
:
false
,
setUserCaptureScreenText
:
'
禁止截屏
'
,
setUserCaptureScreenText
:
'
禁止截屏
'
,
permissionGranted
:
false
permissionGranted
:
false
,
id
:
0
}
}
},
},
onLoad
()
{
onLoad
()
{
...
@@ -45,24 +46,37 @@
...
@@ -45,24 +46,37 @@
fn
:
function
(
res
){
fn
:
function
(
res
){
console
.
log
(
res
)
console
.
log
(
res
)
},
},
getLocationTest
()
{
console
.
log
(
"
------- getLocationTest:
"
);
uni
.
getLocation
({
type
:
'
gcj02
'
,
success
(
res
)
{
console
.
log
(
"
success
"
,
res
);
},
fail
(
res
)
{
console
.
log
(
"
fail
"
,
res
);
}
})
},
onGetWifiList2_assert0
()
{
onGetWifiList2_assert0
()
{
const
fn
=
res
=>
console
.
log
(
'
onGetWifiList res
'
,
res
)
console
.
log
(
"
------- onGetWifiList2_assert0:
"
,
this
.
id
);
uni
.
startWifi
({
success
(){
const
fn
=
res
=>
console
.
log
(
'
onGetWifiList res
'
,
res
)
uni
.
onGetWifiList
(
fn
)
uni
.
startWifi
({
success
(){
uni
.
getWifiList
({
uni
.
onGetWifiList
(
fn
)
success
()
{
uni
.
getWifiList
({
console
.
log
(
'
getWifiList success
'
);
success
()
{
uni
.
offGetWifiList
(
fn
)
console
.
log
(
'
getWifiList success
'
);
uni
.
stopWifi
({
uni
.
offGetWifiList
(
fn
)
success
()
{},
uni
.
stopWifi
({
fail
(
e
)
{
success
()
{},
console
.
log
(
"
stopWifi fail:
"
,
e
);
fail
(
e
)
{
}
console
.
log
(
"
stopWifi fail:
"
,
e
);
})
}
}
})
})
}
}})
})
},
}})
this
.
id
++
},
testConnnectWifi
(){
testConnnectWifi
(){
...
...
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
浏览文件 @
c4d182b7
...
@@ -4,7 +4,7 @@ export interface Uni {
...
@@ -4,7 +4,7 @@ export interface Uni {
*
*
* @tutorial http://uniapp.dcloud.io/api/location/location?id=getlocation
* @tutorial http://uniapp.dcloud.io/api/location/location?id=getlocation
*/
*/
getLocation
: GetLocation
;
getLocation
(options: GetLocationOptions) : void
;
}
}
export type GetLocation = (options: GetLocationOptions) => void;
export type GetLocation = (options: GetLocationOptions) => void;
...
...
uni_modules/uni-getbatteryinfo/changelog.md
浏览文件 @
c4d182b7
## 1.3.1(2023-09-15)
app端适配使用UniError
## 1.3.0(2023-05-30)
新增 同步获取电量api
## 1.2.0(2022-10-17)
## 1.2.0(2022-10-17)
实现百度小程序/支付宝小程序/QQ小程序获取电量
实现百度小程序/支付宝小程序/QQ小程序获取电量
## 1.1.0(2022-10-17)
## 1.1.0(2022-10-17)
实现ios平台获取电量
实现ios平台获取电量
...
...
uni_modules/uni-getbatteryinfo/package.json
浏览文件 @
c4d182b7
{
{
"id"
:
"uni-getbatteryinfo"
,
"id"
:
"uni-getbatteryinfo"
,
"displayName"
:
"uni-getbatteryinfo"
,
"displayName"
:
"uni-getbatteryinfo"
,
"version"
:
"1.
2.0
"
,
"version"
:
"1.
3.1
"
,
"description"
:
"使用uts开发,实现在多个平台获取电池电量功能"
,
"description"
:
"使用uts开发,实现在多个平台获取电池电量功能"
,
"keywords"
:
[
"keywords"
:
[
"battery"
"battery"
],
],
"repository"
:
""
,
"repository"
:
""
,
"engines"
:
{
"engines"
:
{
"HBuilderX"
:
"^3.
6
.0"
"HBuilderX"
:
"^3.
9
.0"
},
},
"dcloudext"
:
{
"dcloudext"
:
{
"type"
:
"uts"
,
"type"
:
"uts"
,
...
@@ -32,7 +32,12 @@
...
@@ -32,7 +32,12 @@
},
},
"uni_modules"
:
{
"uni_modules"
:
{
"uni-ext-api"
:
{
"uni-ext-api"
:
{
"uni"
:
[
"getBatteryInfo"
,
"getBatteryInfoSync"
]
"uni"
:
{
"getBatteryInfo"
:
"getBatteryInfo"
,
"getBatteryInfoSync"
:
{
"web"
:
false
}
}
},
},
"dependencies"
:
[],
"dependencies"
:
[],
"encrypt"
:
[],
"encrypt"
:
[],
...
...
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
浏览文件 @
c4d182b7
import Context from "android.content.Context";
import Context from "android.content.Context";
import BatteryManager from "android.os.BatteryManager";
import BatteryManager from "android.os.BatteryManager";
import { UTSAndroid } from "io.dcloud.uts";
import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoFail, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts'
import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts'
import IntentFilter from 'android.content.IntentFilter';
import Intent from 'android.content.Intent';
/**
/**
* 异步获取电量
* 异步获取电量
* @param {Object} options
*/
*/
export const getBatteryInfo : GetBatteryInfo = function (options) {
export const getBatteryInfo : GetBatteryInfo = function (options : GetBatteryInfoOptions) {
const context = UTSAndroid.getAppContext();
const context = UTSAndroid.getAppContext();
if (context != null) {
if (context != null) {
const manager = context.getSystemService(
const manager = context.getSystemService(
...
@@ -15,21 +19,22 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
...
@@ -15,21 +19,22 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
) as BatteryManager;
) as BatteryManager;
const level = manager.getIntProperty(
const level = manager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CAPACITY
BatteryManager.BATTERY_PROPERTY_CAPACITY
);
);
let ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
let batteryStatus = context.registerReceiver(null, ifilter);
let status = batteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
let isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
const res : GetBatteryInfoSuccess = {
const res : GetBatteryInfoSuccess = {
errMsg: 'getBatteryInfo:ok',
errMsg: 'getBatteryInfo:ok',
level,
level,
isCharging:
manager.isCharging()
isCharging:
isCharging
}
}
options.success?.(res)
options.success?.(res)
options.complete?.(res)
options.complete?.(res)
} else {
} else {
const res : GetBatteryInfoFail = {
const res = new UniError("uni-getBatteryInfo", 1001, "getBatteryInfo:fail getAppContext is null")
errSubject: "uni-getBatteryInfo",
errCode: 1001,
errMsg: 'getBatteryInfo:fail getAppContext is null',
cause: null
}
options.fail?.(res)
options.fail?.(res)
options.complete?.(res)
options.complete?.(res)
}
}
...
@@ -39,31 +44,40 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
...
@@ -39,31 +44,40 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
* 同步获取电量示例
* 同步获取电量示例
*/
*/
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
const context = UTSAndroid.getAppContext();
const context = UTSAndroid.getAppContext();
if (context != null) {
if (context != null) {
const manager = context.getSystemService(
const manager = context.getSystemService(
Context.BATTERY_SERVICE
Context.BATTERY_SERVICE
) as BatteryManager;
) as BatteryManager;
const level = manager.getIntProperty(
const level = manager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CAPACITY
BatteryManager.BATTERY_PROPERTY_CAPACITY
);
);
const res : GetBatteryInfoResult = {
let ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
level: level,
let batteryStatus = context.registerReceiver(null, ifilter);
isCharging: manager.isCharging()
let status = batteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
};
let isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
return res;
} else {
const res : GetBatteryInfoResult = {
/**
level: level,
* 无有效上下文
isCharging: isCharging
*/
};
const res : GetBatteryInfoResult = {
level: -1,
return res;
isCharging: false
}
};
else {
return res;
/**
* 无有效上下文
*/
const res : GetBatteryInfoResult = {
level: -1,
isCharging: false
};
return res;
}
}
}
}
\ No newline at end of file
uni_modules/uni-getbatteryinfo/utssdk/app-ios/config.json
0 → 100644
浏览文件 @
c4d182b7
{
"deploymentTarget"
:
"9"
}
\ No newline at end of file
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
浏览文件 @
c4d182b7
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import { UIDevice } from "UIKit";
import { UIDevice } from "UIKit";
import { Int } from 'Swift';
import { Int } from 'Swift';
import { GetBatteryInfo, GetBatteryInfoSuccess } from '../interface.uts';
import { GetBatteryInfo, GetBatteryInfoSuccess
, GetBatteryInfoResult, GetBatteryInfoSync
} from '../interface.uts';
/**
/**
* 导出 获取电量方法
* 导出 获取电量方法
...
@@ -20,8 +20,8 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
...
@@ -20,8 +20,8 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
};
};
options.success?.(res);
options.success?.(res);
options.complete?.(res);
options.complete?.(res);
}
}
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
// 开启电量检测
// 开启电量检测
...
@@ -33,4 +33,4 @@ export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryIn
...
@@ -33,4 +33,4 @@ export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryIn
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
};
};
return res;
return res;
}
}
\ No newline at end of file
uni_modules/uni-getbatteryinfo/index.d.ts
→
uni_modules/uni-getbatteryinfo/
utssdk/
index.d.ts
浏览文件 @
c4d182b7
...
@@ -34,4 +34,9 @@ declare interface Uni {
...
@@ -34,4 +34,9 @@ declare interface Uni {
* 文档: [https://uniapp.dcloud.net.cn/api/system/batteryInfo.html](https://uniapp.dcloud.net.cn/api/system/batteryInfo.html)
* 文档: [https://uniapp.dcloud.net.cn/api/system/batteryInfo.html](https://uniapp.dcloud.net.cn/api/system/batteryInfo.html)
*/
*/
getBatteryInfo
(
option
?:
UniNamespace
.
GetBatteryInfoOption
):
void
;
getBatteryInfo
(
option
?:
UniNamespace
.
GetBatteryInfoOption
):
void
;
/**
* 同步获取电池电量信息
*/
getBatteryInfoSync
():
UniNamespace
.
GetBatteryInfoSuccessCallbackResult
;
}
}
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
浏览文件 @
c4d182b7
...
@@ -10,24 +10,24 @@ export type GetBatteryInfoSuccess = {
...
@@ -10,24 +10,24 @@ export type GetBatteryInfoSuccess = {
isCharging : boolean
isCharging : boolean
}
}
export type GetBatteryInfoFail = {
//
export type GetBatteryInfoFail = {
/**
//
/**
* 错误码
//
* 错误码
*/
//
*/
errCode : number,
//
errCode : number,
/**
//
/**
* 调用API的名称
//
* 调用API的名称
*/
//
*/
errSubject : string,
//
errSubject : string,
/**
//
/**
* 错误的详细信息
//
* 错误的详细信息
*/
//
*/
errMsg : string,
//
errMsg : string,
/**
//
/**
* 错误来源
//
* 错误来源
*/
//
*/
cause : any | null
//
cause : any | null
}
//
}
...
@@ -39,7 +39,7 @@ export type GetBatteryInfoOptions = {
...
@@ -39,7 +39,7 @@ export type GetBatteryInfoOptions = {
/**
/**
* 接口调用失败的回调函数
* 接口调用失败的回调函数
*/
*/
fail ?: (res :
GetBatteryInfoFail
) => void
fail ?: (res :
UniError
) => void
/**
/**
* 接口调用成功的回调
* 接口调用成功的回调
*/
*/
...
@@ -60,12 +60,12 @@ export type GetBatteryInfoResult = {
...
@@ -60,12 +60,12 @@ export type GetBatteryInfoResult = {
/**
/**
* 获取电量信息
* 获取电量信息
* @param {GetBatteryInfoOptions} options
* @param {GetBatteryInfoOptions} options
*
*
*
*
* @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html
* @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html
* @platforms APP-IOS = ^9.0,APP-ANDROID = ^22
* @platforms APP-IOS = ^9.0,APP-ANDROID = ^22
* @since 3.6.11
* @since 3.6.11
*
*
* @assert () => success({errCode: 0, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:ok", level: 60, isCharging: false })
* @assert () => success({errCode: 0, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:ok", level: 60, isCharging: false })
* @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" })
* @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" })
*/
*/
...
@@ -79,7 +79,7 @@ interface Uni {
...
@@ -79,7 +79,7 @@ interface Uni {
/**
/**
* 获取电池电量信息
* 获取电池电量信息
* @description 获取电池电量信息
* @description 获取电池电量信息
* @param {GetBatteryInfoOptions} options
* @param {GetBatteryInfoOptions} options
* @example
* @example
* ```typescript
* ```typescript
* uni.getBatteryInfo({
* uni.getBatteryInfo({
...
@@ -107,7 +107,7 @@ interface Uni {
...
@@ -107,7 +107,7 @@ interface Uni {
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
*
*
*/
*/
getBatteryInfo
: GetBatteryInfo
,
getBatteryInfo
(options : GetBatteryInfoOptions) : void
,
/**
/**
* 同步获取电池电量信息
* 同步获取电池电量信息
* @description 获取电池电量信息
* @description 获取电池电量信息
...
@@ -134,6 +134,6 @@ interface Uni {
...
@@ -134,6 +134,6 @@ interface Uni {
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
*
*
*/
*/
getBatteryInfoSync
: GetBatteryInfoSync
getBatteryInfoSync
():GetBatteryInfoResult
}
}
\ No newline at end of file
uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js
浏览文件 @
c4d182b7
export
function
getBatteryInfo
(
options
)
{
export
function
getBatteryInfo
(
options
)
{
return
my
.
getBatteryInfo
(
options
)
return
my
.
getBatteryInfo
(
options
)
}
}
export
function
getBatteryInfoSync
(
options
)
{
return
my
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js
浏览文件 @
c4d182b7
export
function
getBatteryInfo
(
options
)
{
export
function
getBatteryInfo
(
options
)
{
return
swan
.
getBatteryInfo
(
options
)
return
swan
.
getBatteryInfo
(
options
)
}
}
export
function
getBatteryInfoSync
(
options
)
{
return
swan
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js
浏览文件 @
c4d182b7
export
function
getBatteryInfo
(
options
)
{
export
function
getBatteryInfo
(
options
)
{
return
qq
.
getBatteryInfo
(
options
)
return
qq
.
getBatteryInfo
(
options
)
}
}
export
function
getBatteryInfoSync
(
options
)
{
return
qq
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js
浏览文件 @
c4d182b7
export
function
getBatteryInfo
(
options
)
{
export
function
getBatteryInfo
(
options
)
{
return
wx
.
getBatteryInfo
(
options
)
return
wx
.
getBatteryInfo
(
options
)
}
}
export
function
getBatteryInfoSync
(
options
)
{
return
wx
.
getBatteryInfoSync
(
options
)
}
uni_modules/uni-memorywarning/package.json
浏览文件 @
c4d182b7
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
"description"
:
"UTS 实现内存警告监听"
,
"description"
:
"UTS 实现内存警告监听"
,
"keywords"
:
[
"keywords"
:
[
"onMemoryWarning"
"onMemoryWarning"
],
],
"repository"
:
""
,
"repository"
:
""
,
"engines"
:
{
"engines"
:
{
"HBuilderX"
:
"^3.6.11"
"HBuilderX"
:
"^3.6.11"
...
@@ -31,18 +31,16 @@
...
@@ -31,18 +31,16 @@
"npmurl"
:
""
"npmurl"
:
""
},
},
"uni_modules"
:
{
"uni_modules"
:
{
"uni-ext-api"
:{
"uni-ext-api"
:
{
"uni"
:
{
"uni"
:
{
"onMemoryWarning"
:
"onMemoryWarning"
,
"onMemoryWarning"
:
{
"offMemoryWarning"
:
"offMemoryWarning"
"web"
:
false
},
},
"mp-weixin"
:
false
,
"offMemoryWarning"
:
{
"mp-alipay"
:
false
,
"web"
:
false
"mp-baidu"
:
false
,
}
"mp-qq"
:
false
,
}
"mp-kuaishou"
:
false
,
},
"mp-jd"
:
false
},
"dependencies"
:
[],
"dependencies"
:
[],
"encrypt"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"platforms"
:
{
...
@@ -58,10 +56,10 @@
...
@@ -58,10 +56,10 @@
"App"
:
{
"App"
:
{
"app-android"
:
{
"app-android"
:
{
"minVersion"
:
"19"
"minVersion"
:
"19"
},
},
"app-ios"
:
{
"app-ios"
:
{
"minVersion"
:
"9"
"minVersion"
:
"9"
}
}
},
},
"H5-mobile"
:
{
"H5-mobile"
:
{
"Safari"
:
"n"
,
"Safari"
:
"n"
,
...
@@ -94,4 +92,4 @@
...
@@ -94,4 +92,4 @@
}
}
}
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
浏览文件 @
c4d182b7
...
@@ -46,6 +46,7 @@ class MemoryWarningTool {
...
@@ -46,6 +46,7 @@ class MemoryWarningTool {
}
}
}
}
// 开启监听内存警告
// 开启监听内存警告
export const onMemoryWarning : OnMemoryWarning = function (callback: UTSCallback) {
export const onMemoryWarning : OnMemoryWarning = function (callback: UTSCallback) {
MemoryWarningTool.listenMemoryWarning(callback)
MemoryWarningTool.listenMemoryWarning(callback)
...
...
uni_modules/uni-memorywarning/utssdk/interface.uts
浏览文件 @
c4d182b7
...
@@ -24,9 +24,10 @@ export interface Uni {
...
@@ -24,9 +24,10 @@ export interface Uni {
* }
* }
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
onMemoryWarning
: OnMemoryWarning
,
onMemoryWarning
(callback: UTSCallback) : void
,
/**
/**
* 取消监听内存不足告警事件
* 取消监听内存不足告警事件
*
*
...
@@ -47,7 +48,8 @@ export interface Uni {
...
@@ -47,7 +48,8 @@ export interface Uni {
* }
* }
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
offMemoryWarning
: OffMemoryWarning
offMemoryWarning
(callback : UTSCallback | null) : void
}
}
\ No newline at end of file
uni_modules/uni-usercapturescreen/package.json
浏览文件 @
c4d182b7
...
@@ -33,9 +33,16 @@
...
@@ -33,9 +33,16 @@
"uni_modules"
:
{
"uni_modules"
:
{
"uni-ext-api"
:{
"uni-ext-api"
:{
"uni"
:
{
"uni"
:
{
"onUserCaptureScreen"
:
"onUserCaptureScreen"
,
"onUserCaptureScreen"
:
{
"offUserCaptureScreen"
:
"offUserCaptureScreen"
,
"web"
:
false
"setUserCaptureScreen"
:
"setUserCaptureScreen"
},
"offUserCaptureScreen"
:
{
"web"
:
false
},
"setUserCaptureScreen"
:
{
"web"
:
false
,
"mp-weixin"
:
false
}
}
}
},
},
"dependencies"
:
[],
"dependencies"
:
[],
...
...
uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
浏览文件 @
c4d182b7
...
@@ -9,6 +9,7 @@ import Environment from "android.os.Environment";
...
@@ -9,6 +9,7 @@ import Environment from "android.os.Environment";
import System from 'java.lang.System';
import System from 'java.lang.System';
import WindowManager from 'android.view.WindowManager';
import WindowManager from 'android.view.WindowManager';
import { OnUserCaptureScreenCallbackResult, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreenSuccess, SetUserCaptureScreenOptions, SetUserCaptureScreen } from "../interface.uts";
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 {
...
@@ -34,9 +35,9 @@ class ScreenFileObserver extends FileObserver {
*/
*/
private screenFile : File;
private screenFile : File;
constructor(screenFile
: File
) {
constructor(screenFile
Str : string
) {
super(screenFile);
super(screenFile
Str
);
this.screenFile =
screenFile
;
this.screenFile =
new File(screenFileStr)
;
}
}
override onEvent(event : Int, path : string | null) : void {
override onEvent(event : Int, path : string | null) : void {
...
@@ -83,7 +84,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
...
@@ -83,7 +84,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
}
}
// 先结束监听 再开启监听
// 先结束监听 再开启监听
observer?.stopWatching();
observer?.stopWatching();
observer = new ScreenFileObserver(directory_screenshot);
observer = new ScreenFileObserver(directory_screenshot
.getPath()
);
observer?.startWatching();
observer?.startWatching();
...
@@ -92,7 +93,6 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
...
@@ -92,7 +93,6 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
observer = null
observer = null
})
})
}
}
/**
/**
...
...
uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts
浏览文件 @
c4d182b7
...
@@ -3,7 +3,7 @@ import { CGRect } from "CoreFoundation";
...
@@ -3,7 +3,7 @@ import { CGRect } from "CoreFoundation";
import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit"
import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit"
import { UTSiOS } from "DCloudUTSFoundation"
import { UTSiOS } from "DCloudUTSFoundation"
import { DispatchQueue } from 'Dispatch';
import { DispatchQueue } from 'Dispatch';
import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess
, SetUserCaptureScreenFail
} from "../interface.uts"
import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess } from "../interface.uts"
/**
/**
* 定义监听截屏事件工具类
* 定义监听截屏事件工具类
...
@@ -119,20 +119,12 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback :
...
@@ -119,20 +119,12 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback :
*/
*/
export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) {
export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) {
if (UIDevice.current.systemVersion < "13.0") {
if (UIDevice.current.systemVersion < "13.0") {
let res: SetUserCaptureScreenFail = {
let res = new UniError("uni-usercapturescreen", 12001, "setUserCaptureScreen:system not support")
errCode: 12001,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:system not support"
}
options.fail?.(res);
options.fail?.(res);
options.complete?.(res);
options.complete?.(res);
} else if (UIDevice.current.systemVersion == "15.1") {
} else if (UIDevice.current.systemVersion == "15.1") {
let res: SetUserCaptureScreenFail = {
let res = new UniError("uni-usercapturescreen", 12010, "setUserCaptureScreen:system internal error")
errCode: 12010,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:system internal error"
}
options.fail?.(res);
options.fail?.(res);
options.complete?.(res);
options.complete?.(res);
} else {
} else {
...
...
uni_modules/uni-usercapturescreen/utssdk/interface.uts
浏览文件 @
c4d182b7
...
@@ -23,25 +23,6 @@ export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null)
...
@@ -23,25 +23,6 @@ export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null)
export type SetUserCaptureScreenSuccess = {
export type SetUserCaptureScreenSuccess = {
}
}
/**
* uni.setUserCaptureScreen失败回调参数
*/
export type SetUserCaptureScreenFail = {
/**
* 错误码
* 12001:system not support
* 12010:system internal error
*/
errCode : number,
/**
* 调用API的名称
*/
errSubject : string,
/**
* 错误的详细信息
*/
errMsg : string,
}
/**
/**
* uni.setUserCaptureScreen成功回调函数定义
* uni.setUserCaptureScreen成功回调函数定义
...
@@ -51,7 +32,7 @@ export type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuc
...
@@ -51,7 +32,7 @@ export type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuc
/**
/**
* uni.setUserCaptureScreen失败回调函数定义
* uni.setUserCaptureScreen失败回调函数定义
*/
*/
export type SetUserCaptureScreenFailCallback = (res :
SetUserCaptureScreenFail
) => void
export type SetUserCaptureScreenFailCallback = (res :
UniError
) => void
/**
/**
* uni.setUserCaptureScreen完成回调函数定义
* uni.setUserCaptureScreen完成回调函数定义
...
@@ -107,9 +88,10 @@ export interface Uni {
...
@@ -107,9 +88,10 @@ export interface Uni {
* }
* }
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
onUserCaptureScreen
: OnUserCaptureScreen
,
onUserCaptureScreen
(callback : UserCaptureScreenCallback | null) : void
,
/**
/**
* 关闭截屏监听
* 关闭截屏监听
*
*
...
@@ -130,9 +112,10 @@ export interface Uni {
...
@@ -130,9 +112,10 @@ export interface Uni {
* }
* }
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
offUserCaptureScreen
: OffUserCaptureScreen
,
offUserCaptureScreen
(callback : UserCaptureScreenCallback | null) : void
,
/**
/**
* 设置防截屏
* 设置防截屏
*
*
...
@@ -155,5 +138,5 @@ export interface Uni {
...
@@ -155,5 +138,5 @@ export interface Uni {
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
*/
*/
setUserCaptureScreen
: SetUserCaptureScreen
setUserCaptureScreen
(options : SetUserCaptureScreenOptions) : void
}
}
\ No newline at end of file
uni_modules/uni-wifi/package.json
浏览文件 @
c4d182b7
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
"description"
:
"wifi管理"
,
"description"
:
"wifi管理"
,
"keywords"
:
[
"keywords"
:
[
"wifi"
"wifi"
],
],
"repository"
:
""
,
"repository"
:
""
,
"engines"
:
{
"engines"
:
{
"HBuilderX"
:
"^3.6.11"
"HBuilderX"
:
"^3.6.11"
...
@@ -31,21 +31,43 @@
...
@@ -31,21 +31,43 @@
"npmurl"
:
""
"npmurl"
:
""
},
},
"uni_modules"
:
{
"uni_modules"
:
{
"uni-ext-api"
:{
"uni-ext-api"
:
{
"uni"
:
{
"uni"
:
{
"startWifi"
:
"startWifi"
,
"startWifi"
:
{
"stopWifi"
:
"stopWifi"
,
"web"
:
false
"connectWifi"
:
"connectWifi"
,
},
"getConnectedWifi"
:
"getConnectedWifi"
,
"stopWifi"
:
{
"getWifiList"
:
"getWifiList"
,
"web"
:
false
"onGetWifiList"
:
"onGetWifiList"
,
},
"offGetWifiList"
:
"offGetWifiList"
,
"connectWifi"
:
{
"onWifiConnected"
:
"onWifiConnected"
,
"web"
:
false
"offWifiConnected"
:
"offWifiConnected"
,
},
"onWifiConnectedWithPartialInfo"
:
"onWifiConnectedWithPartialInfo"
,
"getConnectedWifi"
:
{
"offWifiConnectedWithPartialInfo"
:
"offWifiConnectedWithPartialInfo"
"web"
:
false
}
},
},
"getWifiList"
:
{
"web"
:
false
},
"onGetWifiList"
:
{
"web"
:
false
},
"offGetWifiList"
:
{
"web"
:
false
},
"onWifiConnected"
:
{
"web"
:
false
},
"offWifiConnected"
:
{
"web"
:
false
},
"onWifiConnectedWithPartialInfo"
:
{
"web"
:
false
},
"offWifiConnectedWithPartialInfo"
:
{
"web"
:
false
}
}
},
"dependencies"
:
[],
"dependencies"
:
[],
"encrypt"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"platforms"
:
{
...
@@ -61,10 +83,10 @@
...
@@ -61,10 +83,10 @@
"App"
:
{
"App"
:
{
"app-android"
:
{
"app-android"
:
{
"minVersion"
:
"19"
"minVersion"
:
"19"
},
},
"app-ios"
:
{
"app-ios"
:
{
"minVersion"
:
"9"
"minVersion"
:
"9"
}
}
},
},
"H5-mobile"
:
{
"H5-mobile"
:
{
"Safari"
:
"n"
,
"Safari"
:
"n"
,
...
@@ -97,4 +119,4 @@
...
@@ -97,4 +119,4 @@
}
}
}
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-wifi/utssdk/app-android/config.json
0 → 100644
浏览文件 @
c4d182b7
{
"minSdkVersion"
:
"19"
}
\ No newline at end of file
uni_modules/uni-wifi/utssdk/app-android/index.uts
浏览文件 @
c4d182b7
...
@@ -210,8 +210,8 @@ function wrapWifiConfiguration(SSID : string, password ?: string, passwordType :
...
@@ -210,8 +210,8 @@ function wrapWifiConfiguration(SSID : string, password ?: string, passwordType :
/**
/**
* 判断当前wifi的加密类型
* 判断当前wifi的加密类型
*/
*/
function getSecurityType(result : ScanResult) : string {
function getSecurityType(result : ScanResult) : string {
if (result.capabilities.contains("WEP")) {
if (result.capabilities.contains("WEP")) {
return "WEP";
return "WEP";
...
@@ -306,17 +306,8 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
...
@@ -306,17 +306,8 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
if (intent.action == WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) {
if (intent.action == WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) {
startWifiScaning = false;
startWifiScaning = false;
let ret : UniWifiResult = {
errCode: 0,
errSubject: "uni-getWifiList",
errMsg: "getWifiList:ok"
}
if(Global.supendGetWifiSuccess != null){
Global.supendGetWifiSuccess?.(ret)
}
if(Global.supendGetWifiComplete != null){
Global.supendGetWifiComplete?.(ret)
}
// wifi 扫描结果回调
// wifi 扫描结果回调
let results = this.mWifiManager!.scanResults;
let results = this.mWifiManager!.scanResults;
...
@@ -336,15 +327,27 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
...
@@ -336,15 +327,27 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
const data = new JSONObject();
const data = new JSONObject();
data["wifiList"] = Global.scanList
data["wifiList"] = Global.scanList
Global.onGetWifiListCallback?.(data);
Global.onGetWifiListCallback?.(data);
/**
* 确保onGetWifiList 只会被执行一次
*/
Global.onGetWifiListCallback = null
}
}
// for (let perCallback in Global.onGetWifiListCallback) {
// const data = new JSONObject();
// data["wifiList"] = Global.scanList
// perCallback(data);
// }
}
}
let ret : UniWifiResult = {
errCode: 0,
errSubject: "uni-getWifiList",
errMsg: "getWifiList:ok"
}
if(Global.supendGetWifiSuccess != null){
Global.supendGetWifiSuccess?.(ret)
Global.supendGetWifiSuccess = null
}
if(Global.supendGetWifiComplete != null){
Global.supendGetWifiComplete?.(ret)
Global.supendGetWifiComplete = null
}
}
}
}
}
...
@@ -367,18 +370,21 @@ export function startWifi(option : WifiOption) {
...
@@ -367,18 +370,21 @@ export function startWifi(option : WifiOption) {
// 需要先开启wifi,才能使用后续的功能
// 需要先开启wifi,才能使用后续的功能
let requestCode = 1001;
let requestCode = 1001;
let permissionWifi = arrayOf("android.permission.ACCESS_FINE_LOCATION");
let permissionWifi = arrayOf("android.permission.ACCESS_FINE_LOCATION");
var result : UniWifiResult = {
let result : UniWifiResult = {
errCode: 12001,
errCode: 12001,
errMsg: "startWifi:premission loss",
errMsg: "startWifi:premission loss",
errSubject: "uni-startWifi"
errSubject: "uni-startWifi"
}
}
// 检查权限
// 检查权限
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, permissionWifi, requestCode.toInt())
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, permissionWifi, requestCode.toInt())
// 尚不具备权限,返回错误
// 尚不具备权限,返回错误
option.fail?.(result)
let err = new UniError("uni-startWifi",12001,"startWifi:premission loss");
option.complete?.(result)
option.fail?.(err)
option.complete?.(err)
return;
return;
}
}
...
@@ -389,11 +395,9 @@ export function startWifi(option : WifiOption) {
...
@@ -389,11 +395,9 @@ export function startWifi(option : WifiOption) {
// 用户没有开启wifi 总开关
// 用户没有开启wifi 总开关
if (!wifiManager.isWifiEnabled()) {
if (!wifiManager.isWifiEnabled()) {
// wifi 没开启
// wifi 没开启
result.errCode = 12005;
let err = new UniError("uni-startWifi",12005,"wifi not turned on");
result.errMsg = "wifi not turned on";
option.fail?.(err);
option.complete?.(err);
option.fail?.(result);
option.complete?.(result);
return;
return;
}
}
// 初始化wifi 状态广播监听,后续所有的api,均基于此
// 初始化wifi 状态广播监听,后续所有的api,均基于此
...
@@ -453,16 +457,13 @@ export function startWifi(option : WifiOption) {
...
@@ -453,16 +457,13 @@ export function startWifi(option : WifiOption) {
@Suppress("DEPRECATION")
@Suppress("DEPRECATION")
export function getWifiList(option : WifiOption) {
export function getWifiList(option : WifiOption) {
var result : UniWifiResult = {
errCode: 12000,
errMsg: "getWifiList:fail:not invoke startWifi",
errSubject: "uni-getWifiList"
}
if (Global.mReceiver == null) {
if (Global.mReceiver == null) {
// 还没调用startWifi 提示报错
// 还没调用startWifi 提示报错
option.fail?.(result)
let err = new UniError("uni-getWifiList",12000,"getWifiList:fail:not invoke startWifi");
option.complete?.(result)
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -547,11 +548,13 @@ export function offGetWifiList(callback? : UTSCallback) {
...
@@ -547,11 +548,13 @@ export function offGetWifiList(callback? : UTSCallback) {
/**
/**
* 真正执行wifi链接逻辑
* 真正执行wifi链接逻辑
*/
*/
function realWifiConnect(option : WifiConnectOption
,result : UniWifiResult
){
function realWifiConnect(option : WifiConnectOption){
if (Global.mReceiver == null || Global.scanList.length < 1) {
if (Global.mReceiver == null || Global.scanList.length < 1) {
option.fail?.(result)
option.complete?.(result)
let err = new UniError("uni-connectWifi",12000,"connectWifi:fail:not invoke startWifi");
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -566,8 +569,9 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -566,8 +569,9 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
if (scanWifiInfo == null) {
if (scanWifiInfo == null) {
// 不在扫描列表中返回错误
// 不在扫描列表中返回错误
option.fail?.(result)
let err = new UniError("uni-connectWifi",12000,"connectWifi:fail:not invoke startWifi");
option.complete?.(result)
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -593,16 +597,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -593,16 +597,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
// add since 2023-03-28,如果当前系统大于等于android10, 则明确当前系统不支持
// add since 2023-03-28,如果当前系统大于等于android10, 则明确当前系统不支持
if(Build.VERSION.SDK_INT > 28){
if(Build.VERSION.SDK_INT > 28){
// 系统大于android 9
// 系统大于android 9
result.errCode = 12001
let err = new UniError("uni-connectWifi",12001,"connectWifi:system not support");
result.errMsg = "connectWifi:system not support"
option.fail?.(err)
option.complete?.(err)
}else{
}else{
// 移除之前的配置失败了,返回错误,需要用户手动取消保存一下
// 移除之前的配置失败了,返回错误,需要用户手动取消保存一下
result.errCode = 12013
let err = new UniError("uni-connectWifi",12013,"connectWifi:wifi config may be expired");
result.errMsg = "connectWifi:wifi config may be expired"
option.fail?.(err)
option.complete?.(err)
}
}
option.fail?.(result)
option.complete?.(result)
return
return
}
}
...
@@ -623,11 +627,11 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -623,11 +627,11 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
let netID = wifiManager.addNetwork(wifiConfigration);
let netID = wifiManager.addNetwork(wifiConfigration);
// 如果-1 说明没添加上,报错即可
// 如果-1 说明没添加上,报错即可
if (netID < 0) {
if (netID < 0) {
result.errCode = 12002
result.errMsg = "connectWifi:password error Wi-Fi"
let err = new UniError("uni-connectWifi",12002,"connectWifi:password error Wi-Fi");
option.fail?.(
result
)
option.fail?.(
err
)
option.complete?.(
result
)
option.complete?.(
err
)
return
return
}
}
...
@@ -636,11 +640,10 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -636,11 +640,10 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
let enabled = wifiManager.enableNetwork(netID, true);
let enabled = wifiManager.enableNetwork(netID, true);
if (!enabled) {
if (!enabled) {
result.errCode = 12007
let err = new UniError("uni-connectWifi",12007,"connectWifi:user denied");
result.errMsg = "connectWifi:user denied"
option.fail?.(err)
option.fail?.(result)
option.complete?.(err)
option.complete?.(result)
return
return
}
}
...
@@ -654,14 +657,18 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -654,14 +657,18 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
if (!connected) {
if (!connected) {
// 出错了,返回错误
// 出错了,返回错误
// 兜底的报错
// 兜底的报错
result.errCode = 12010
let err = new UniError("uni-connectWifi",12010,"connectWifi:fail:unknown error");
result.errMsg = "connectWifi:fail:unknown error"
option.fail?.(err)
option.complete?.(err)
option.fail?.(result)
option.complete?.(result)
return
return
}
}
let result : UniWifiResult = {
errCode: 0,
errMsg: "connectWifi:ok",
errSubject: "uni-connectWifi",
}
wifiManager.saveConfiguration()
wifiManager.saveConfiguration()
//scanWifiInfo 根据 partialInfo 填充给返回字段
//scanWifiInfo 根据 partialInfo 填充给返回字段
if (option.partialInfo != null && option.partialInfo == true) {
if (option.partialInfo != null && option.partialInfo == true) {
...
@@ -673,9 +680,6 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -673,9 +680,6 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo)
result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo)
}
}
// result.wifi = scanWifiInfo.toUTSJSON(option.partialInfo)
result.errCode = 0
result.errMsg = "connectWifi:ok"
option.success?.(result)
option.success?.(result)
option.complete?.(result)
option.complete?.(result)
...
@@ -687,20 +691,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -687,20 +691,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
@Suppress("UNUSED_PARAMETER", "DEPRECATION")
@Suppress("UNUSED_PARAMETER", "DEPRECATION")
export function connectWifi(option : WifiConnectOption) {
export function connectWifi(option : WifiConnectOption) {
var result : UniWifiResult = {
errCode: 12000,
errMsg: "connectWifi:fail:not invoke startWifi",
errSubject: "uni-connectWifi",
}
if (option.maunal == true) {
if (option.maunal == true) {
// 指定了手动模式
// 指定了手动模式
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
UTSAndroid.getUniActivity()!.startActivity(manunalIntent);
UTSAndroid.getUniActivity()!.startActivity(manunalIntent);
result.errCode = 0
let result : UniWifiResult = {
result.errMsg = "connectWifi:ok"
errCode: 0,
errMsg: "connectWifi:ok",
errSubject: "uni-connectWifi",
}
option.success?.(result)
option.success?.(result)
option.complete?.(result)
option.complete?.(result)
...
@@ -719,7 +719,7 @@ export function connectWifi(option : WifiConnectOption) {
...
@@ -719,7 +719,7 @@ export function connectWifi(option : WifiConnectOption) {
if(taskCount >= 5 || startWifiScaning == false){
if(taskCount >= 5 || startWifiScaning == false){
// 超过10s了。或者扫描过程结束了
// 超过10s了。或者扫描过程结束了
clearInterval(taskId)
clearInterval(taskId)
realWifiConnect(option
,result
)
realWifiConnect(option)
}
}
},2000)
},2000)
...
@@ -727,7 +727,7 @@ export function connectWifi(option : WifiConnectOption) {
...
@@ -727,7 +727,7 @@ export function connectWifi(option : WifiConnectOption) {
clearInterval(taskId)
clearInterval(taskId)
});
});
}else{
}else{
realWifiConnect(option
,result
)
realWifiConnect(option)
}
}
...
@@ -741,13 +741,9 @@ export function connectWifi(option : WifiConnectOption) {
...
@@ -741,13 +741,9 @@ export function connectWifi(option : WifiConnectOption) {
export function stopWifi(option : WifiOption) {
export function stopWifi(option : WifiOption) {
// 需要先开启wifi,才能使用后续的功能
// 需要先开启wifi,才能使用后续的功能
if (Global.mReceiver == null) {
if (Global.mReceiver == null) {
var result : UniWifiResult = {
let err = new UniError("uni-stopWifi",12000,"stopWifi:not init");
errCode: 12000,
option.fail?.(err)
errSubject: "uni-stopWifi",
option.complete?.(err)
errMsg: "stopWifi:not init"
}
option.fail?.(result)
option.complete?.(result)
return
return
}
}
...
@@ -768,6 +764,7 @@ export function stopWifi(option : WifiOption) {
...
@@ -768,6 +764,7 @@ export function stopWifi(option : WifiOption) {
errSubject: "uni-stopWifi",
errSubject: "uni-stopWifi",
errMsg: "stopWifi:ok"
errMsg: "stopWifi:ok"
}
}
option.success?.(result)
option.success?.(result)
option.complete?.(result)
option.complete?.(result)
...
@@ -783,16 +780,12 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
@@ -783,16 +780,12 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
SSID: ""
SSID: ""
}
}
var res : UniWifiResult = {
errCode: 12000,
errMsg: "getConnectedWifi:fail:not invoke startWifi",
errSubject: "uni-getConnectedWifi",
}
if (Global.mReceiver == null) {
if (Global.mReceiver == null) {
// 还没调用startWifi 提示报错
// 还没调用startWifi 提示报错
option.fail?.(res)
let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:fail:not invoke startWifi");
option.complete?.(res)
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -800,14 +793,14 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
@@ -800,14 +793,14 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
// 需要先校验权限,没有位置权限无法获取wifi
// 需要先校验权限,没有位置权限无法获取wifi
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 尚不具备权限,返回错误
// 尚不具备权限,返回错误
res.errCode = 12001
let err = new UniError("uni-getConnectedWifi",12001,"getConnectedWifi:permission loss");
res.errMsg = "getConnectedWifi:permission loss"
option.fail?.(err)
option.complete?.(err)
option.fail?.(res)
option.complete?.(res)
return;
return;
}
}
const context = UTSAndroid.getAppContext();
const context = UTSAndroid.getAppContext();
if (context != null) {
if (context != null) {
const wm = context.getSystemService(
const wm = context.getSystemService(
...
@@ -818,31 +811,37 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
@@ -818,31 +811,37 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
const winfo = wm.getConnectionInfo();
const winfo = wm.getConnectionInfo();
wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo);
wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo);
let res : UniWifiResult = {
errCode: 0,
errMsg: "getConnectedWifi:ok",
errSubject: "uni-getConnectedWifi",
}
// 判断一下是否wifi 关闭了
// 判断一下是否wifi 关闭了
if (option.partialInfo
!= null && option.partialInfo == true
) {
if (option.partialInfo
!= null
) {
let ret : UniWifiInfo = {
let ret : UniWifiInfo = {
SSID: wifiInfo.SSID
SSID: wifiInfo.SSID
}
}
res.wifi = ret;
res.wifi = ret;
} else {
} else {
if (wifiInfo.BSSID == null || zeroCountNum(wifiInfo.BSSID) > 3) {
if (wifiInfo.BSSID == null || zeroCountNum(wifiInfo.BSSID) > 3) {
res.errCode = 12005
let err = new UniError("uni-getConnectedWifi",12005,"getConnectedWifi:fail:wifi is disable");
res.errMsg = "getConnectedWifi:fail:wifi is disable"
option.fail?.(err)
option.complete?.(err)
option.fail?.(res)
option.complete?.(res)
return
return
}
}
res.wifi = wifiInfo;
res.wifi = wifiInfo;
}
}
res.errCode = 0
res.errMsg = "getConnectedWifi:ok"
option.success?.(res)
option.success?.(res)
option.complete?.(res)
option.complete?.(res)
return
return
}
}
option.fail?.(res)
option.complete?.(res)
let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:fail:not invoke startWifi");
}
option.fail?.(err)
\ No newline at end of file
option.complete?.(err)
}
uni_modules/uni-wifi/utssdk/app-ios/index.uts
浏览文件 @
c4d182b7
...
@@ -114,24 +114,14 @@ function fetchConnectedWifiWithLocationPromise(option: GetConnectedWifiOptions)
...
@@ -114,24 +114,14 @@ function fetchConnectedWifiWithLocationPromise(option: GetConnectedWifiOptions)
option.success?.(res)
option.success?.(res)
option.complete?.(res)
option.complete?.(res)
}else {
}else {
const res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12010,"getConnectedWifi:system internal error");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12010,
option.complete?.(err)
errMsg: "getConnectedWifi:system internal error",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
}else {
}else {
const res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12010,"getConnectedWifi:system internal error");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12010,
option.complete?.(err)
errMsg: "getConnectedWifi:system internal error",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
}
}
...
@@ -174,7 +164,7 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
...
@@ -174,7 +164,7 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
errCode: 0,
errCode: 0,
errMsg: "stopWifi:ok",
errMsg: "stopWifi:ok",
wifi: null
wifi: null
}
}
option.success?.(res)
option.success?.(res)
option.complete?.(res)
option.complete?.(res)
}
}
...
@@ -183,14 +173,9 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
...
@@ -183,14 +173,9 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
* 获取wifi列表, 在调用之前需要引导用户跳转到系统设置-WIFI设置页面,系统搜索周边wifi后app才能接收到回调
* 获取wifi列表, 在调用之前需要引导用户跳转到系统设置-WIFI设置页面,系统搜索周边wifi后app才能接收到回调
*/
*/
export const getWifiList: GetWifiList = function (option: WifiOption) {
export const getWifiList: GetWifiList = function (option: WifiOption) {
let res: UniWifiResult = {
let err = new UniError("uni-getWifiList",12001,"getWifiList:system not support");
errSubject: "uni-getWifiList",
option.fail?.(err)
errCode: 12001,
option.complete?.(err)
errMsg: "getWifiList:system not support",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
/* 获取wifi列表的回调
/* 获取wifi列表的回调
...
@@ -213,28 +198,18 @@ export const offGetWifiList: OffGetWifiList = function (callback: UniWifiCallbac
...
@@ -213,28 +198,18 @@ export const offGetWifiList: OffGetWifiList = function (callback: UniWifiCallbac
*/
*/
export const getConnectedWifi: GetConnectedWifi = function (option: GetConnectedWifiOptions) {
export const getConnectedWifi: GetConnectedWifi = function (option: GetConnectedWifiOptions) {
if (UniWiFiModuleGloabInfo.alreadyStartWifi == false) {
if (UniWiFiModuleGloabInfo.alreadyStartWifi == false) {
let res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:not init");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12000,
option.complete?.(err)
errMsg: "getConnectedWifi:not init",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
} else{
} else{
if (UIDevice.current.systemVersion >= "13.0") {
if (UIDevice.current.systemVersion >= "13.0") {
requestLocationPromise((success) => {
requestLocationPromise((success) => {
if (success == true) {
if (success == true) {
fetchConnectedWifiWithLocationPromise(option)
fetchConnectedWifiWithLocationPromise(option)
}else {
}else {
let res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12007,"getConnectedWifi:user denied");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12007,
option.complete?.(err)
errMsg: "getConnectedWifi:user denied",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
})
})
} else{
} else{
...
@@ -247,14 +222,10 @@ export const getConnectedWifi: GetConnectedWifi = function (option: GetConnected
...
@@ -247,14 +222,10 @@ export const getConnectedWifi: GetConnectedWifi = function (option: GetConnected
* 连接wifi
* 连接wifi
*/
*/
export const connectWifi: ConnectWifi = function (option: WifiConnectOption) {
export const connectWifi: ConnectWifi = function (option: WifiConnectOption) {
let res: UniWifiResult = {
errSubject: "uni-connectWifi",
let err = new UniError("uni-connectWifi",12001,"connectWifi:system not support");
errCode: 12001,
option.fail?.(err)
errMsg: "connectWifi:system not support",
option.complete?.(err)
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
...
@@ -290,12 +261,7 @@ export const onOffWifiConnectedWithPartialInfo: OnOffWifiConnectedWithPartialInf
...
@@ -290,12 +261,7 @@ export const onOffWifiConnectedWithPartialInfo: OnOffWifiConnectedWithPartialInf
* 设置 wifiList 中 AP 的相关信息。在 onGetWifiList 回调后调用,iOS特有接口。
* 设置 wifiList 中 AP 的相关信息。在 onGetWifiList 回调后调用,iOS特有接口。
*/
*/
export const setWifiList: SetWifiList = function (option: WifiOption) {
export const setWifiList: SetWifiList = function (option: WifiOption) {
let res: UniWifiResult = {
let err = new UniError("uni-setWifiList",12001,"setWifiList:system not support");
errSubject: "uni-setWifiList",
option.fail?.(err)
errCode: 12001,
option.complete?.(err)
errMsg: "setWifiList:system not support",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
\ No newline at end of file
uni_modules/uni-wifi/utssdk/interface.uts
浏览文件 @
c4d182b7
/**
/**
* Wifi 函数通用入参封装
* Wifi 函数通用入参封装
*/
*/
export type WifiOption = {
export type WifiOption = {
success
?: (res
: UniWifiResult) => void;
success
?: (res
: UniWifiResult) => void;
fail
?: (res: UniWifiResult
) => void;
fail
?: (res : UniError
) => void;
complete
?: (res: UniWifiResult
) => void;
complete
?: (res : any
) => void;
};
};
/**
/**
* Wifi 链接参数封装
* Wifi 链接参数封装
*/
*/
export type WifiConnectOption = {
export type WifiConnectOption = {
SSID?: string;
SSID
?: string;
BSSID?: string;
BSSID
?: string;
password?: string;
password
?: string;
maunal?: boolean;
maunal
?: boolean;
partialInfo?: boolean; //ios不生效
partialInfo
?: boolean; //ios不生效
success
?: (res
: UniWifiResult) => void;
success
?: (res
: UniWifiResult) => void;
fail
?: (res: UniWifiResult
) => void;
fail
?: (res : UniError
) => void;
complete
?: (res: UniWifiResult
) => void;
complete
?: (res : any
) => void;
}
}
/**
/**
* 获取当前链接的wifi信息
* 获取当前链接的wifi信息
*/
*/
export type GetConnectedWifiOptions = {
export type GetConnectedWifiOptions = {
partialInfo?: boolean
partialInfo
?: boolean
success
?: (res
: UniWifiResult) => void
success
?: (res
: UniWifiResult) => void
fail
?: (res: UniWifiResult
) => void
fail
?: (res : UniError
) => void
complete
?: (res: UniWifiResult
) => void
complete
?: (res : any
) => void
}
}
/*
/*
* 对外暴露的wifi信息
* 对外暴露的wifi信息
*/
*/
export type UniWifiInfo = {
export type UniWifiInfo = {
SSID: string;
SSID
: string;
BSSID?: string;
BSSID
?: string;
secure?: boolean;
secure
?: boolean;
signalStrength?: number;
signalStrength
?: number;
frequency?: number;
frequency
?: number;
}
}
...
@@ -47,35 +47,35 @@ export type UniWifiResult = {
...
@@ -47,35 +47,35 @@ export type UniWifiResult = {
errCode : number,
errCode : number,
errSubject : string,
errSubject : string,
errMsg : string,
errMsg : string,
wifi: UniWifiInfo | null
wifi
: UniWifiInfo | null
}
}
export type UniWifiCallback = () => void
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 {
interface Uni {
/**
/**
...
@@ -99,8 +99,9 @@ interface Uni {
...
@@ -99,8 +99,9 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { after: 'stopWifi' }
*/
*/
startWifi
: StartWifi
,
startWifi
(option : WifiOption): void
,
/**
/**
* 关闭 Wi-Fi 模块
* 关闭 Wi-Fi 模块
*
*
...
@@ -122,15 +123,16 @@ interface Uni {
...
@@ -122,15 +123,16 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { before: 'startWifi' }
*/
*/
stopWifi
: StopWifi
,
stopWifi
(option : WifiOption) : void
,
/**
/**
* @param {WifiConnectOption} option
* @param {WifiConnectOption} option
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi
* @uniPlatform {
* @uniPlatform {
* "app": {
* "app": {
* "android": {
* "android": {
* "osVer": "
4.4.4
",
* "osVer": "
>=4.4 && <10.0
",
* "uniVer": "3.7.0",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* "unixVer": "3.9.0"
* },
* },
...
@@ -163,7 +165,7 @@ interface Uni {
...
@@ -163,7 +165,7 @@ interface Uni {
]
]
}
}
*/
*/
connectWifi
: ConnectWifi
,
connectWifi
(option : WifiConnectOption) : void
,
/**
/**
* 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。
* 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。
* @param {WifiOption} option
* @param {WifiOption} option
...
@@ -184,17 +186,9 @@ interface Uni {
...
@@ -184,17 +186,9 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest {
* @autotest { before: 'startWifi', after: 'stopWifi' }
generated: false,
cases:[
{
before: 'startWifi',
after: 'stopWifi'
}
]
}
*/
*/
getWifiList
: GetWifiList
,
getWifiList
(option : WifiOption) : void
,
/**
/**
* 监听获取到 Wi-Fi 列表数据事件。
* 监听获取到 Wi-Fi 列表数据事件。
*
*
...
@@ -216,8 +210,25 @@ interface Uni {
...
@@ -216,8 +210,25 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
* @autotest {
generated: false,
pollution: false,
expectCallback: true,
before: 'startWifi',
after: 'onGetWifiListAfter',
cases: [
{
output: {
value: 0,
returnKey: '.wifiList.length',
jestExpectSyntax: 'toBeGreaterThan'
},
}
]
}
*/
*/
onGetWifiList
: OnGetWifiList
,
onGetWifiList
(callback : UniWifiCallback) : void
,
/**
/**
* 移除获取到 Wi-Fi 列表数据事件的监听函数。
* 移除获取到 Wi-Fi 列表数据事件的监听函数。
*
*
...
@@ -239,8 +250,9 @@ interface Uni {
...
@@ -239,8 +250,9 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
offGetWifiList
: OffGetWifiList
,
offGetWifiList
(callback : UniWifiCallback) : void
,
/**
/**
* 获取已连接的 Wi-Fi 信息
* 获取已连接的 Wi-Fi 信息
*
*
...
@@ -262,8 +274,9 @@ interface Uni {
...
@@ -262,8 +274,9 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { before: 'startWifi', after: 'stopWifi' }
*/
*/
getConnectedWifi
: GetConnectedWifi
,
getConnectedWifi
(option : GetConnectedWifiOptions) : void
,
/**
/**
* 监听连接上 Wi-Fi 的事件
* 监听连接上 Wi-Fi 的事件
*
*
...
@@ -285,8 +298,9 @@ interface Uni {
...
@@ -285,8 +298,9 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
onWifiConnected
: OnWifiConnecte
d,
onWifiConnected
(callback : UniWifiCallback) : voi
d,
/**
/**
* 监听连接上 Wi-Fi 的事件。
* 监听连接上 Wi-Fi 的事件。
*
*
...
@@ -308,8 +322,9 @@ interface Uni {
...
@@ -308,8 +322,9 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
onWifiConnectedWithPartialInfo
: OnWifiConnectedWithPartialInfo
,
onWifiConnectedWithPartialInfo
(callback : UniWifiCallback) : void
,
/**
/**
* 移除连接上 Wi-Fi 的事件的监听函数。
* 移除连接上 Wi-Fi 的事件的监听函数。
*
*
...
@@ -331,8 +346,9 @@ interface Uni {
...
@@ -331,8 +346,9 @@ interface Uni {
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
offWifiConnected
: OffWifiConnecte
d,
offWifiConnected
(callback : UniWifiCallback | null) : voi
d,
/**
/**
* 移除连接上 Wi-Fi 的事件的监听函数。
* 移除连接上 Wi-Fi 的事件的监听函数。
*
*
...
@@ -341,20 +357,39 @@ interface Uni {
...
@@ -341,20 +357,39 @@ interface Uni {
* @uniPlatform {
* @uniPlatform {
* "app": {
* "app": {
* "android": {
* "android": {
* "osVer": "
4.4.4
",
* "osVer": "
x
",
* "uniVer": "
3.7.0
",
* "uniVer": "
x
",
* "unixVer": "
3.9.0
"
* "unixVer": "
x
"
* },
* },
* "ios": {
* "ios": {
* "osVer": "
9.0
",
* "osVer": "
x
",
* "uniVer": "
3.7.7
",
* "uniVer": "
x
",
* "unixVer": "
3.9.0
"
* "unixVer": "
x
"
* }
* }
* }
* }
* }
* }
* @uniVersion 3.7.7
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
* @uniVueVersion 2,3 //支持的vue版本
* @autotest { expectCallback: true }
*/
*/
onOffWifiConnectedWithPartialInfo : OnOffWifiConnectedWithPartialInfo,
onOffWifiConnectedWithPartialInfo(callback : UniWifiCallback | null) : void,
setWifiList : SetWifiList,
/**
}
* SetWifiList 暂未实现
*
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
*/
setWifiList(option : WifiOption) : void,
}
\ No newline at end of file
uni_modules/uni-wifi/utssdk/uni.autotest.js
0 → 100644
浏览文件 @
c4d182b7
export
function
startWifi
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
startWifi
({
success
:
()
=>
{
console
.
log
(
'
startWifi success
'
);
resolve
()
},
complete
:
()
=>
{
console
.
log
(
'
startWifi fail
'
);
resolve
()
}
})
})
}
export
function
stopWifi
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
stopWifi
({
complete
:
resolve
})
})
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录