From 08ac81fa2b98ff158bbf41f0229a55d000e72464 Mon Sep 17 00:00:00 2001 From: licunhao1 <1441249604@qq.com> Date: Wed, 19 Jun 2024 10:39:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=83=A8=E5=88=86API=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=BB=A7=E6=89=BF?= =?UTF-8?q?h5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/api/device/wifi/index.tsx | 1 + .../build/config/harmony-definition.json | 22 ++--- .../src/api/apis/device/wifi/connectWifi.ts | 80 ------------------- .../src/api/apis/device/wifi/getWifiList.ts | 33 -------- .../src/api/apis/device/wifi/index.ts | 4 - .../src/api/apis/device/wifi/startWifi.ts | 33 -------- .../src/api/apis/device/wifi/stopWifi.ts | 33 -------- 7 files changed, 6 insertions(+), 200 deletions(-) delete mode 100644 packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/connectWifi.ts delete mode 100644 packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/getWifiList.ts delete mode 100644 packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/startWifi.ts delete mode 100644 packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/stopWifi.ts diff --git a/examples/mini-program-example/src/pages/api/device/wifi/index.tsx b/examples/mini-program-example/src/pages/api/device/wifi/index.tsx index 1d574a0e69f8..bc846359b63f 100644 --- a/examples/mini-program-example/src/pages/api/device/wifi/index.tsx +++ b/examples/mini-program-example/src/pages/api/device/wifi/index.tsx @@ -160,6 +160,7 @@ export default class Index extends React.Component { password: 'lwh123456', }, func: (apiIndex, data) => { + TestConsole.consoleTest('connectWifi') Taro.connectWifi({ ...data, success: (res) => { diff --git a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json index bf7c604d102d..0fb07aec6f0c 100644 --- a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json +++ b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json @@ -667,13 +667,7 @@ "tcpNoDelay": true } }, - "connectWifi": { - "object": { - "SSID": true, - "password": true, - "BSSID": true - } - }, + "connectWifi": false, "console": { "debug": true, "error": true, @@ -1237,7 +1231,7 @@ } }, "getWeRunData": false, - "getWifiList": true, + "getWifiList": false, "getWindowInfo": { "return": { "pixelRatio": true, @@ -1331,13 +1325,7 @@ } }, "navigateToBookshelf": false, - "navigateToMiniProgram": { - "object": { - "appId": true, - "path": true, - "extraData": true - } - }, + "navigateToMiniProgram": false, "nextTick": true, "notifyBLECharacteristicValueChange": { "object": { @@ -1979,7 +1967,7 @@ "resultJSONSignature": true } }, - "startWifi": true, + "startWifi": false, "stopAccelerometer": true, "stopBackgroundAudio": false, "stopBeaconDiscovery": false, @@ -1994,7 +1982,7 @@ "stopPullDownRefresh": true, "stopRecord": false, "stopVoice": false, - "stopWifi": true, + "stopWifi": false, "subscribeService": false, "subscribeVoIPVideoMembers": false, "switchTab": { diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/connectWifi.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/connectWifi.ts deleted file mode 100644 index 7a2c89580b91..000000000000 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/connectWifi.ts +++ /dev/null @@ -1,80 +0,0 @@ -import Taro from '@tarojs/taro' -import { getParameterError, shouldBeObject } from 'src/api/apis/utils' -import { MethodHandler } from 'src/api/apis/utils/handler' - -import nativeWifi from './NativeWifi' - -/** - * 连接 Wi-Fi - * - * @canUse connectWifi - * @__object [SSID, password, BSSID] - */ -export const connectWifi: typeof Taro.connectWifi = (options) => { - const name = 'connectWifi' - - return new Promise((resolve, reject) => { - // options must be an Object - const isObject = shouldBeObject(options) - if (!isObject.flag) { - const res = { errMsg: `${name}:fail ${isObject.msg}` } - console.error(res.errMsg) - return reject(res) - } - const { SSID, password, BSSID, success, fail, complete } = options as Exclude - - const handle = new MethodHandler({ name, success, fail, complete }) - - // options.SSID must be string - if (typeof SSID !== 'string') { - return handle.fail( - { - errMsg: getParameterError({ - para: 'SSID', - correct: 'string', - wrong: SSID, - }), - }, - { resolve, reject } - ) - } - - if (typeof password !== 'string') { - return handle.fail( - { - errMsg: getParameterError({ - para: 'password', - correct: 'string', - wrong: password, - }), - }, - { resolve, reject } - ) - } - - if (typeof BSSID !== 'string') { - return handle.fail( - { - errMsg: getParameterError({ - para: 'BSSID', - correct: 'string', - wrong: BSSID, - }), - }, - { resolve, reject } - ) - } - - nativeWifi.connectWifi({ - SSID: SSID, - password: password, - BSSID: BSSID, - success: (res: any) => { - handle.success(res, { resolve, reject }) - }, - fail: (err: any) => { - handle.fail(err, { resolve, reject }) - }, - }) - }) -} diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/getWifiList.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/getWifiList.ts deleted file mode 100644 index 160779d6694c..000000000000 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/getWifiList.ts +++ /dev/null @@ -1,33 +0,0 @@ -import Taro from '@tarojs/taro' -import { shouldBeObject } from 'src/api/apis/utils' -import { MethodHandler } from 'src/api/apis/utils/handler' - -import nativeWifi from './NativeWifi' - -/** - * 请求获取 Wi-Fi 列表 - * - * @canUse getWifiList - */ -export const getWifiList: typeof Taro.getWifiList = (options) => { - const name = 'getWifiList' - const isValid = shouldBeObject(options).flag || typeof options === 'undefined' - if (!isValid) { - const res = { errMsg: `${name}:fail invalid params` } - console.error(res.errMsg) - return Promise.reject(res) - } - const { success, fail, complete } = options || {} - const handle = new MethodHandler({ name, success, fail, complete }) - - return new Promise((resolve, reject) => { - nativeWifi.getWifiList({ - success: (res: any) => { - handle.success(res, { resolve, reject }) - }, - fail: (err: any) => { - handle.fail(err, { resolve, reject }) - }, - }) - }) -} diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/index.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/index.ts index 6e96662f2ce1..d42a89906780 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/index.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/index.ts @@ -1,14 +1,10 @@ -export * from './connectWifi' export * from './getConnectedWifi' -export * from './getWifiList' export * from './offGetWifiList' export * from './offWifiConnected' export * from './offWifiConnectedWithPartialInfo' export * from './onGetWifiList' export * from './onWifiConnected' export * from './onWifiConnectedWithPartialInfo' -export * from './startWifi' -export * from './stopWifi' /** * Wifi 信息(native 返回) diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/startWifi.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/startWifi.ts deleted file mode 100644 index f86ceda9cea0..000000000000 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/startWifi.ts +++ /dev/null @@ -1,33 +0,0 @@ -import Taro from '@tarojs/taro' -import { shouldBeObject } from 'src/api/apis/utils' -import { MethodHandler } from 'src/api/apis/utils/handler' - -import nativeWifi from './NativeWifi' - -/** - * 初始化 Wi-Fi 模块 - * - * @canUse startWifi - */ -export const startWifi: typeof Taro.startWifi = (options) => { - const name = 'startWifi' - const isValid = shouldBeObject(options).flag || typeof options === 'undefined' - if (!isValid) { - const res = { errMsg: `${name}:fail invalid params` } - console.error(res.errMsg) - return Promise.reject(res) - } - const { success, fail, complete } = options || {} - const handle = new MethodHandler({ name, success, fail, complete }) - - return new Promise((resolve, reject) => { - nativeWifi.startWifi({ - success: (res: any) => { - handle.success(res, { resolve, reject }) - }, - fail: (err: any) => { - handle.fail(err, { resolve, reject }) - }, - }) - }) -} diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/stopWifi.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/stopWifi.ts deleted file mode 100644 index 6032cfb0198e..000000000000 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/device/wifi/stopWifi.ts +++ /dev/null @@ -1,33 +0,0 @@ -import Taro from '@tarojs/taro' -import { shouldBeObject } from 'src/api/apis/utils' -import { MethodHandler } from 'src/api/apis/utils/handler' - -import nativeWifi from './NativeWifi' - -/** - * 关闭 Wi-Fi 模块 - * - * @canUse stopWifi - */ -export const stopWifi: typeof Taro.stopWifi = (options) => { - const name = 'stopWifi' - const isValid = shouldBeObject(options).flag || typeof options === 'undefined' - if (!isValid) { - const res = { errMsg: `${name}:fail invalid params` } - console.error(res.errMsg) - return Promise.reject(res) - } - const { success, fail, complete } = options || {} - const handle = new MethodHandler({ name, success, fail, complete }) - - return new Promise((resolve, reject) => { - nativeWifi.stopWifi({ - success: (res: any) => { - handle.success(res, { resolve, reject }) - }, - fail: (err: any) => { - handle.fail(err, { resolve, reject }) - }, - }) - }) -}