protocols.js 3.3 KB
Newer Older
1
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
fxy060608's avatar
fxy060608 已提交
2

3
// 不支持的 API 列表
4
const todos = [
X
xiaoyucoding 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  'getBackgroundAudioManager',
  'createCameraContext',
  'createLivePlayerContext',
  'getSavedFileInfo',
  'openDocument',
  'chooseLocation',
  'createMapContext',
  'canIUse',
  'onMemoryWarning',
  'onGyroscopeChange',
  'startGyroscope',
  'stopGyroscope',
  'setScreenBrightness',
  'getScreenBrightness',
  'onUserCaptureScreen',
  'addPhoneContact',
  'openBluetoothAdapter',
  'startBluetoothDevicesDiscovery',
  'onBluetoothDeviceFound',
  'stopBluetoothDevicesDiscovery',
  'onBluetoothAdapterStateChange',
  'getConnectedBluetoothDevices',
  'getBluetoothDevices',
  'getBluetoothAdapterState',
  'closeBluetoothAdapter',
  'writeBLECharacteristicValue',
  'readBLECharacteristicValue',
  'onBLEConnectionStateChange',
  'onBLECharacteristicValueChange',
  'notifyBLECharacteristicValueChange',
  'getBLEDeviceServices',
  'getBLEDeviceCharacteristics',
  'createBLEConnection',
  'closeBLEConnection',
  'onBeaconServiceChange',
  'onBeaconUpdate',
  'getBeacons',
  'startBeaconDiscovery',
  'stopBeaconDiscovery',
  'setNavigationBarColor',
  'showNavigationBarLoading',
  'hideNavigationBarLoading',
  'setTabBarItem',
  'setTabBarStyle',
  'hideTabBar',
  'showTabBar',
  'setTabBarBadge',
  'removeTabBarBadge',
  'showTabBarRedDot',
  'hideTabBarRedDot',
  'setBackgroundColor',
  'setBackgroundTextStyle',
X
xiaoyucoding 已提交
57 58 59 60 61 62 63 64 65 66
  'chooseInvoiceTitle',
  'navigateToMiniProgram',
  'navigateBackMiniProgram',
  'addTemplate',
  'deleteTemplate',
  'getTemplateLibraryById',
  'getTemplateLibraryList',
  'getTemplateList',
  'sendTemplateMessage',
  'setEnableDebug',
X
xiaoyucoding 已提交
67
  'onWindowResize',
68 69
  'offWindowResize',
  'compressImage',
W
wangyaqi 已提交
70 71
  'createOffscreenCanvas',
  'vibrate'
72 73
]

74
// 存在兼容性的 API 列表
75 76
// 头条小程序不支持canIUses
const canIUses = [
fxy060608's avatar
fxy060608 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90
  // 'createIntersectionObserver',
  // 'getSavedFileList',
  // 'removeSavedFile',
  // 'hideKeyboard',
  // 'getImageInfo',
  // 'createVideoContext',
  // 'onSocketOpen',
  // 'onSocketError',
  // 'sendSocketMessage',
  // 'onSocketMessage',
  // 'closeSocket',
  // 'onSocketClose',
  // 'getExtConfig',
  // 'getExtConfigSync',
91
]
92

93
// 需要做转换的 API 列表
X
xiaoyucoding 已提交
94 95 96 97 98 99
const protocols = {
  chooseImage: {
    args: {
      sizeType: false
    }
  },
100
  previewImage,
X
xiaoyucoding 已提交
101 102 103 104 105 106 107
  connectSocket: {
    args: {
      method: false
    }
  },
  chooseVideo: {
    args: {
108
      camera: false
X
xiaoyucoding 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
    }
  },
  scanCode: {
    args: {
      onlyFromCamera: false,
      scanType: false
    }
  },
  startAccelerometer: {
    args: {
      interval: false
    }
  },
  showToast: {
    args: {
      image: false,
      mask: false
    }
  },
  showLoading: {
    args: {
      mask: false
    }
  },
  showModal: {
    args: {
      cancelColor: false,
      confirmColor: false
    }
  },
  showActionSheet: {
    args: {
      itemColor: false
    }
  },
  login: {
    args: {
      scopes: false,
      timeout: false
    }
  },
  getUserInfo: {
    args: {
      lang: false,
      timeout: false
    }
  },
  requestPayment: {
157 158 159 160 161 162 163 164
    args: {
      orderInfo: 'data'
    }
  },
  getFileInfo: {
    args: {
      digestAlgorithm: false
    }
X
xiaoyucoding 已提交
165 166
  }
}
167

168 169 170 171 172
export {
  protocols,
  todos,
  canIUses
}