@mpxjs/api-proxy 2.9.26 → 2.9.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/package.json +2 -2
  2. package/src/common/js/utils.js +5 -1
  3. package/src/platform/api/action-sheet/index.ali.js +3 -2
  4. package/src/platform/api/action-sheet/index.js +1 -3
  5. package/src/platform/api/add-phone-contact/index.ali.js +2 -2
  6. package/src/platform/api/add-phone-contact/index.js +1 -3
  7. package/src/platform/api/animation/index.js +1 -3
  8. package/src/platform/api/app/index.js +1 -3
  9. package/src/platform/api/audio/index.js +1 -3
  10. package/src/platform/api/base/index.js +1 -3
  11. package/src/platform/api/base/index.web.js +1 -1
  12. package/src/platform/api/ble-connection/index.ali.js +5 -3
  13. package/src/platform/api/ble-connection/index.js +1 -3
  14. package/src/platform/api/canvas/index.ali.js +2 -4
  15. package/src/platform/api/canvas/index.js +1 -6
  16. package/src/platform/api/check-session/index.js +1 -3
  17. package/src/platform/api/clipboard-data/index.ali.js +3 -3
  18. package/src/platform/api/clipboard-data/index.js +1 -3
  19. package/src/platform/api/create-intersection-observer/index.ali.js +3 -1
  20. package/src/platform/api/create-intersection-observer/index.js +1 -3
  21. package/src/platform/api/create-selector-query/index.ali.js +8 -4
  22. package/src/platform/api/create-selector-query/index.js +1 -3
  23. package/src/platform/api/device/network/index.js +1 -3
  24. package/src/platform/api/file/index.ali.js +4 -4
  25. package/src/platform/api/file/index.js +1 -3
  26. package/src/platform/api/get-user-info/index.ali.js +2 -2
  27. package/src/platform/api/get-user-info/index.js +1 -3
  28. package/src/platform/api/image/index.ali.js +3 -3
  29. package/src/platform/api/image/index.js +1 -3
  30. package/src/platform/api/lifecycle/index.ali.js +3 -1
  31. package/src/platform/api/lifecycle/index.js +1 -3
  32. package/src/platform/api/login/index.ali.js +2 -2
  33. package/src/platform/api/login/index.js +1 -3
  34. package/src/platform/api/make-phone-call/index.ali.js +2 -2
  35. package/src/platform/api/make-phone-call/index.js +1 -3
  36. package/src/platform/api/modal/index.ali.js +3 -3
  37. package/src/platform/api/modal/index.js +1 -3
  38. package/src/platform/api/next-tick/index.js +1 -3
  39. package/src/platform/api/page-scroll-to/index.js +1 -3
  40. package/src/platform/api/pull-down/index.js +1 -3
  41. package/src/platform/api/request/index.ali.js +4 -4
  42. package/src/platform/api/request/index.js +1 -3
  43. package/src/platform/api/request-payment/index.ali.js +2 -2
  44. package/src/platform/api/request-payment/index.js +1 -3
  45. package/src/platform/api/route/index.js +1 -3
  46. package/src/platform/api/scan-code/index.ali.js +2 -2
  47. package/src/platform/api/scan-code/index.js +1 -3
  48. package/src/platform/api/screen-brightness/index.ali.js +3 -3
  49. package/src/platform/api/screen-brightness/index.js +1 -3
  50. package/src/platform/api/set-navigation-bar/index.ali.js +7 -9
  51. package/src/platform/api/set-navigation-bar/index.js +1 -3
  52. package/src/platform/api/socket/index.js +1 -3
  53. package/src/platform/api/storage/index.ali.js +12 -10
  54. package/src/platform/api/storage/index.js +1 -3
  55. package/src/platform/api/system/index.ali.js +5 -5
  56. package/src/platform/api/system/index.js +1 -3
  57. package/src/platform/api/tab-bar/index.js +1 -3
  58. package/src/platform/api/toast/index.ali.js +5 -5
  59. package/src/platform/api/toast/index.js +1 -3
  60. package/src/platform/api/video/index.js +1 -3
  61. package/src/platform/api/window/index.js +1 -3
  62. package/src/platform/index.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.9.26",
3
+ "version": "2.9.28",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "dependencies": {
40
40
  "axios": "^1.6.7"
41
41
  },
42
- "gitHead": "0abcc7e543b5c4c4af14b2154b78b15c1f571160"
42
+ "gitHead": "d573387d467bb2efb88cca627380627a1d45a4cd"
43
43
  }
@@ -100,6 +100,9 @@ const isBrowser = typeof window !== 'undefined'
100
100
  function throwSSRWarning (info) {
101
101
  console.error(`[Mpx runtime error]: Dangerous API! ${info}, It may cause some problems, please use this method with caution`)
102
102
  }
103
+
104
+ const ENV_OBJ = getEnvObj()
105
+
103
106
  export {
104
107
  changeOpts,
105
108
  handleSuccess,
@@ -111,5 +114,6 @@ export {
111
114
  makeMap,
112
115
  isBrowser,
113
116
  hasOwn,
114
- throwSSRWarning
117
+ throwSSRWarning,
118
+ ENV_OBJ
115
119
  }
@@ -1,4 +1,5 @@
1
- import { changeOpts, noop } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, noop } from '../../../common/js'
2
+
2
3
  function showActionSheet (options = {}) {
3
4
  const opts = changeOpts(options, {
4
5
  itemList: 'items'
@@ -20,7 +21,7 @@ function showActionSheet (options = {}) {
20
21
  }
21
22
  }
22
23
 
23
- my.showActionSheet(opts)
24
+ return ENV_OBJ.showActionSheet(opts)
24
25
  }
25
26
 
26
27
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const showActionSheet = ENV_OBJ.showActionSheet || envError('showActionSheet')
6
4
 
@@ -1,11 +1,11 @@
1
- import { changeOpts } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts } from '../../../common/js'
2
2
 
3
3
  function addPhoneContact (options = {}) {
4
4
  const opts = changeOpts(options, {
5
5
  weChatNumber: 'alipayAccount'
6
6
  })
7
7
 
8
- my.addPhoneContact(opts)
8
+ return ENV_OBJ.addPhoneContact(opts)
9
9
  }
10
10
 
11
11
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const addPhoneContact = ENV_OBJ.addPhoneContact || envError('addPhoneContact')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createAnimation = ENV_OBJ.createAnimation || envError('createAnimation')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const onError = ENV_OBJ.onError || envError('onError')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createInnerAudioContext = ENV_OBJ.createInnerAudioContext || envError('createInnerAudioContext')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const base64ToArrayBuffer = ENV_OBJ.base64ToArrayBuffer || envError('base64ToArrayBuffer')
6
4
 
@@ -1,7 +1,7 @@
1
1
  import { fromByteArray, toByteArray } from './base64'
2
2
 
3
3
  function base64ToArrayBuffer (base64) {
4
- return toByteArray(base64)
4
+ return toByteArray(base64)?.buffer
5
5
  }
6
6
 
7
7
  function arrayBufferToBase64 (arrayBuffer) {
@@ -1,13 +1,15 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function closeBLEConnection (options = {}) {
2
- my.disconnectBLEDevice(options)
4
+ return ENV_OBJ.disconnectBLEDevice(options)
3
5
  }
4
6
 
5
7
  function createBLEConnection (options = {}) {
6
- my.connectBLEDevice(options)
8
+ return ENV_OBJ.connectBLEDevice(options)
7
9
  }
8
10
 
9
11
  function onBLEConnectionStateChange (callback) {
10
- my.onBLEConnectionStateChanged(callback)
12
+ return ENV_OBJ.onBLEConnectionStateChanged(callback)
11
13
  }
12
14
 
13
15
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const closeBLEConnection = ENV_OBJ.closeBLEConnection || envError('closeBLEConnection')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, envError, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, envError, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function canvasToTempFilePath (options = {}) {
4
4
  handleSuccess(options, res => {
@@ -8,13 +8,11 @@ function canvasToTempFilePath (options = {}) {
8
8
  )
9
9
  })
10
10
 
11
- my.canvasToTempFilePath(options)
11
+ return ENV_OBJ.canvasToTempFilePath(options)
12
12
  }
13
- const createCanvasContext = envError('createCanvasContext')
14
13
  const canvasGetImageData = envError('canvasGetImageData')
15
14
 
16
15
  export {
17
- createCanvasContext,
18
16
  canvasToTempFilePath,
19
17
  canvasGetImageData
20
18
  }
@@ -1,15 +1,10 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
4
-
5
- const createCanvasContext = ENV_OBJ.createCanvasContext || envError('createCanvasContext')
1
+ import { ENV_OBJ, envError } from '../../../common/js'
6
2
 
7
3
  const canvasToTempFilePath = ENV_OBJ.canvasToTempFilePath || envError('canvasToTempFilePath')
8
4
 
9
5
  const canvasGetImageData = ENV_OBJ.canvasGetImageData || envError('canvasGetImageData')
10
6
 
11
7
  export {
12
- createCanvasContext,
13
8
  canvasToTempFilePath,
14
9
  canvasGetImageData
15
10
  }
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const checkSession = ENV_OBJ.checkSession || envError('checkSession')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function setClipboardData (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -11,7 +11,7 @@ function setClipboardData (options = {}) {
11
11
  errMsg: 'setClipboardData:ok'
12
12
  })
13
13
  })
14
- my.setClipboard(opts)
14
+ return ENV_OBJ.setClipboard(opts)
15
15
  }
16
16
 
17
17
  function getClipboardData (options = {}) {
@@ -21,7 +21,7 @@ function getClipboardData (options = {}) {
21
21
  return changeOpts(res, { text: 'data' })
22
22
  })
23
23
 
24
- my.getClipboard(opts)
24
+ return ENV_OBJ.getClipboard(opts)
25
25
  }
26
26
 
27
27
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setClipboardData = ENV_OBJ.setClipboardData || envError('setClipboardData')
6
4
 
@@ -1,5 +1,7 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function createIntersectionObserver (component, options = {}) {
2
- return my.createIntersectionObserver(options)
4
+ return ENV_OBJ.createIntersectionObserver(options)
3
5
  }
4
6
 
5
7
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createIntersectionObserver = ENV_OBJ.createIntersectionObserver || envError('createIntersectionObserver')
6
4
 
@@ -1,7 +1,7 @@
1
- import { noop } from '../../../common/js'
1
+ import { ENV_OBJ, noop } from '../../../common/js'
2
2
 
3
3
  function createSelectorQuery (options = {}) {
4
- const selectorQuery = my.createSelectorQuery(options)
4
+ const selectorQuery = ENV_OBJ.createSelectorQuery(options)
5
5
  const proxyMethods = ['boundingClientRect', 'scrollOffset']
6
6
  const cbs = []
7
7
  proxyMethods.forEach((name) => {
@@ -23,8 +23,12 @@ function createSelectorQuery (options = {}) {
23
23
  return originalExec.call(this, cb)
24
24
  }
25
25
 
26
- selectorQuery.in = function () {
27
- return this
26
+ selectorQuery.in = function (_this) {
27
+ if (typeof _this !== 'object' || typeof _this.createSelectorQuery !== 'function') {
28
+ throw new Error('in 方法中,传入的 this 参数不是组件实例')
29
+ }
30
+
31
+ return _this.createSelectorQuery(options)
28
32
  }
29
33
 
30
34
  return selectorQuery
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createSelectorQuery = ENV_OBJ.createSelectorQuery || envError('createSelectorQuery')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../../common/js'
4
2
 
5
3
  const getNetworkType = ENV_OBJ.getNetworkType || envError('getNetworkType')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function downloadFile (options = {}) {
4
4
  const opts = changeOpts(options)
@@ -7,13 +7,13 @@ function downloadFile (options = {}) {
7
7
  return changeOpts(res, { apFilePath: 'tempFilePath' })
8
8
  })
9
9
 
10
- return my.downloadFile(opts)
10
+ return ENV_OBJ.downloadFile(opts)
11
11
  }
12
12
 
13
13
  function uploadFile (options = {}) {
14
14
  const opts = changeOpts(options, { name: 'fileName' })
15
15
 
16
- return my.uploadFile(opts)
16
+ return ENV_OBJ.uploadFile(opts)
17
17
  }
18
18
 
19
19
  function saveFile (options = {}) {
@@ -25,7 +25,7 @@ function saveFile (options = {}) {
25
25
  return changeOpts(res, { apFilePath: 'savedFilePath' })
26
26
  })
27
27
 
28
- my.saveFile(opts)
28
+ return ENV_OBJ.saveFile(opts)
29
29
  }
30
30
 
31
31
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const downloadFile = ENV_OBJ.downloadFile || envError('downloadFile')
6
4
 
@@ -1,4 +1,4 @@
1
- import { warn } from '../../../common/js'
1
+ import { ENV_OBJ, warn } from '../../../common/js'
2
2
 
3
3
  const TIPS_NAME = '支付宝环境 mpx'
4
4
 
@@ -10,7 +10,7 @@ function getUserInfo (options = {}) {
10
10
  warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 中使用 lang 参数`)
11
11
  }
12
12
 
13
- my.getOpenUserInfo(options)
13
+ return ENV_OBJ.getOpenUserInfo(options)
14
14
  }
15
15
 
16
16
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const getUserInfo = ENV_OBJ.getUserInfo || envError('getUserInfo')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function previewImage (options = {}) {
4
4
  const opts = changeOpts(options)
@@ -8,7 +8,7 @@ function previewImage (options = {}) {
8
8
  opts.current = idx !== -1 ? idx : 0
9
9
  }
10
10
 
11
- my.previewImage(opts)
11
+ return ENV_OBJ.previewImage(opts)
12
12
  }
13
13
 
14
14
  function compressImage (options = {}) {
@@ -27,7 +27,7 @@ function compressImage (options = {}) {
27
27
  )
28
28
  })
29
29
 
30
- my.compressImage(opts)
30
+ return ENV_OBJ.compressImage(opts)
31
31
  }
32
32
 
33
33
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const previewImage = ENV_OBJ.previewImage || envError('previewImage')
6
4
 
@@ -1,5 +1,7 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function getEnterOptionsSync () {
2
- return my.getEnterOptionsSync()
4
+ return ENV_OBJ.getEnterOptionsSync()
3
5
  }
4
6
 
5
7
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function login (options = {}) {
4
4
  const opts = changeOpts(options)
@@ -7,7 +7,7 @@ function login (options = {}) {
7
7
  return changeOpts(res, { authCode: 'code' }, { errMsg: 'login:ok' })
8
8
  })
9
9
 
10
- my.getAuthCode(opts)
10
+ return ENV_OBJ.getAuthCode(opts)
11
11
  }
12
12
 
13
13
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const login = ENV_OBJ.login || envError('login')
6
4
 
@@ -1,10 +1,10 @@
1
- import { changeOpts } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts } from '../../../common/js'
2
2
 
3
3
  function makePhoneCall (options = {}) {
4
4
  const opts = changeOpts(options, {
5
5
  phoneNumber: 'number'
6
6
  })
7
- my.makePhoneCall(opts)
7
+ return ENV_OBJ.makePhoneCall(opts)
8
8
  }
9
9
 
10
10
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const makePhoneCall = ENV_OBJ.makePhoneCall || envError('makePhoneCall')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function showModal (options = {}) {
4
4
  let opts
@@ -13,7 +13,7 @@ function showModal (options = {}) {
13
13
  return changeOpts(res, undefined, { cancel: !res.confirm })
14
14
  })
15
15
 
16
- my.confirm(opts)
16
+ return ENV_OBJ.confirm(opts)
17
17
  } else {
18
18
  opts = changeOpts(options, {
19
19
  confirmText: 'buttonText'
@@ -23,7 +23,7 @@ function showModal (options = {}) {
23
23
  return changeOpts(res, undefined, { cancel: false, confirm: true })
24
24
  })
25
25
 
26
- my.alert(opts)
26
+ return ENV_OBJ.alert(opts)
27
27
  }
28
28
  }
29
29
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const showModal = ENV_OBJ.showModal || envError('showModal')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const nextTick = ENV_OBJ.nextTick || envError('nextTick')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const pageScrollTo = ENV_OBJ.pageScrollTo || envError('pageScrollTo')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const stopPullDownRefresh = ENV_OBJ.stopPullDownRefresh || envError('stopPullDownRefresh')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function request (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -14,10 +14,10 @@ function request (options = {}) {
14
14
 
15
15
  // request 在 1.11.0 以上版本才支持
16
16
  // httpRequest 即将被废弃,钉钉端仍需要使用
17
- if (my.canIUse('request')) {
18
- return my.request(opts)
17
+ if (ENV_OBJ.canIUse('request')) {
18
+ return ENV_OBJ.request(opts)
19
19
  } else {
20
- return my.httpRequest(opts)
20
+ return ENV_OBJ.httpRequest(opts)
21
21
  }
22
22
  }
23
23
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const request = ENV_OBJ.request || envError('request')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, error, noop } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, error, noop } from '../../../common/js'
2
2
 
3
3
  const TIPS_NAME = '支付宝环境 mpx'
4
4
 
@@ -37,7 +37,7 @@ function requestPayment (options = {}) {
37
37
  }
38
38
  }
39
39
 
40
- my.tradePay(opts)
40
+ return ENV_OBJ.tradePay(opts)
41
41
  }
42
42
 
43
43
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const requestPayment = ENV_OBJ.requestPayment || envError('requestPayment')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const redirectTo = ENV_OBJ.redirectTo || envError('redirectTo')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function scanCode (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -9,7 +9,7 @@ function scanCode (options = {}) {
9
9
  return changeOpts(res, { code: 'result' })
10
10
  })
11
11
 
12
- my.scan(opts)
12
+ return ENV_OBJ.scan(opts)
13
13
  }
14
14
 
15
15
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const scanCode = ENV_OBJ.scanCode || envError('scanCode')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function setScreenBrightness (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -7,7 +7,7 @@ function setScreenBrightness (options = {}) {
7
7
  handleSuccess(opts, res => {
8
8
  return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
9
9
  })
10
- my.setScreenBrightness(opts)
10
+ return ENV_OBJ.setScreenBrightness(opts)
11
11
  }
12
12
 
13
13
  function getScreenBrightness (options = {}) {
@@ -17,7 +17,7 @@ function getScreenBrightness (options = {}) {
17
17
  return changeOpts(res, { brightness: 'value' }, { errMsg: 'getScreenBrightness:ok' })
18
18
  })
19
19
 
20
- my.getScreenBrightness(opts)
20
+ return ENV_OBJ.getScreenBrightness(opts)
21
21
  }
22
22
 
23
23
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setScreenBrightness = ENV_OBJ.setScreenBrightness || envError('setScreenBrightness')
6
4
 
@@ -1,22 +1,20 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function setNavigationBarTitle (options = {}) {
4
4
  handleSuccess(options, res => {
5
5
  return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
6
6
  })
7
- if (my.canIUse('setNavigationBarTitle')) {
8
- my.setNavigationBarTitle(options)
9
- return
7
+ if (ENV_OBJ.canIUse('setNavigationBarTitle')) {
8
+ return ENV_OBJ.setNavigationBarTitle(options)
10
9
  }
11
- my.setNavigationBar(options)
10
+ return ENV_OBJ.setNavigationBar(options)
12
11
  }
13
12
 
14
13
  function setNavigationBarColor (options = {}) {
15
- if (my.canIUse('setNavigationBarColor')) {
16
- my.setNavigationBarColor(options)
17
- return
14
+ if (ENV_OBJ.canIUse('setNavigationBarColor')) {
15
+ return ENV_OBJ.setNavigationBarColor(options)
18
16
  }
19
- my.setNavigationBar(options)
17
+ return ENV_OBJ.setNavigationBar(options)
20
18
  }
21
19
 
22
20
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setNavigationBarTitle = ENV_OBJ.setNavigationBarTitle || envError('setNavigationBarTitle')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const connectSocket = ENV_OBJ.connectSocket || envError('connectSocket')
6
4
 
@@ -1,48 +1,50 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function setStorage (options) {
2
- my.setStorage(options)
4
+ return ENV_OBJ.setStorage(options)
3
5
  }
4
6
 
5
7
  function setStorageSync (key, data) {
6
- my.setStorageSync({
8
+ return ENV_OBJ.setStorageSync({
7
9
  key,
8
10
  data
9
11
  })
10
12
  }
11
13
 
12
14
  function getStorage (options) {
13
- my.getStorage(options)
15
+ return ENV_OBJ.getStorage(options)
14
16
  }
15
17
 
16
18
  function getStorageSync (key) {
17
- return my.getStorageSync({
19
+ return ENV_OBJ.getStorageSync({
18
20
  key
19
21
  }).data
20
22
  }
21
23
 
22
24
  function getStorageInfo (options) {
23
- return my.getStorageInfo(options)
25
+ return ENV_OBJ.getStorageInfo(options)
24
26
  }
25
27
 
26
28
  function getStorageInfoSync () {
27
- return my.getStorageInfoSync()
29
+ return ENV_OBJ.getStorageInfoSync()
28
30
  }
29
31
 
30
32
  function removeStorage (options) {
31
- return my.removeStorage(options)
33
+ return ENV_OBJ.removeStorage(options)
32
34
  }
33
35
 
34
36
  function removeStorageSync (key) {
35
- my.removeStorageSync({
37
+ return ENV_OBJ.removeStorageSync({
36
38
  key
37
39
  })
38
40
  }
39
41
 
40
42
  function clearStorage (options) {
41
- my.clearStorage(options)
43
+ return ENV_OBJ.clearStorage(options)
42
44
  }
43
45
 
44
46
  function clearStorageSync (options) {
45
- my.clearStorageSync(options)
47
+ return ENV_OBJ.clearStorageSync(options)
46
48
  }
47
49
 
48
50
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setStorage = ENV_OBJ.setStorage || envError('setStorage')
6
4
 
@@ -1,11 +1,11 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function getSystemInfo (options = {}) {
4
4
  const opts = changeOpts(options)
5
5
 
6
6
  handleSuccess(opts, res => {
7
7
  res.system = `${res.platform} ${res.system}`
8
- res.SDKVersion = my.SDKVersion
8
+ res.SDKVersion = ENV_OBJ.SDKVersion
9
9
 
10
10
  // 支付宝 windowHeight 可能为 0
11
11
  if (!res.windowHeight) {
@@ -15,14 +15,14 @@ function getSystemInfo (options = {}) {
15
15
  return res
16
16
  })
17
17
 
18
- my.getSystemInfo(opts)
18
+ return ENV_OBJ.getSystemInfo(opts)
19
19
  }
20
20
 
21
21
  function getSystemInfoSync () {
22
- const res = my.getSystemInfoSync() || {}
22
+ const res = ENV_OBJ.getSystemInfoSync() || {}
23
23
 
24
24
  res.system = `${res.platform} ${res.system}`
25
- res.SDKVersion = my.SDKVersion
25
+ res.SDKVersion = ENV_OBJ.SDKVersion
26
26
 
27
27
  // 支付宝 windowHeight 可能为 0
28
28
  if (!res.windowHeight) {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const getSystemInfo = ENV_OBJ.getSystemInfo || envError('getSystemInfo')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setTabBarItem = ENV_OBJ.setTabBarItem || envError('setTabBarItem')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, warn } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, warn } from '../../../common/js'
2
2
 
3
3
  const TIPS_NAME = '支付宝环境 mpx'
4
4
 
@@ -7,28 +7,28 @@ function showToast (options = {}) {
7
7
  title: 'content',
8
8
  icon: 'type'
9
9
  })
10
- my.showToast(opts)
10
+ return ENV_OBJ.showToast(opts)
11
11
  }
12
12
 
13
13
  function hideToast (options = {}) {
14
14
  if (options.success || options.fail || options.complete) {
15
15
  warn(`${TIPS_NAME}.hideToast 不支持 success/fail/complete 参数`)
16
16
  }
17
- my.hideToast(options)
17
+ return ENV_OBJ.hideToast(options)
18
18
  }
19
19
 
20
20
  function showLoading (options = {}) {
21
21
  const opts = changeOpts(options, {
22
22
  title: 'content'
23
23
  })
24
- my.showLoading(opts)
24
+ return ENV_OBJ.showLoading(opts)
25
25
  }
26
26
 
27
27
  function hideLoading (options = {}) {
28
28
  if (options.success || options.fail || options.complete) {
29
29
  warn(`${TIPS_NAME}.hideLoading 不支持 success/fail/complete 参数`)
30
30
  }
31
- my.hideLoading(options)
31
+ return ENV_OBJ.hideLoading(options)
32
32
  }
33
33
 
34
34
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const showToast = ENV_OBJ.showToast || envError('showToast')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createVideoContext = ENV_OBJ.createVideoContext || envError('createVideoContext')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const onWindowResize = ENV_OBJ.onWindowResize || envError('onWindowResize')
6
4
 
@@ -19,7 +19,7 @@ export * from './api/base'
19
19
  // closeBLEConnection, createBLEConnection, onBLEConnectionStateChange
20
20
  export * from './api/ble-connection'
21
21
 
22
- // createCanvasContext, canvasToTempFilePath, canvasGetImageData
22
+ // canvasToTempFilePath, canvasGetImageData
23
23
  export * from './api/canvas'
24
24
 
25
25
  // checkSession