Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5eebff32
authored
Jul 09, 2024
by
yixinjj
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整删除文件逻辑
1 parent
2cb1e5eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
mixin/uploader.js
mixin/uploader.js
View file @
5eebff3
import
{
getOssToken
}
from
'@/utils/ossUploadFile/uploadFile.js'
import
Queue
from
'@/utils/Queue.js'
const
interval
=
60
*
1
0
cons
t
timer
=
null
const
interval
=
60
*
1
le
t
timer
=
null
export
default
{
onLoad
()
{},
data
()
{
...
...
@@ -49,6 +49,7 @@ export default {
}
catch
(
e
)
{
this
.
reportError
(
recordId
,
fileName
,
e
)
}
finally
{
console
.
log
(
'本次任务完成,开启下一次上传任务!'
);
this
.
polling
()
}
},
...
...
@@ -141,11 +142,9 @@ export default {
const
record
=
uni
.
$recordManager
.
getRecordById
(
recordId
)
if
(
!
record
)
return
this
.
_changeFilePathToServer
(
record
,
filePathOnClient
,
filePathOnServer
,
fileName
)
this
.
_removeFileOnClient
(
filePathOnClient
)
await
this
.
_saveOrUpdate
(
record
)
await
this
.
_saveOrUpdate
(
record
,
filePathOnClient
)
}
catch
(
err
)
{
this
.
reportError
(
recordId
,
filePathOnClient
,
err
)
Promise
.
reject
(
error
)
throw
new
Error
(
err
)
}
finally
{
unlock
()
}
...
...
@@ -197,13 +196,14 @@ export default {
* @param {Object} record - 要保存或更新的记录对象
* @throws {Error} 如果在保存或更新记录时发生错误,将抛出错误
*/
async
_saveOrUpdate
(
record
)
{
async
_saveOrUpdate
(
record
,
filePathOnClient
)
{
if
(
record
.
recordUrlList
?.
every
(
i
=>
i
.
status
==
undefined
))
{
const
pathArr
=
record
.
recordUrlList
.
map
(
i
=>
i
.
file
)
const
params
=
{
...
record
,
recordUrlList
:
pathArr
}
const
res
=
await
uni
.
$api
.
commonApi
.
saveRecCustomer
(
params
)
if
(
res
)
{
uni
.
$recordManager
.
removeRecord
(
record
.
id
)
this
.
_removeFileOnClient
(
filePathOnClient
)
}
}
else
{
uni
.
$recordManager
.
updateRecord
(
record
)
...
...
@@ -256,10 +256,10 @@ export default {
* @throws {Error} 如果在上传过程中发生错误,将抛出错误,延迟 interval 后继续 polling
*/
polling
()
{
console
.
log
(
this
.
snapshot
.
size
,
'
this.snapshot.size
'
)
console
.
log
(
this
.
snapshot
.
size
,
'
当前待上传文件快照数量
'
)
if
(
this
.
snapshot
===
null
)
return
// prettier-ignore
uni
.
$isNetWork
().
then
(
this
.
upload
).
catch
(()
=>
this
.
pollingLater
(
interval
)
)
uni
.
$isNetWork
().
then
(
this
.
upload
).
catch
(()
=>
{
this
.
pollingLater
(
interval
)}
)
},
/**
* 上传文件或执行队列操作
...
...
@@ -269,8 +269,8 @@ export default {
*/
upload
()
{
if
(
this
.
snapshot
.
size
==
0
)
{
this
.
enQueue
()
this
.
pollingLater
(
interval
)
this
.
enQueue
()
}
else
{
let
record
=
this
.
snapshot
.
dequeue
()
// while(record.file.startsWith('http')) {
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment