提交 b897123a 编写于 作者: Q qiang

Merge branch 'dev' into alpha

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