diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index 4f101c80d4035c45efa6774e9d3930cd9f4468d8..c7d3b20eb62075ce5e5618bf9c3b6df6856ff4d8 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -361,9 +361,14 @@ const protocols = { // 需要做转换的 API 列表 previewImage: { args (fromArgs) { // 支付宝小程序的 current 是索引值,而非图片地址。 - if (fromArgs.current && Array.isArray(fromArgs.urls)) { - const index = fromArgs.urls.indexOf(fromArgs.current); - fromArgs.current = ~index ? index : 0; + const currentIndex = Number(fromArgs.current); + if (isNaN(currentIndex)) { + if (fromArgs.current && Array.isArray(fromArgs.urls)) { + const index = fromArgs.urls.indexOf(fromArgs.current); + fromArgs.current = ~index ? index : 0; + } + } else { + fromArgs.current = currentIndex; } return { indicator: false, diff --git a/packages/uni-mp-alipay/package.json b/packages/uni-mp-alipay/package.json index 4ec8aa306c5deb8c3211310fbbd5f7f996d88fed..17d4cfa93cacf496e44e2fed89b30ee1a2664fbb 100644 --- a/packages/uni-mp-alipay/package.json +++ b/packages/uni-mp-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-alipay", - "version": "0.0.802", + "version": "0.0.803", "description": "uni-app mp-alipay", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index e144b83584d1997ef07da02b8105d2aff00001b2..db93ea193db7a8a01a32dd335a8cec343fb5027c 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -144,6 +144,34 @@ function upx2px (number, newDeviceWidth) { return number < 0 ? -result : result } +function normalize (fromArgs) { + let currentIndex = parseInt(fromArgs.current); + if (isNaN(currentIndex)) { + return + } + const urls = fromArgs.urls; + if (!Array.isArray(urls)) { + return + } + const len = urls.length; + if (!len) { + return + } + if (currentIndex < 0) { + currentIndex = 0; + } else if (currentIndex >= len) { + currentIndex = len - 1; + } + if (currentIndex > 0) { + fromArgs.current = urls[currentIndex]; + fromArgs.urls = urls.filter( + (item, index) => index < currentIndex ? item !== urls[currentIndex] : true + ); + } else { + fromArgs.current = urls[0]; + } +} + // 不支持的 API 列表 const todos = [ 'hideKeyboard', @@ -205,9 +233,12 @@ const protocols = { } }, previewImage: { - args: { - indicator: false, - loop: false + args (fromArgs) { + normalize(fromArgs); + return { + indicator: false, + loop: false + } } }, getRecorderManager: { diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index 99be9a84be41f4419bf6e8dae7f543d2604bc39b..aada5ec907426cf4ace78302d6f01967a6fc095d 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.828", + "version": "0.0.829", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 833c081be14724467fe89a806926ba2f06d8e577..d56308da39deb02ed3cac4b53dc115ef660f25fd 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -144,6 +144,34 @@ function upx2px (number, newDeviceWidth) { return number < 0 ? -result : result } +function normalize (fromArgs) { + let currentIndex = parseInt(fromArgs.current); + if (isNaN(currentIndex)) { + return + } + const urls = fromArgs.urls; + if (!Array.isArray(urls)) { + return + } + const len = urls.length; + if (!len) { + return + } + if (currentIndex < 0) { + currentIndex = 0; + } else if (currentIndex >= len) { + currentIndex = len - 1; + } + if (currentIndex > 0) { + fromArgs.current = urls[currentIndex]; + fromArgs.urls = urls.filter( + (item, index) => index < currentIndex ? item !== urls[currentIndex] : true + ); + } else { + fromArgs.current = urls[0]; + } +} + // 不支持的 API 列表 const todos = [ 'hideKeyboard', @@ -238,9 +266,12 @@ const protocols = { } }, previewImage: { - args: { - indicator: false, - loop: false + args (fromArgs) { + normalize(fromArgs); + return { + indicator: false, + loop: false + } } }, connectSocket: { diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index 6f9e579958bb4ec2c16c9c5d7a20f45449d9e21b..6a934b8a506d50f559a8c3ec0aeccfe08580050f 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.326", + "version": "0.0.327", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index f8c8ce162655cad4d5ec2c713adb7476d4d8ddd4..63da3c6ffa4fe28f71ed4ed7662eb8ed4b73321c 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -144,8 +144,40 @@ function upx2px (number, newDeviceWidth) { return number < 0 ? -result : result } -const protocols = {}; -const todos = []; +function normalize (fromArgs) { + let currentIndex = parseInt(fromArgs.current); + if (isNaN(currentIndex)) { + return + } + const urls = fromArgs.urls; + if (!Array.isArray(urls)) { + return + } + const len = urls.length; + if (!len) { + return + } + if (currentIndex < 0) { + currentIndex = 0; + } else if (currentIndex >= len) { + currentIndex = len - 1; + } + if (currentIndex > 0) { + fromArgs.current = urls[currentIndex]; + fromArgs.urls = urls.filter( + (item, index) => index < currentIndex ? item !== urls[currentIndex] : true + ); + } else { + fromArgs.current = urls[0]; + } +} + +const protocols = { + previewImage: { + args: normalize + } +}; +const todos = []; const canIUses = []; const CALLBACKS = ['success', 'fail', 'cancel', 'complete']; diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index 921ee811318792f38aa5fbebb61c016b776417b5..c574a5ab72daeca0233ba23c9b515bec3241e6a3 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.950", + "version": "0.0.951", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": {