Skip to content

Commit

Permalink
fix(mp): 修复4.41引发的小程序端部分uni.xxx方法不能调用的Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangyaqi committed Jan 2, 2025
1 parent 6078fb4 commit 96ba741
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions packages/uni-mp-core/src/api/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,14 @@ export function initWrapper(protocols: MPProtocols) {
)
}
return function wrapper(methodName: string, method: unknown) {
if ((isContextApi(methodName) || isTaskApi(methodName)) && method) {
const oldMethod = method as Function
method = function (this: any, ...args: unknown[]) {
const contextOrTask = oldMethod.apply(this, args)
if (contextOrTask) {
contextOrTask.__v_skip = true
}
return contextOrTask
}
}
if (
(!hasOwn(protocols, methodName) && !isFunction(protocols.returnValue)) ||
!isFunction(method)
) {
/**
* 注意:此处method为原始全局对象上的uni方法名对应的属性值,比如method值可能为my.login,即undefined
*/
if (!hasOwn(protocols, methodName) && !isFunction(protocols.returnValue)) {
return method
}
const protocol = protocols[methodName] as MPProtocolObject
if (!protocol && !isFunction(protocols.returnValue)) {
if (!protocol && !method) {
// 暂不支持的 api
return function () {
console.error(`__PLATFORM_TITLE__ 暂不支持${methodName}`)
Expand Down

0 comments on commit 96ba741

Please sign in to comment.