Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李俊赕
self-support
Commits
62f27c7a
Commit
62f27c7a
authored
Aug 17, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 图片上传队列-删除本地不存在的临时文件
parent
847e1ed8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
task.js
src/components/upload/task.js
+22
-15
No files found.
src/components/upload/task.js
View file @
62f27c7a
...
@@ -19,13 +19,22 @@ export default {
...
@@ -19,13 +19,22 @@ export default {
console
.
log
(
"上传进度返回:"
,
res
);
console
.
log
(
"上传进度返回:"
,
res
);
}
}
}
}
const
result
=
await
uploader
.
qnFileUpload
(
options
)
if
(
result
&&
!
result
.
statusCode
)
{
// 匹配已上传完成的图片,更新缓存数据
uploader
.
qnFileUpload
(
options
).
then
(
res
=>
{
this
.
refreshTask
(
that
,
res
)
}).
catch
(
err
=>
{
console
.
log
(
"err"
,
err
)
if
(
err
.
errMsg
.
indexOf
(
'fail file not found'
)
!==
-
1
)
{
// 在任务中删除不存在的图片
this
.
refreshTask
(
that
,
[
'failErr'
])
}
})
},
refreshTask
(
that
,
result
)
{
const
uploadTask
=
that
.
uploadTask
let
newTask
=
[]
let
newTask
=
[]
let
delImg
=
[]
let
delImg
=
[]
uploadTask
.
forEach
(
v
=>
{
uploadTask
.
forEach
(
v
=>
{
if
(
result
.
includes
(
`/
${
v
.
key
}
`
))
{
// 删除已上传的图片
if
(
result
.
includes
(
`/
${
v
.
key
}
`
)
||
result
.
includes
(
'failErr'
))
{
// 删除已上传的图片
delImg
.
push
(
v
.
path
)
delImg
.
push
(
v
.
path
)
}
else
{
// 未上传的重新存储
}
else
{
// 未上传的重新存储
newTask
.
push
(
v
)
newTask
.
push
(
v
)
...
@@ -35,6 +44,4 @@ export default {
...
@@ -35,6 +44,4 @@ export default {
// uni.setStorageSync('delImg', delImg) // 已上传完的图片,会在启动系统的时候做一次清理
// uni.setStorageSync('delImg', delImg) // 已上传完的图片,会在启动系统的时候做一次清理
that
.
$u
.
vuex
(
'uploadTask'
,
newTask
)
that
.
$u
.
vuex
(
'uploadTask'
,
newTask
)
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment