From 1161b07a7fa3eacd6880d0442ae72c84a98160d2 Mon Sep 17 00:00:00 2001 From: taohebin Date: Fri, 9 Aug 2024 10:54:11 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=BD=91=E7=BB=9C=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=20=E5=A2=9E=E5=8A=A0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=AE=8C=E6=AF=95task=E7=BD=AE=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/download-file/download-file.uvue | 6 ++++-- pages/API/request/request.uvue | 3 ++- pages/API/upload-file/upload-file.uvue | 14 ++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pages/API/download-file/download-file.uvue b/pages/API/download-file/download-file.uvue index 1fad4fe3..48d1d9f9 100644 --- a/pages/API/download-file/download-file.uvue +++ b/pages/API/download-file/download-file.uvue @@ -55,11 +55,13 @@ success: (res) => { console.log('downloadFile success, res is', res.tempFilePath) self.imageSrc = res.tempFilePath; - uni.hideLoading(); }, fail: (err) => { console.log('downloadFile fail, err is:', err) - uni.hideLoading(); + }, + complete: (res) => { + uni.hideLoading(); + this.task = null; } }); this.task?.onProgressUpdate((update) => { diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue index ed74e5b1..35d8c378 100644 --- a/pages/API/request/request.uvue +++ b/pages/API/request/request.uvue @@ -218,7 +218,8 @@ }); }, complete: () => { - uni.hideLoading() + uni.hideLoading() + this.task = null }, }); }, diff --git a/pages/API/upload-file/upload-file.uvue b/pages/API/upload-file/upload-file.uvue index fab01a8a..9368ff95 100644 --- a/pages/API/upload-file/upload-file.uvue +++ b/pages/API/upload-file/upload-file.uvue @@ -61,7 +61,6 @@ }, success: (res) => { console.log('uploadImage success, res is:', res) - uni.hideLoading(); uni.showToast({ title: '上传成功', icon: 'success', @@ -71,12 +70,15 @@ }, fail: (err) => { console.log('uploadImage fail', err); - uni.hideLoading(); uni.showModal({ content: err.errMsg, showCancel: false }); - }, + }, + complete: (res) => { + uni.hideLoading(); + this.task = null + } }); }, fail: (err) => { @@ -87,7 +89,7 @@ //自动化测试例专用 jest_uploadFile() { const imageSrc = "/static/uni.png"; - this.task = uni.uploadFile({ + uni.uploadFile({ url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址 filePath: imageSrc, name: 'file', @@ -160,7 +162,7 @@ }, jest_cookie_upload(needCookie : boolean) { const imageSrc = "/static/uni.png"; - this.task = uni.uploadFile({ + uni.uploadFile({ url: 'https://request.dcloud.net.cn/api/http/header/upload', filePath: imageSrc, name: 'file', @@ -180,7 +182,7 @@ }, jest_files_upload() { const imageSrc = "/static/uni.png"; - this.task = uni.uploadFile({ + uni.uploadFile({ url: 'https://unidemo.dcloud.net.cn/upload', files: [ { -- GitLab