diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index db93ea193db7a8a01a32dd335a8cec343fb5027c..6bdf4e3cb939a17f86e6e47bc381787e5a63ebb3 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -144,33 +144,39 @@ 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]; +var previewImage = { + args (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]; + } + return { + indicator: false, + loop: false + } } -} +}; // 不支持的 API 列表 const todos = [ @@ -232,15 +238,7 @@ const protocols = { method: false } }, - previewImage: { - args (fromArgs) { - normalize(fromArgs); - return { - indicator: false, - loop: false - } - } - }, + previewImage, getRecorderManager: { returnValue (fromRet) { fromRet.onFrameRecorded = createTodoMethod('RecorderManager', 'onFrameRecorded'); diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index aada5ec907426cf4ace78302d6f01967a6fc095d..7f1254f58815d3a7cc2e796fdc42ba94b13bdbb2 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.829", + "version": "0.0.830", "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 d56308da39deb02ed3cac4b53dc115ef660f25fd..6add7ff27bb4bfaea72f53c24f97a54f2325ed5c 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -144,33 +144,39 @@ 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]; +var previewImage = { + args (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]; + } + return { + indicator: false, + loop: false + } } -} +}; // 不支持的 API 列表 const todos = [ @@ -265,15 +271,7 @@ const protocols = { sizeType: false } }, - previewImage: { - args (fromArgs) { - normalize(fromArgs); - return { - indicator: false, - loop: false - } - } - }, + previewImage, connectSocket: { args: { method: false diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index 6a934b8a506d50f559a8c3ec0aeccfe08580050f..88e1d85d5f5ebc815ab8e6b5e995ab1ec1014f0e 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.327", + "version": "0.0.328", "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 63da3c6ffa4fe28f71ed4ed7662eb8ed4b73321c..e6eab42a263bd2f2d728d7cbce16174f07c7c555 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -144,38 +144,42 @@ 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]; +var previewImage = { + args (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]; + } + return { + indicator: false, + loop: false + } } -} +}; const protocols = { - previewImage: { - args: normalize - } + previewImage }; const todos = []; const canIUses = []; diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index c574a5ab72daeca0233ba23c9b515bec3241e6a3..f22169b4c8263121ae57633c15089241e4e7b511 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.951", + "version": "0.0.952", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/platforms/mp-baidu/service/api/protocols.js b/src/platforms/mp-baidu/service/api/protocols.js index 08fb92fc66e6e5aaf175a2377396dd75b2675a28..43ee0a267a039b75dd9ba4a8878272871f13faa9 100644 --- a/src/platforms/mp-baidu/service/api/protocols.js +++ b/src/platforms/mp-baidu/service/api/protocols.js @@ -1,4 +1,4 @@ -import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args' +import previewImage from '../../../mp-weixin/helpers/normalize-preview-image' // 不支持的 API 列表 const todos = [ 'hideKeyboard', @@ -59,15 +59,7 @@ const protocols = { method: false } }, - previewImage: { - args (fromArgs) { - normalizePreviewImageArgs(fromArgs) - return { - indicator: false, - loop: false - } - } - }, + previewImage, getRecorderManager: { returnValue (fromRet) { fromRet.onFrameRecorded = createTodoMethod('RecorderManager', 'onFrameRecorded') diff --git a/src/platforms/mp-toutiao/service/api/protocols.js b/src/platforms/mp-toutiao/service/api/protocols.js index 9ff4f8de5112cdcb524c04a0942a44e0e3328dd1..205e4dc1cb997280c4e408fcfa6434432d851938 100644 --- a/src/platforms/mp-toutiao/service/api/protocols.js +++ b/src/platforms/mp-toutiao/service/api/protocols.js @@ -1,4 +1,4 @@ -import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args' +import previewImage from '../../../mp-weixin/helpers/normalize-preview-image' // 不支持的 API 列表 const todos = [ @@ -93,15 +93,7 @@ const protocols = { sizeType: false } }, - previewImage: { - args (fromArgs) { - normalizePreviewImageArgs(fromArgs) - return { - indicator: false, - loop: false - } - } - }, + previewImage, connectSocket: { args: { method: false diff --git a/src/platforms/mp-weixin/helpers/normalize-preview-image-args.js b/src/platforms/mp-weixin/helpers/normalize-preview-image-args.js deleted file mode 100644 index 6c0f499acd4bb93a88f7a02d60d757fda7b61851..0000000000000000000000000000000000000000 --- a/src/platforms/mp-weixin/helpers/normalize-preview-image-args.js +++ /dev/null @@ -1,27 +0,0 @@ -export default 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] - } -} diff --git a/src/platforms/mp-weixin/helpers/normalize-preview-image.js b/src/platforms/mp-weixin/helpers/normalize-preview-image.js new file mode 100644 index 0000000000000000000000000000000000000000..02a652485e7a955b0bdaec1d93f8c912de09071e --- /dev/null +++ b/src/platforms/mp-weixin/helpers/normalize-preview-image.js @@ -0,0 +1,33 @@ +export default { + args (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] + } + return { + indicator: false, + loop: false + } + } +} diff --git a/src/platforms/mp-weixin/service/api/protocols.js b/src/platforms/mp-weixin/service/api/protocols.js index 5786e7e5c6d485ffc763abb2e12d8119471979fe..3b6cd7a96562b97053f1efcd91ed1917576ef925 100644 --- a/src/platforms/mp-weixin/service/api/protocols.js +++ b/src/platforms/mp-weixin/service/api/protocols.js @@ -1,14 +1,6 @@ -import normalizePreviewImageArgs from '../../helpers/normalize-preview-image-args' +import previewImage from '../../helpers/normalize-preview-image' export const protocols = { - previewImage: { - args (fromArgs) { - normalizePreviewImageArgs(fromArgs) - return { - indicator: false, - loop: false - } - } - } + previewImage } export const todos = [] export const canIUses = []