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": { diff --git a/src/core/helpers/protocol/media/preview-image.js b/src/core/helpers/protocol/media/preview-image.js index 8981f5665aa47b998bfedbb70205983775ad6dab..43e87e18372a97de992d80d6cff15b65abf4d8dc 100644 --- a/src/core/helpers/protocol/media/preview-image.js +++ b/src/core/helpers/protocol/media/preview-image.js @@ -19,9 +19,11 @@ export const previewImage = { } }, current: { - type: String, + type: [String, Number], validator (value, params) { - params.type = value ? getRealPath(value) : '' + // 假值都会被转换为数字 0 无需再做判定 + const index = Number(value) + params.current = isNaN(index) ? getRealPath(value) : index } } } diff --git a/src/core/service/api/context/canvas.js b/src/core/service/api/context/canvas.js index 9fdb55f2c49e20a255636c4e0db5a9162b095e07..6224ab38513effa4151cc2b5b68326c5cb1298b8 100644 --- a/src/core/service/api/context/canvas.js +++ b/src/core/service/api/context/canvas.js @@ -671,10 +671,17 @@ methods3.forEach(function (method) { case 'setFillStyle': case 'setStrokeStyle': return function (color) { - this.actions.push({ - method, - data: ['normal', checkColor(color)] - }) + if (typeof color !== 'object') { + this.actions.push({ + method, + data: ['normal', checkColor(color)] + }) + } else { + this.actions.push({ + method, + data: [color.type, color.data, color.colorStop] + }) + } } case 'setGlobalAlpha': return function (alpha) { diff --git a/src/core/view/components/canvas/index.vue b/src/core/view/components/canvas/index.vue index 80d1b227f6a4e1cf483cf0b04f59c9d06215a629..525a8b52f7c21c5eac1db1e40d2766161a8e6917 100644 --- a/src/core/view/components/canvas/index.vue +++ b/src/core/view/components/canvas/index.vue @@ -163,6 +163,7 @@ export default { let color = resolveColor(data2[1]) LinearGradient.addColorStop(offset, color) }) + color = LinearGradient } else if (data[0] === 'radial') { let x = data[1][0] let y = data[1][1] @@ -173,6 +174,7 @@ export default { let color = resolveColor(data2[1]) LinearGradient.addColorStop(offset, color) }) + color = LinearGradient } else if (data[0] === 'pattern') { let loaded = this.checkImageLoaded(data[1], actions.slice(index + 1), callbackId, function (image) { diff --git a/src/platforms/h5/components/system-routes/preview-image/index.vue b/src/platforms/h5/components/system-routes/preview-image/index.vue index 8eab5d3963083eef2204f04873a149cbb5032165..52cb2a21edfa8c14d14415ff0352428e228339d0 100644 --- a/src/platforms/h5/components/system-routes/preview-image/index.vue +++ b/src/platforms/h5/components/system-routes/preview-image/index.vue @@ -33,7 +33,7 @@ export default { } }, created () { - var index = this.urls.indexOf(this.current) + const index = typeof this.current === 'number' ? this.current : this.urls.indexOf(this.current) this.index = index < 0 ? 0 : index }, methods: { diff --git a/src/platforms/h5/view/components/map/index.vue b/src/platforms/h5/view/components/map/index.vue index d64d6f2afb2329430e62508e2d7ee0f1d6c3db79..f653b778d3238441f31d9b59ce483b12dbe8defd 100644 --- a/src/platforms/h5/view/components/map/index.vue +++ b/src/platforms/h5/view/components/map/index.vue @@ -346,7 +346,8 @@ export default { this.$emit('boundsready') }) maps.event.addListener(map, 'click', () => { - this.$trigger('tap', {}, {}) + // TODO 编译器将 tap 转换为click + this.$trigger('click', {}, {}) }) maps.event.addListener(map, 'dragstart', () => { this.$trigger('regionchange', {}, { diff --git a/src/platforms/mp-alipay/service/api/protocols.js b/src/platforms/mp-alipay/service/api/protocols.js index b0a90c7959db3c9b03dd7cf05e841f59cf812457..d770544d1e38db27890cf52ac8f72fb3360d483e 100644 --- a/src/platforms/mp-alipay/service/api/protocols.js +++ b/src/platforms/mp-alipay/service/api/protocols.js @@ -215,9 +215,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/src/platforms/mp-baidu/service/api/protocols.js b/src/platforms/mp-baidu/service/api/protocols.js index 1bb1bd35dda13eedd3bf5c494e474d38099b8d56..08fb92fc66e6e5aaf175a2377396dd75b2675a28 100644 --- a/src/platforms/mp-baidu/service/api/protocols.js +++ b/src/platforms/mp-baidu/service/api/protocols.js @@ -1,3 +1,4 @@ +import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args' // 不支持的 API 列表 const todos = [ 'hideKeyboard', @@ -59,9 +60,12 @@ const protocols = { } }, previewImage: { - args: { - indicator: false, - loop: false + args (fromArgs) { + normalizePreviewImageArgs(fromArgs) + return { + indicator: false, + loop: false + } } }, getRecorderManager: { diff --git a/src/platforms/mp-toutiao/service/api/protocols.js b/src/platforms/mp-toutiao/service/api/protocols.js index 0f99ee949ff99fea3a57304d72cc95a4a3635995..9ff4f8de5112cdcb524c04a0942a44e0e3328dd1 100644 --- a/src/platforms/mp-toutiao/service/api/protocols.js +++ b/src/platforms/mp-toutiao/service/api/protocols.js @@ -1,3 +1,5 @@ +import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args' + // 不支持的 API 列表 const todos = [ 'hideKeyboard', @@ -92,9 +94,12 @@ const protocols = { } }, previewImage: { - args: { - indicator: false, - loop: false + args (fromArgs) { + normalizePreviewImageArgs(fromArgs) + return { + indicator: false, + loop: false + } } }, connectSocket: { diff --git a/src/platforms/mp-weixin/helpers/normalize-preview-image-args.js b/src/platforms/mp-weixin/helpers/normalize-preview-image-args.js new file mode 100644 index 0000000000000000000000000000000000000000..6c0f499acd4bb93a88f7a02d60d757fda7b61851 --- /dev/null +++ b/src/platforms/mp-weixin/helpers/normalize-preview-image-args.js @@ -0,0 +1,27 @@ +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/service/api/protocols.js b/src/platforms/mp-weixin/service/api/protocols.js index 93855999bfb1dc2cd64ca3cfd3b75bd78e9e942d..697914b020b91c83bcfa9a399ff9ec4f0bdd50be 100644 --- a/src/platforms/mp-weixin/service/api/protocols.js +++ b/src/platforms/mp-weixin/service/api/protocols.js @@ -1,3 +1,8 @@ -export const protocols = {} -export const todos = [] +import normalizePreviewImageArgs from '../../helpers/normalize-preview-image-args' +export const protocols = { + previewImage: { + args: normalizePreviewImageArgs + } +} +export const todos = [] export const canIUses = []