protocols.js 3.4 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
  'createCameraContext',
  'createLivePlayerContext',
  'getSavedFileInfo',
  'createMapContext',
  'onMemoryWarning',
  'onGyroscopeChange',
  'startGyroscope',
  'stopGyroscope',
  'setScreenBrightness',
  'getScreenBrightness',
  '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 已提交
52 53 54 55 56 57 58 59
  'chooseInvoiceTitle',
  'addTemplate',
  'deleteTemplate',
  'getTemplateLibraryById',
  'getTemplateLibraryList',
  'getTemplateList',
  'sendTemplateMessage',
  'setEnableDebug',
X
xiaoyucoding 已提交
60
  'onWindowResize',
61
  'offWindowResize',
W
wangyaqi 已提交
62 63
  'createOffscreenCanvas',
  'vibrate'
64 65
]

66
// 存在兼容性的 API 列表
雪洛's avatar
雪洛 已提交
67
// 头条小程序自1.35.0+支持canIUses
68
const canIUses = [
fxy060608's avatar
fxy060608 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82
  // 'createIntersectionObserver',
  // 'getSavedFileList',
  // 'removeSavedFile',
  // 'hideKeyboard',
  // 'getImageInfo',
  // 'createVideoContext',
  // 'onSocketOpen',
  // 'onSocketError',
  // 'sendSocketMessage',
  // 'onSocketMessage',
  // 'closeSocket',
  // 'onSocketClose',
  // 'getExtConfig',
  // 'getExtConfigSync',
雪洛's avatar
雪洛 已提交
83 84 85 86 87 88 89
  // 'navigateToMiniProgram',
  // 'navigateBackMiniProgram',
  // 'compressImage',
  // 'chooseLocation',
  // 'openDocument',
  // 'onUserCaptureScreen',
  // 'getBackgroundAudioManager',
90
]
91

92
// 需要做转换的 API 列表
X
xiaoyucoding 已提交
93 94 95 96 97 98
const protocols = {
  chooseImage: {
    args: {
      sizeType: false
    }
  },
99
  previewImage,
X
xiaoyucoding 已提交
100 101 102 103 104 105 106
  connectSocket: {
    args: {
      method: false
    }
  },
  chooseVideo: {
    args: {
107
      camera: false
X
xiaoyucoding 已提交
108 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
    }
  },
  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: {
156 157 158 159 160 161 162 163
    args: {
      orderInfo: 'data'
    }
  },
  getFileInfo: {
    args: {
      digestAlgorithm: false
    }
X
xiaoyucoding 已提交
164 165
  }
}
166

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