Commit 5eebff32 by yixinjj

调整删除文件逻辑

1 parent 2cb1e5eb
import { getOssToken } from '@/utils/ossUploadFile/uploadFile.js'
import Queue from '@/utils/Queue.js'
const interval = 60 * 10
const timer = null
const interval = 60 * 1
let 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')) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!