From e6d421dfb148aaafe6eff00a4836128cd5eb0de6 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Fri, 6 Sep 2024 13:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=96=E6=B6=88=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 4 +-- src/utils/oss-upload.js | 30 +++++++++++++++---- src/views/product/group/index.vue | 6 +++- .../system/version/components/add-version.vue | 22 ++++++++------ 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/.env.production b/.env.production index 1db13cc..2a4f841 100644 --- a/.env.production +++ b/.env.production @@ -3,13 +3,13 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http # 测试 -# VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' +VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' # 生产 # VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn' # 预发布接口 -VUE_APP_BASE_API = 'https://pre-cashieradmin.sxczgkj.cn' +# VUE_APP_BASE_API = 'https://pre-cashieradmin.sxczgkj.cn' # VUE_APP_BASE_API = 'http://192.168.2.98:8000' # 如果接口是 http 形式, wss 需要改为 ws diff --git a/src/utils/oss-upload.js b/src/utils/oss-upload.js index 0852205..dc7b9a2 100644 --- a/src/utils/oss-upload.js +++ b/src/utils/oss-upload.js @@ -10,6 +10,8 @@ const $config = { accessKeySecret: "", bucket: "cashier-oss" } +import { Notification } from 'element-ui' + async function uploadAndDownloadFile(name, file, headers) { return new Promise((resolve, reject) => { try { @@ -39,16 +41,16 @@ class ossClient { refreshSTSTokenInterval: 3600 * 1000 }); } - async upload(name, file, progressCallback) { + async upload(name, file, progressCallback) { try { let options = { // 获取分片上传进度、断点和返回值。 progress: progressCallback, - headers:$headers + headers: $headers } const { res: resp - } = await this.ossClient.put(name, file,options).catch(error => { + } = await this.ossClient.put(name, file, options).catch(error => { reject(error); }) return resp.requestUrls @@ -81,10 +83,21 @@ class ossClient { res: resp } = await this.ossClient.multipartUpload(name ? name : file.name, file, options) // return resp.requestUrls + console.log('------resp---'); console.log(resp) return `${resp.requestUrls[0]}`.split('?')[0] } catch (e) { + console.log('------e---'); console.log(e); + if (e.name == 'cancel') { + Notification.error({ + title: '上传已取消', + duration: 3000 + }) + return e + + } + } } @@ -94,8 +107,15 @@ class ossClient { * @param {Object} uploadId * @param {Object} name */ - abortUpload(uploadId, name) { - this.client.abortMultipartUpload(name, uploadId) + async abortUpload(uploadId, name) { + try { + const res=await this.ossClient.abortMultipartUpload(name, uploadId) + return res + } catch (error) { + console.log(error) + return error + } + } diff --git a/src/views/product/group/index.vue b/src/views/product/group/index.vue index 65d3545..d887081 100644 --- a/src/views/product/group/index.vue +++ b/src/views/product/group/index.vue @@ -40,7 +40,7 @@ - @@ -76,6 +76,10 @@ export default { }, methods: { + sizeChange(e){ + this.tableData.size = e + this.getTableData() + }, saleEndTimeFilter: (a, b) => { var currentDate = new Date(); // 当前日期对象 diff --git a/src/views/system/version/components/add-version.vue b/src/views/system/version/components/add-version.vue index 9a60047..68e141e 100644 --- a/src/views/system/version/components/add-version.vue +++ b/src/views/system/version/components/add-version.vue @@ -4,11 +4,9 @@ width="500px" :visible.sync="dialogVisible" @close="diaClose" - :close-on-click-modal="false" + :close-on-click-modal="true" > -
- -
+ +
+ +
{ this.progress = Math.floor(p * 100); - console.log("Progress: " + p * 100 + "%"); // 这里可以根据进度做相应的处理,例如更新UI等 } ); console.log(fileRes); if (!fileRes) { this.loading = false; + this.progress = 0; this.$notify({ title: "失败", message: `上传阿里云失败`, @@ -175,9 +177,11 @@ export default { }); return; } + if(fileRes.name=='cancel'){ + return + } } - this.progress = 0; let res = ""; if (this.form.id) { //编辑 @@ -206,7 +210,7 @@ export default { }); } this.loading = false; - + this.progress = 0; this.close(); this.$emit("success", res);