Skip to content

Commit

Permalink
fix(alipay): 修复调用部分api未正确获取返回值的问题, fix #11703 (#11714)
Browse files Browse the repository at this point in the history
* fix(alipay): 修复调用部分api未正确获取返回值的问题, fix #11703

* test(alipay): update snapshot

Co-authored-by: chenjiajian <[email protected]>
  • Loading branch information
AdvancedCat and Chen-jj authored Apr 25, 2022
1 parent 823b13d commit 4c4c1e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
13 changes: 8 additions & 5 deletions packages/taro-alipay/src/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ const apiDiff = {
alias: 'disconnectBLEDevice'
}
}

/**
* 抹平API返回值的差异
* key 为 alipay小程序中的api名称
*/
const asyncResultApiDiff = {
getScreenBrightness: {
res: {
Expand Down Expand Up @@ -426,7 +429,7 @@ export function modifyApis (apis: Set<string>) {
apis.delete('alert')
}

export function modifyAsyncResult (key, res) {
export function modifyAsyncResult (key: string, res) {
if (key === 'connectSocket') {
res.onClose = function (cb) {
my.onSocketClose(cb)
Expand All @@ -453,9 +456,9 @@ export function modifyAsyncResult (key, res) {
}
}

Object.keys(asyncResultApiDiff).forEach(item => {
const apiItem = apiDiff[item]
if (key !== item) {
Object.keys(asyncResultApiDiff).forEach(apiKey => {
const apiItem = asyncResultApiDiff[apiKey]
if (key !== apiKey) {
return
}
if (!apiItem.res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ require(\\"./taro\\");
my.closeSocket();
};
}
Object.keys(asyncResultApiDiff).forEach((function(item) {
var apiItem = apiDiff[item];
if (key !== item) {
Object.keys(asyncResultApiDiff).forEach((function(apiKey) {
var apiItem = asyncResultApiDiff[apiKey];
if (key !== apiKey) {
return;
}
if (!apiItem.res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ require(\\"./taro\\");
my.closeSocket();
};
}
Object.keys(asyncResultApiDiff).forEach((function(item) {
var apiItem = apiDiff[item];
if (key !== item) {
Object.keys(asyncResultApiDiff).forEach((function(apiKey) {
var apiItem = asyncResultApiDiff[apiKey];
if (key !== apiKey) {
return;
}
if (!apiItem.res) {
Expand Down

0 comments on commit 4c4c1e6

Please sign in to comment.