Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ChenYFan_OHHH
uni-app
提交
511c004c
U
uni-app
项目概览
ChenYFan_OHHH
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
511c004c
编写于
9月 17, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(App): chooseImage、chooseVideo 优化
上级
3abb8b2a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
77 deletion
+25
-77
packages/vue-cli-plugin-uni/commands/build.js
packages/vue-cli-plugin-uni/commands/build.js
+1
-1
src/platforms/app-plus/service/api/media/choose-image.js
src/platforms/app-plus/service/api/media/choose-image.js
+5
-38
src/platforms/app-plus/service/api/media/choose-video.js
src/platforms/app-plus/service/api/media/choose-video.js
+19
-38
未找到文件。
packages/vue-cli-plugin-uni/commands/build.js
浏览文件 @
511c004c
...
...
@@ -133,7 +133,7 @@ async function build (args, api, options) {
log
()
if
(
!
runByHBuilderX
&&
!
runByAliIde
)
{
logWithSpinner
(
uniI18n
.
__
(
'
pluginUni.startCompileProjectToPlatform
'
,
{
0
:
process
.
env
.
UNI_SUB_PLATFORM
||
process
.
env
.
UNI_PLATFORM
,
1
:
process
.
env
.
UNI_MP_PLUGIN
?
uniI18n
.
__
(
'
pl
atform
'
)
:
uniI18n
.
__
(
'
plugin
'
)
}))
logWithSpinner
(
uniI18n
.
__
(
'
pluginUni.startCompileProjectToPlatform
'
,
{
0
:
process
.
env
.
UNI_SUB_PLATFORM
||
process
.
env
.
UNI_PLATFORM
,
1
:
process
.
env
.
UNI_MP_PLUGIN
?
uniI18n
.
__
(
'
pl
ugin
'
)
:
uniI18n
.
__
(
'
platform
'
)
}))
}
const
targetDir
=
api
.
resolve
(
options
.
outputDir
)
...
...
src/platforms/app-plus/service/api/media/choose-image.js
浏览文件 @
511c004c
...
...
@@ -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
,
...
...
@@ -57,7 +38,6 @@ export function chooseImage ({
function
successCallback
(
paths
)
{
const
tempFiles
=
[]
const
tempFilePaths
=
[]
// plus.zip.compressImage 压缩文件并发调用在iOS端容易出现问题(图像错误、闪退),改为队列执行
Promise
.
all
(
paths
.
map
((
path
)
=>
getFileInfo
(
path
)))
.
then
((
filesInfo
)
=>
{
filesInfo
.
forEach
((
file
,
index
)
=>
{
...
...
@@ -77,25 +57,12 @@ export function chooseImage ({
function
openCamera
()
{
const
camera
=
plus
.
camera
.
getCamera
()
camera
.
captureImage
(
path
=>
{
// fix By Lxh 暂时添加拍照压缩逻辑,等客户端增加逻辑后修改
// 判断是否需要压缩
if
(
sizeType
&&
sizeType
.
includes
(
'
compressed
'
))
{
return
getFileInfo
(
path
).
then
(({
size
})
=>
{
// 压缩阈值 0.5 兆
const
THRESHOLD
=
1024
*
1024
*
0.5
return
size
&&
size
>
THRESHOLD
?
compressImage
(
path
).
then
(
dstPath
=>
successCallback
([
dstPath
]))
:
successCallback
([
path
])
}).
catch
(
errorCallback
)
}
return
successCallback
([
path
])
},
errorCallback
,
{
camera
.
captureImage
(
path
=>
successCallback
([
path
]),
errorCallback
,
{
filename
:
TEMP_PATH
+
'
/camera/
'
,
resolution
:
'
high
'
,
crop
crop
,
sizeType
})
}
...
...
src/platforms/app-plus/service/api/media/choose-video.js
浏览文件 @
511c004c
...
...
@@ -7,8 +7,7 @@ import {
}
from
'
../../bridge
'
import
{
warpPlusErrorCallback
,
getFileName
warpPlusErrorCallback
}
from
'
../util
'
import
{
...
...
@@ -24,40 +23,20 @@ export function chooseVideo ({
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
'
chooseVideo
'
,
'
cancel
'
)
function
successCallback
(
tempFilePath
=
''
)
{
const
filename
=
`
${
TEMP_PATH
}
/compressed/
${
Date
.
now
()}
_
${
getFileName
(
tempFilePath
)}
`
const
compressVideo
=
compressed
?
new
Promise
((
resolve
)
=>
{
plus
.
zip
.
compressVideo
({
src
:
tempFilePath
,
filename
,
quality
:
'
medium
'
},
({
tempFilePath
})
=>
{
resolve
(
tempFilePath
)
},
()
=>
{
resolve
(
tempFilePath
)
})
})
:
Promise
.
resolve
(
tempFilePath
)
if
(
compressed
)
{
plus
.
nativeUI
.
showWaiting
()
}
compressVideo
.
then
(
tempFilePath
=>
{
if
(
compressed
)
{
plus
.
nativeUI
.
closeWaiting
()
}
plus
.
io
.
getVideoInfo
({
filePath
:
tempFilePath
,
success
(
videoInfo
)
{
const
result
=
{
errMsg
:
'
chooseVideo:ok
'
,
tempFilePath
:
tempFilePath
}
result
.
size
=
videoInfo
.
size
result
.
duration
=
videoInfo
.
duration
result
.
width
=
videoInfo
.
width
result
.
height
=
videoInfo
.
height
invoke
(
callbackId
,
result
)
},
fail
:
errorCallback
})
plus
.
io
.
getVideoInfo
({
filePath
:
tempFilePath
,
success
(
videoInfo
)
{
const
result
=
{
errMsg
:
'
chooseVideo:ok
'
,
tempFilePath
:
tempFilePath
}
result
.
size
=
videoInfo
.
size
result
.
duration
=
videoInfo
.
duration
result
.
width
=
videoInfo
.
width
result
.
height
=
videoInfo
.
height
invoke
(
callbackId
,
result
)
},
fail
:
errorCallback
})
}
...
...
@@ -69,7 +48,8 @@ export function chooseVideo ({
multiple
:
true
,
maximum
:
1
,
filename
:
TEMP_PATH
+
'
/gallery/
'
,
permissionAlert
:
true
permissionAlert
:
true
,
videoCompress
:
compressed
})
}
...
...
@@ -78,7 +58,8 @@ export function chooseVideo ({
plusCamera
.
startVideoCapture
(
successCallback
,
errorCallback
,
{
index
:
camera
===
'
front
'
?
2
:
1
,
videoMaximumDuration
:
maxDuration
,
filename
:
TEMP_PATH
+
'
/camera/
'
filename
:
TEMP_PATH
+
'
/camera/
'
,
videoCompress
:
compressed
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录