提交 b774e91f 编写于 作者: Q qiang

fix(App): 忽略 compressImage、chooseVideo 压缩失败

上级 d53b1754
......@@ -30,7 +30,7 @@ function getFileInfo (filePath) {
function compressImage (tempFilePath) {
const dstPath = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
plus.nativeUI.showWaiting()
plus.zip.compressImage({
src: tempFilePath,
......@@ -39,9 +39,9 @@ function compressImage (tempFilePath) {
}, () => {
plus.nativeUI.closeWaiting()
resolve(dstPath)
}, (error) => {
}, () => {
plus.nativeUI.closeWaiting()
reject(error)
resolve(tempFilePath)
})
})
}
......
......@@ -25,16 +25,20 @@ export function chooseVideo ({
function successCallback (tempFilePath = '') {
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`
const compressVideo = compressed ? plus.zip.compressVideo : function (_, callback) {
callback({ tempFilePath })
}
const compressVideo = compressed ? new Promise((resolve) => {
plus.zip.compressVideo({
src: tempFilePath,
dst
}, ({ tempFilePath }) => {
resolve(tempFilePath)
}, () => {
resolve(tempFilePath)
})
}) : Promise.resolve()
if (compressed) {
plus.nativeUI.showWaiting()
}
compressVideo({
src: tempFilePath,
dst
}, ({ tempFilePath }) => {
compressVideo.then(tempFilePath => {
if (compressed) {
plus.nativeUI.closeWaiting()
}
......@@ -50,12 +54,9 @@ export function chooseVideo ({
result.width = videoInfo.width
result.height = videoInfo.height
invoke(callbackId, result)
},
},
errorCallback
})
}, error => {
plus.nativeUI.closeWaiting()
errorCallback(error)
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册