Skip to content

Commit

Permalink
fix(api): 对齐 API 分类
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Dec 15, 2021
1 parent 46191da commit 77cf97a
Show file tree
Hide file tree
Showing 34 changed files with 64 additions and 76 deletions.
4 changes: 4 additions & 0 deletions packages/taro-h5/src/api/ad/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { temporarilyNotSupport } from '../utils'

export const createRewardedVideoAd = temporarilyNotSupport('createRewardedVideoAd')
export const createInterstitialAd = temporarilyNotSupport('createInterstitialAd')
5 changes: 5 additions & 0 deletions packages/taro-h5/src/api/base/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { temporarilyNotSupport } from '../utils'

export const setEnableDebug = temporarilyNotSupport('setEnableDebug')
export const getRealtimeLogManager = temporarilyNotSupport('getRealtimeLogManager')
export const getLogManager = temporarilyNotSupport('getLogManager')
12 changes: 12 additions & 0 deletions packages/taro-h5/src/api/base/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { fromByteArray, toByteArray } from 'base64-js'
import { temporarilyNotSupport } from '../utils'

export const canIUse = temporarilyNotSupport('canIUse')

export function arrayBufferToBase64 (arrayBuffer) {
return fromByteArray(arrayBuffer)
}

export function base64ToArrayBuffer (base64) {
return toByteArray(base64)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getSystemInfo, getSystemInfoSync } from './info'
import { getNetworkType, onNetworkStatusChange } from './network'
import { processOpenApi } from '../utils'
import { processOpenApi } from '../../utils'

export const scanCode = processOpenApi('scanQRCode', { needResult: 1 }, res => ({
errMsg: res.errMsg === 'scanQRCode:ok' ? 'scanCode:ok' : res.errMsg,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { CallbackManager, MethodHandler } from '../utils/handler'
import { CallbackManager, MethodHandler } from '../../utils/handler'

const callbackManager = new CallbackManager()
let devicemotionListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import Taro from '@tarojs/api'
import { setStorage, setStorageSync, getStorageSync } from '../storage/index'
import { MethodHandler } from '../utils/handler'
import { setStorage, setStorageSync, getStorageSync } from '../../storage/index'
import { MethodHandler } from '../../utils/handler'

const CLIPBOARD_STORAGE_NAME = 'taro_clipboard'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { CallbackManager, MethodHandler } from '../utils/handler'
import { CallbackManager, MethodHandler } from '../../utils/handler'

const callbackManager = new CallbackManager()
let compassListener
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { CallbackManager, MethodHandler } from '../utils/handler'
import { CallbackManager, MethodHandler } from '../../utils/handler'

const callbackManager = new CallbackManager()
let deviceMotionListener
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { MethodHandler } from '../utils/handler'
import { MethodHandler } from '../../utils/handler'

const vibrator = function vibrator (mm) {
try {
Expand Down
64 changes: 22 additions & 42 deletions packages/taro-h5/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,58 @@
export * from './unsupportedApi'

/* 已实现api */
// export * from './ad'
// "api/base/index.d.ts"
// "api/base/debug.d.ts"
export * from './system'
// "api/base/system.d.ts"
export * from './ad'
export * from './base'
export * from './base/debug'
export * from './base/system'
// "api/base/update.d.ts"
// "api/base/weapp/life-cycle.d.ts"
// "api/base/weapp/app-event.d.ts"
// "api/base/env.d.ts"
export * from './canvas'
// "api/canvas/index.d.ts"
// "api/cloud/index.d.ts"
// "api/data-analysis/index.d.ts"
// "api/device/accelerometer.d.ts"
export * from './accelerometer'
export * from './device/accelerometer'
// "api/device/battery.d.ts"
// "api/device/ble.d.ts"
// "api/device/bluetooth.d.ts"
export * from './clipboard'
// "api/device/clipboard.d.ts"
export * from './compass'
// "api/device/compass.d.ts"
export * from './device/clipboard'
export * from './device/compass'
// "api/device/contact.d.ts"
// "api/device/gyroscope.d.ts"
// "api/device/iBeacon.d.ts"
export * from './deviceMotion'
// "api/device/motion.d.ts"
export * from './device/motion'
// "api/device/network.d.ts"
// "api/device/nfc.d.ts"
// "api/device/performance.d.ts"
// "api/device/phone.d.ts"
// "api/device/scan.d.ts"
// "api/device/screen.d.ts"
export * from './vibrate'
export * from './device/vibrate'
// "api/device/vibrate.d.ts"
// "api/device/wifi.d.ts"
// "api/ext/index.d.ts"
export * from './fileTransfer'
// "api/files/index.d.ts"
// "api/framework/index.d.ts"
export * from './location'
// "api/location/index.d.ts"
export * from './audio'
// "api/media/audio.d.ts"
export * from './media/audio'
// "api/media/background-audio.d.ts"
// "api/media/camera.d.ts"
// "api/media/editor.d.ts"
export * from './image'
// "api/media/image.d.ts"
export * from './media/image'
// "api/media/live.d.ts"
// "api/media/map.d.ts"
// "api/media/recorder.d.ts"
export * from './video'
// "api/media/video.d.ts"
export * from './media/video'
// "api/media/video-processing.d.ts"
// "api/network/download.d.ts"
// "api/network/mdns.d.ts"
export * from './request'
// "api/network/request.d.ts"
export * from './network/request'
// "api/network/udp.d.ts"
// "api/network/upload.d.ts"
export * from './webSocket'
// "api/network/websocket.d.ts"
export * from './open'
export * from './network/websocket'
export * from './open-api'
// "api/open-api/account.d.ts"
// "api/open-api/address.d.ts"
// "api/open-api/authorize.d.ts"
Expand All @@ -85,31 +73,23 @@ export * from './open'
// "api/share/index.d.ts"
// "api/storage/background-fetch.d.ts"
export * from './storage'
// "api/storage/index.d.ts"
export * from './createAnimation'
// "api/ui/animation.d.ts"
export * from './ui/animation'
// "api/ui/background.d.ts"
// "api/ui/custom-component.d.ts"
// "api/ui/fonts.d.ts"
// "api/ui/keyboard.d.ts"
// "api/ui/menu.d.ts"
export * from './navigationBar'
// "api/ui/navigation-bar.d.ts"
export * from './pullDownRefresh'
// "api/ui/pull-down-refresh.d.ts"
export * from './ui/navigation-bar'
export * from './ui/pull-down-refresh'
export * from './scroll'
// "api/ui/scroll.d.ts"
// "api/ui/sticky.d.ts"
export * from './tabBar'
// "api/ui/tab-bar.d.ts"
export * from './window'
// "api/ui/window.d.ts"
export * from './interactive'
// "api/ui/interaction.d.ts"
export * from './ui/tab-bar'
export * from './ui/window'
export * from './ui/interaction'
// "api/worker/index.d.ts"
// "api/wxml/index.d.ts"
export * from './wxml'

// "api/alipay/index.d.ts"
// "api/swan/index.d.ts"
export * from './createSelectorQuery'
export * from './others'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { CallbackManager } from '../utils/handler'
import { CallbackManager } from '../../utils/handler'

class InnerAudioContext implements Taro.InnerAudioContext {
Instance?: HTMLAudioElement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shouldBeObject, getParameterError } from '../utils/odd'
import { shouldBeObject, getParameterError } from '../../utils/odd'

/**
* 从本地相册选择图片或使用相机拍照。
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shouldBeObject, getParameterError, findDOM } from '../utils/odd'
import { shouldBeObject, getParameterError, findDOM } from '../../utils/odd'

/**
* @typedef {Object} ChooseVideoParam
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Taro from '@tarojs/api'
import 'whatwg-fetch'
import jsonpRetry from 'jsonp-retry'
import { serializeParams } from '../utils/odd'
import { serializeParams } from '../../utils/odd'
const { Link } = Taro

function generateRequestUrlWithParams (url, params) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SocketTask from './socketTask'
import { shouldBeObject, getParameterError } from '../utils/odd'
import { shouldBeObject, getParameterError } from '../../utils/odd'

let socketTasks = []
let socketsCounter = 1
Expand Down
File renamed without changes.
9 changes: 0 additions & 9 deletions packages/taro-h5/src/api/others/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import { fromByteArray, toByteArray } from 'base64-js'
import { shouldBeObject, getParameterError } from '../utils/odd'

export function arrayBufferToBase64 (arrayBuffer) {
return fromByteArray(arrayBuffer)
}

export function base64ToArrayBuffer (base64) {
return toByteArray(base64)
}

export function makePhoneCall (options) {
// options must be an Object
const isObject = shouldBeObject(options)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inlineStyle, setTransform } from '../utils/odd'
import { inlineStyle, setTransform } from '../../utils/odd'

const noop = function () {}
export default class ActionSheet {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { errorHandler, getParameterError } from '../utils/odd'
import { errorHandler, getParameterError } from '../../utils/odd'
import Toast from './toast'
import Modal from './modal'
import ActionSheet from './actionSheet'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inlineStyle } from '../utils/odd'
import { inlineStyle } from '../../utils/odd'

const noop = function () {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inlineStyle } from '../utils/odd'
import { inlineStyle } from '../../utils/odd'

const noop = function () {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shouldBeObject, getParameterError } from '../utils/odd'
import { shouldBeObject, getParameterError } from '../../utils/odd'

export function setNavigationBarTitle (options) {
// options must be an Object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { MethodHandler } from '../utils/handler'
import { MethodHandler } from '../../utils/handler'
/**
* 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Taro, { AppConfig } from '@tarojs/api'
import { shouldBeObject, getParameterError, isValidColor } from '../utils'
import { MethodHandler } from '../utils/handler'
import { shouldBeObject, getParameterError, isValidColor } from '../../utils'
import { MethodHandler } from '../../utils/handler'

let tabConf

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/api'
import { CallbackManager } from '../utils/handler'
import { CallbackManager } from '../../utils/handler'

const callbackManager = new CallbackManager()

Expand Down
4 changes: 0 additions & 4 deletions packages/taro-h5/src/api/unsupportedApi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const onWifiConnected = temporarilyNotSupport('onWifiConnected')
// export const clearStorageSync = temporarilyNotSupport('clearStorageSync')
// export const getSystemInfoSync = temporarilyNotSupport('getSystemInfoSync')
export const getExtConfigSync = temporarilyNotSupport('getExtConfigSync')
export const getLogManager = temporarilyNotSupport('getLogManager')
export const onMemoryWarning = temporarilyNotSupport('onMemoryWarning')
export const reportAnalytics = temporarilyNotSupport('reportAnalytics')
export const navigateToSmartGameProgram = temporarilyNotSupport('navigateToSmartGameProgram')
Expand Down Expand Up @@ -57,7 +56,6 @@ export const createLivePusherContext = temporarilyNotSupport('createLivePusherCo
export const createMapContext = temporarilyNotSupport('createMapContext')

// 设备
export const canIUse = temporarilyNotSupport('canIUse')
// export const startAccelerometer = temporarilyNotSupport('startAccelerometer')
// export const stopAccelerometer = temporarilyNotSupport('stopAccelerometer')
// export const startCompass = temporarilyNotSupport('startCompass')
Expand Down Expand Up @@ -247,8 +245,6 @@ export const startSoterAuthentication = temporarilyNotSupport('startSoterAuthent
export const checkIsSoterEnrolledInDevice = temporarilyNotSupport('checkIsSoterEnrolledInDevice')
export const exitMiniProgram = temporarilyNotSupport('exitMiniProgram')

export const setEnableDebug = temporarilyNotSupport('setEnableDebug')

// 百度小程序专有 API
// 百度小程序 AI 相关
export const ocrIdCard = temporarilyNotSupport('ocrIdCard')
Expand Down
File renamed without changes.

0 comments on commit 77cf97a

Please sign in to comment.