1
2
3
4
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
| const objectKeys = [
| 'qy',
| 'env',
| 'error',
| 'version',
| 'lanDebug',
| 'cloud',
| 'serviceMarket',
| 'router',
| 'worklet',
| '__webpack_require_UNI_MP_PLUGIN__'
| ]
| const singlePageDisableKey = [
| 'lanDebug',
| 'router',
| 'worklet'
| ]
| const target = typeof globalThis !== 'undefined' ? globalThis : (function () {
| return this
| })()
|
| const key = ['w', 'x'].join('')
| const oldWx = target[key]
| const launchOption = oldWx.getLaunchOptionsSync ? oldWx.getLaunchOptionsSync() : null
|
| function isWxKey (key) {
| if (launchOption && launchOption.scene === 1154 && singlePageDisableKey.includes(key)) {
| return false
| }
| return objectKeys.indexOf(key) > -1 || typeof oldWx[key] === 'function'
| }
|
| function initWx () {
| const newWx = {}
| for (const key in oldWx) {
| if (isWxKey(key)) {
| // TODO wrapper function
| newWx[key] = oldWx[key]
| }
| }
| return newWx
| }
| target[key] = initWx()
| export default target[key]
|
|