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..f09eda38814f 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, @@ -1979,7 +1973,7 @@ "resultJSONSignature": true } }, - "startWifi": true, + "startWifi": false, "stopAccelerometer": true, "stopBackgroundAudio": false, "stopBeaconDiscovery": false, @@ -1994,7 +1988,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 index 7a2c89580b91..adf39e939608 100644 --- 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 @@ -1,80 +1,6 @@ -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] + * @canNotUse connectWifi */ -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 }) - }, - }) - }) -} +export { connectWifi } from '@tarojs/taro-h5' \ No newline at end of file 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 index 160779d6694c..a81d21f33cbe 100644 --- 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 @@ -1,33 +1,6 @@ -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 + * @canNotUse 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 }) - }, - }) - }) -} +export { getWifiList } from '@tarojs/taro-h5' \ No newline at end of file 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 index f86ceda9cea0..55c0c091327e 100644 --- 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 @@ -1,33 +1,6 @@ -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 + * @canNotUse 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 }) - }, - }) - }) -} +export { startWifi } from '@tarojs/taro-h5' \ No newline at end of file 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 index 6032cfb0198e..4c56ede1bdbb 100644 --- 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 @@ -1,33 +1,6 @@ -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 + * @canNotUse 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 }) - }, - }) - }) -} +export { stopWifi } from '@tarojs/taro-h5' \ No newline at end of file