Skip to content

Commit

Permalink
fix(mp-weixin): 单页模式访问wx部分属性报错
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyuWang committed Jan 30, 2023
1 parent 70041fb commit 114d06d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/uni-mp-weixin/dist/wx.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ const objectKeys = [
'router',
'worklet',
]

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()

function isWxKey(key) {
if (launchOption.scene === 1154 && singlePageDisableKey.includes(key)) {
return false
}
return objectKeys.indexOf(key) > -1 || typeof oldWx[key] === 'function'
}

Expand All @@ -32,4 +40,4 @@ function initWx() {
return newWx
}
target[key] = initWx()
export default target[key]
export default target[key]

0 comments on commit 114d06d

Please sign in to comment.