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

fix(mp): previewImage currentIndex

上级 5123d7cf
import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args'
// 不支持的 API 列表 // 不支持的 API 列表
const todos = [ const todos = [
'hideKeyboard', 'hideKeyboard',
...@@ -60,14 +61,7 @@ const protocols = { ...@@ -60,14 +61,7 @@ const protocols = {
}, },
previewImage: { previewImage: {
args (fromArgs) { args (fromArgs) {
// 处理传入索引值的情况 normalizePreviewImageArgs(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 { return {
indicator: false, indicator: false,
loop: false loop: false
......
import normalizePreviewImageArgs from '../../../mp-weixin/helpers/normalize-preview-image-args'
// 不支持的 API 列表 // 不支持的 API 列表
const todos = [ const todos = [
'hideKeyboard', 'hideKeyboard',
...@@ -93,14 +95,7 @@ const protocols = { ...@@ -93,14 +95,7 @@ const protocols = {
}, },
previewImage: { previewImage: {
args (fromArgs) { args (fromArgs) {
// 处理传入索引值的情况 normalizePreviewImageArgs(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 { return {
indicator: false, indicator: false,
loop: 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 = { import normalizePreviewImageArgs from '../../helpers/normalize-preview-image-args'
previewImage: { export const protocols = {
args (fromArgs) { previewImage: {
// 处理传入索引值的情况 args: normalizePreviewImageArgs
const currentIndex = Number(fromArgs.current) }
if (!isNaN(currentIndex)) { }
const urls = fromArgs.urls && Array.isArray(fromArgs.urls) ? fromArgs.urls.concat() : [] export const todos = []
fromArgs.urls = urls.filter((item, index) => {
return index < currentIndex ? item !== urls[currentIndex] : true
})
}
}
}
}
export const todos = []
export const canIUses = [] export const canIUses = []
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册