提交 b897123a 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -7,8 +7,7 @@ import {
} from '../../bridge'
import {
warpPlusErrorCallback,
getFileName
warpPlusErrorCallback
} from '../util'
import {
......@@ -28,24 +27,6 @@ function getFileInfo (filePath) {
})
}
function compressImage (tempFilePath) {
const dstPath = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`
return new Promise((resolve) => {
plus.nativeUI.showWaiting()
plus.zip.compressImage({
src: tempFilePath,
dst: dstPath,
overwrite: true
}, () => {
plus.nativeUI.closeWaiting()
resolve(dstPath)
}, () => {
plus.nativeUI.closeWaiting()
resolve(tempFilePath)
})
})
}
export function chooseImage ({
count,
sizeType,
......@@ -58,35 +39,21 @@ export function chooseImage ({
const tempFiles = []
const tempFilePaths = []
// plus.zip.compressImage 压缩文件并发调用在iOS端容易出现问题(图像错误、闪退),改为队列执行
paths.reduce((promise, path) => {
return promise.then(() => {
return getFileInfo(path)
}).then(fileInfo => {
const size = fileInfo.size
// 压缩阈值 0.5 兆
const THRESHOLD = 1024 * 1024 * 0.5
// 判断是否需要压缩
if (!crop && sizeType.includes('compressed') && size > THRESHOLD) {
return compressImage(path).then(dstPath => {
path = dstPath
return getFileInfo(path)
})
}
return fileInfo
}).then(({ size }) => {
Promise.all(paths.map((path) => getFileInfo(path)))
.then((filesInfo) => {
filesInfo.forEach((file, index) => {
const path = paths[index]
tempFilePaths.push(path)
tempFiles.push({
path,
size
})
tempFiles.push({ path, size: file.size })
})
}, Promise.resolve()).then(() => {
invoke(callbackId, {
errMsg: 'chooseImage:ok',
tempFilePaths,
tempFiles
})
}).catch(errorCallback)
})
.catch(errorCallback)
}
function openCamera () {
......@@ -106,7 +73,8 @@ export function chooseImage ({
system: false,
filename: TEMP_PATH + '/gallery/',
permissionAlert: true,
crop
crop,
sizeType
})
}
......
......@@ -152,7 +152,7 @@ export function initWebview (webview, routeOptions, path, query) {
export function createPreloadWebview () {
if (!preloadWebview || preloadWebview.__uniapp_route) { // 不存在,或已被使用
preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id++))
preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id++), { contentAdjust: false })
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] preloadWebview[${preloadWebview.id}]`)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册