提交 5a475961 编写于 作者: fxy060608's avatar fxy060608

fix(mp-weixin): wx wrapper

上级 b19a1b9c
const hasOwnProperty = Object.prototype.hasOwnProperty
function hasOwn(obj, key) {
return hasOwnProperty.call(obj, key)
}
function isFn(fn) {
return typeof fn === 'function'
}
const objectKeys = [
'qy',
'env',
......@@ -17,22 +7,24 @@ const objectKeys = [
'cloud',
'serviceMarket',
'router',
'worklet'
'worklet',
]
const oldWx = globalThis[['w', 'x'].join('')]
function isWxKey(key) {
return objectKeys.indexOf(key) > -1 || typeof oldWx[key] === 'function'
}
function initWx() {
const WxProxyHandlers = {
get(target, key) {
if (hasOwn(target, key)) {
return target[key]
}
if (objectKeys.indexOf(key) > -1 || isFn(oldWx[key])) {
return oldWx[key]
const newWx = {}
for (const key in oldWx) {
if (isWxKey(key)) {
// TODO wrapper function
newWx[key] = oldWx[key]
}
}
}
return new Proxy({}, WxProxyHandlers)
return newWx
}
const wxProxy = initWx()
globalThis[['w', 'x'].join('')] = wxProxy
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册