Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
b7cdd6c7
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1605
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b7cdd6c7
编写于
11月 25, 2022
作者:
lizhongyi_
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add wifiInfomation 插件
上级
e941620d
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
263 addition
and
1 deletion
+263
-1
manifest.json
manifest.json
+1
-1
pages/SystemAPI/SystemAPI.vue
pages/SystemAPI/SystemAPI.vue
+6
-0
pages/SystemAPI/WifiInfomation/wifiInfomation.vue
pages/SystemAPI/WifiInfomation/wifiInfomation.vue
+53
-0
uni_modules/uni-wifiinformation/changelog.md
uni_modules/uni-wifiinformation/changelog.md
+0
-0
uni_modules/uni-wifiinformation/package.json
uni_modules/uni-wifiinformation/package.json
+81
-0
uni_modules/uni-wifiinformation/readme.md
uni_modules/uni-wifiinformation/readme.md
+5
-0
uni_modules/uni-wifiinformation/utssdk/app-android/index.uts
uni_modules/uni-wifiinformation/utssdk/app-android/index.uts
+0
-0
uni_modules/uni-wifiinformation/utssdk/app-ios/UTS.entitlements
...dules/uni-wifiinformation/utssdk/app-ios/UTS.entitlements
+8
-0
uni_modules/uni-wifiinformation/utssdk/app-ios/index.uts
uni_modules/uni-wifiinformation/utssdk/app-ios/index.uts
+109
-0
未找到文件。
manifest.json
浏览文件 @
b7cdd6c7
{
{
"name"
:
"HelloUTS"
,
"name"
:
"HelloUTS"
,
"appid"
:
"__UNI__
70BE9D0
"
,
"appid"
:
"__UNI__
FB95CAB
"
,
"description"
:
""
,
"description"
:
""
,
"versionName"
:
"1.0.9"
,
"versionName"
:
"1.0.9"
,
"versionCode"
:
"109"
,
"versionCode"
:
"109"
,
...
...
pages/SystemAPI/SystemAPI.vue
浏览文件 @
b7cdd6c7
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
<uni-collapse-item
title=
"系统事件"
:border=
"false"
>
<uni-collapse-item
title=
"系统事件"
:border=
"false"
>
<uni-list>
<uni-list>
<uni-list-item
@
tap=
"gotoScreenListen"
title=
"监听系统截屏"
class=
"itemButton"
:clickable=
"true"
link
/>
<uni-list-item
@
tap=
"gotoScreenListen"
title=
"监听系统截屏"
class=
"itemButton"
:clickable=
"true"
link
/>
<uni-list-item
@
tap=
"gotoWifiInfomation"
title=
"获取当前wifi信息"
class=
"itemButton"
:clickable=
"true"
link
/>
</uni-list>
</uni-list>
</uni-collapse-item>
</uni-collapse-item>
</uni-collapse>
</uni-collapse>
...
@@ -65,6 +66,11 @@
...
@@ -65,6 +66,11 @@
url
:
'
/pages/SystemAPI/ScreenListen/screenlisten
'
url
:
'
/pages/SystemAPI/ScreenListen/screenlisten
'
})
})
},
},
gotoWifiInfomation
(){
uni
.
navigateTo
({
url
:
'
/pages/SystemAPI/WifiInfomation/wifiInfomation
'
})
},
gotoAlert
(){
gotoAlert
(){
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
'
/pages/SystemAPI/Alert/alert
'
url
:
'
/pages/SystemAPI/Alert/alert
'
...
...
pages/SystemAPI/WifiInfomation/wifiInfomation.vue
0 → 100644
浏览文件 @
b7cdd6c7
<
template
>
<page-head
:title=
"title"
></page-head>
<view
class=
"uni-padding-wrap uni-common-mt"
>
<button
@
tap=
"getLocationPromise"
>
获取定位权限
</button>
<button
@
tap=
"getWifiInfo"
>
获取WiFi信息
</button>
</view>
</
template
>
<
script
>
import
{
getCurrentWifiInfo
,
requestLocationPromise
}
from
'
../../../uni_modules/uni-wifiinformation/utssdk/app-ios/index.uts
'
export
default
{
data
()
{
return
{
title
:
"
获取当前连接wifi信息
"
}
},
methods
:{
getLocationPromise
()
{
requestLocationPromise
((
res
):
void
=>
{
console
.
log
(
res
)
uni
.
showToast
({
title
:
res
[
"
message
"
],
icon
:
'
none
'
})
})
},
getWifiInfo
()
{
/* iOS12之后获取wifi信息需要获取系统定位权限,否则获取到的wifi信息为空 */
requestLocationPromise
((
res
):
void
=>
{
if
(
res
[
"
success
"
]
==
true
)
{
let
wifiInfo
=
getCurrentWifiInfo
()
if
(
wifiInfo
!=
null
)
{
console
.
log
(
wifiInfo
)
uni
.
showToast
({
title
:
"
当前wifi信息获取成功
"
,
icon
:
'
none
'
})
}
}
})
}
}
}
</
script
>
<
style
>
</
style
>
\ No newline at end of file
uni_modules/uni-wifiinformation/changelog.md
0 → 100644
浏览文件 @
b7cdd6c7
uni_modules/uni-wifiinformation/package.json
0 → 100644
浏览文件 @
b7cdd6c7
{
"id"
:
"uni-wifiinformation"
,
"displayName"
:
"uni-wifiinformation"
,
"version"
:
"1.0.0"
,
"description"
:
"uni-wifiinformation"
,
"keywords"
:
[
"uni-wifiinformation"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.8"
},
"dcloudext"
:
{
"type"
:
"uts"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
""
,
"data"
:
""
,
"permissions"
:
""
},
"npmurl"
:
""
},
"uni_modules"
:
{
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"u"
,
"aliyun"
:
"u"
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"u"
,
"vue3"
:
"u"
},
"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-wifiinformation/readme.md
0 → 100644
浏览文件 @
b7cdd6c7
# uni-currentwifiinformation
### 开发文档
[
UTS 语法
](
https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html
)
[
UTS 原生插件
](
https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
)
[
Hello UTS
](
https://gitcode.net/dcloud/hello-uts/-/tree/dev
)
\ No newline at end of file
uni_modules/uni-wifiinformation/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
b7cdd6c7
uni_modules/uni-wifiinformation/utssdk/app-ios/UTS.entitlements
0 → 100644
浏览文件 @
b7cdd6c7
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
com.apple.developer.networking.wifi-info
</key>
<true/>
</dict>
</plist>
uni_modules/uni-wifiinformation/utssdk/app-ios/index.uts
0 → 100644
浏览文件 @
b7cdd6c7
import { CLLocationManager, CLAuthorizationStatus, CLLocationManagerDelegate } from 'CoreLocation';
import { CaptiveNetwork, kCNNetworkInfoKeySSID, kCNNetworkInfoKeyBSSID } from 'SystemConfiguration.CaptiveNetwork';
import { NSArray, NSDictionary } from 'Foundation';
import { CFString } from 'CoreFoundation';
class CurrentWifiInfo {
wifiInterface: string = ""
SSID: string = ""
BSSID: string = ""
constructor(wifiInterface: string, ssid: string, bssid: string) {
this.wifiInterface = wifiInterface
this.SSID = ssid
this.BSSID = bssid
}
}
class LocationPromiseService implements CLLocationManagerDelegate {
static promiseCompletionHandler: UTSCallback[] = []
manager?: CLLocationManager = null
constructor(manager: CLLocationManager | null = null) {
this.manager = manager
}
initlizeManager(): boolean {
if (this.manager == null) {
this.manager = new CLLocationManager()
this.manager!.delegate = this
}
return true
}
locationManager(manager: CLLocationManager, status: CLAuthorizationStatus) {
if (status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse) {
LocationPromiseService.promiseCompletionHandler.forEach((handler): void => {
handler({success : true, message: "authorized success"})
})
} else if (status == CLAuthorizationStatus.notDetermined) {
manager.requestWhenInUseAuthorization()
} else if (status == CLAuthorizationStatus.denied) {
LocationPromiseService.promiseCompletionHandler.forEach((handler): void => {
handler({success : false, message: "user denied"})
})
}
}
requestPromise(completion: UTSCallback) {
let status: CLAuthorizationStatus = CLLocationManager.authorizationStatus()
if (status == CLAuthorizationStatus.notDetermined) {
if (this.initlizeManager() == true) {
this.manager!.requestWhenInUseAuthorization()
LocationPromiseService.promiseCompletionHandler.push(completion)
}
} else if (status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse) {
completion({success : true, message: "authorized success"})
} else if (status == CLAuthorizationStatus.denied) {
if (CLLocationManager.locationServicesEnabled() == false && this.initlizeManager() == true) {
this.manager!.requestWhenInUseAuthorization()
LocationPromiseService.promiseCompletionHandler.push(completion)
}
}
}
}
const locationPromiseService: LocationPromiseService = new LocationPromiseService()
export function requestLocationPromise (completion: UTSCallback) {
locationPromiseService.requestPromise(completion)
}
export function getCurrentWifiInfo (): CurrentWifiInfo | null {
let arr = CNCopySupportedInterfaces()
if (arr != null) {
let list = arr! as NSArray
let wifiInfo = new CurrentWifiInfo("", "", "")
let index = 0
let array = [1, 2, 3]
while (index < list.count) {
let item = list[index]
let interfaceName = item as string
let dic = CNCopyCurrentNetworkInfo(interfaceName as CFString)
if (dic != null) {
let dict = dic! as NSDictionary
let SSID = dict[kCNNetworkInfoKeySSID as string]
let BSSID = dict[kCNNetworkInfoKeyBSSID as string]
if (SSID != null && BSSID != null) {
let ssid = SSID! as string
let bssid = BSSID! as string
wifiInfo.wifiInterface = interfaceName
wifiInfo.SSID = ssid
wifiInfo.BSSID = bssid
break;
}
}
index++
}
if (wifiInfo.BSSID.length > 0 && wifiInfo.SSID.length > 0) {
return wifiInfo
}
}
return null
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录