提交 95068879 编写于 作者: fxy060608's avatar fxy060608

fix(mp): previewImage currentIndex

上级 5123d7cf
import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args'
// 不支持的 API 列表
const todos = [
'hideKeyboard',
......@@ -60,14 +61,7 @@ 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
})
}
normalizePreviewImageArgs(fromArgs)
return {
indicator: false,
loop: false
......
import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args'
// 不支持的 API 列表
const todos = [
'hideKeyboard',
......@@ -93,14 +95,7 @@ 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
})
}
normalizePreviewImageArgs(fromArgs)
return {
indicator: false,
loop: false
......
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]
}
}
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 = []
import normalizePreviewImageArgs from '../../helpers/normalize-preview-image-args'
export const protocols = {
previewImage: {
args: normalizePreviewImageArgs
}
}
export const todos = []
export const canIUses = []
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册