提交 b37146e0 编写于 作者: X xiaoyucoding

feat(mp): 小程序平台 previewImage 参数 current 支持传入索引值

上级 5ac4c785
......@@ -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,
......
......@@ -59,9 +59,19 @@ const protocols = {
}
},
previewImage: {
args: {
indicator: false,
loop: false
args (fromArgs) {
// 处理传入索引值的情况
const currentIndex = Number(fromArgs.current)
if (!isNaN(currentIndex)) {
const urls = fromArgs.urls && Array.isArray(fromArgs.urls) ? fromArgs.urls.concat() : []
fromArgs.urls = urls.filter((item, index) => {
return index < currentIndex ? item !== urls[currentIndex] : true
})
}
return {
indicator: false,
loop: false
}
}
},
getRecorderManager: {
......
......@@ -92,9 +92,19 @@ const protocols = {
}
},
previewImage: {
args: {
indicator: false,
loop: false
args (fromArgs) {
// 处理传入索引值的情况
const currentIndex = Number(fromArgs.current)
if (!isNaN(currentIndex)) {
const urls = fromArgs.urls && Array.isArray(fromArgs.urls) ? fromArgs.urls.concat() : []
fromArgs.urls = urls.filter((item, index) => {
return index < currentIndex ? item !== urls[currentIndex] : true
})
}
return {
indicator: false,
loop: false
}
}
},
connectSocket: {
......
export const protocols = {}
export const protocols = {
previewImage: {
args (fromArgs) {
// 处理传入索引值的情况
const currentIndex = Number(fromArgs.current)
if (!isNaN(currentIndex)) {
const urls = fromArgs.urls && Array.isArray(fromArgs.urls) ? fromArgs.urls.concat() : []
fromArgs.urls = urls.filter((item, index) => {
return index < currentIndex ? item !== urls[currentIndex] : true
})
}
}
}
}
export const todos = []
export const canIUses = []
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册