From c3689883a71754f27f02a400fdf68cc5dfc22529 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 14 Oct 2020 22:47:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=8C=E6=9C=9B=E6=94=AF=E6=8C=81aliyunOSS?= =?UTF-8?q?=E5=92=8CtencentCos=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=20#33?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/file.js | 10 +++++++++- .../CodemirrorEditor/uploadImgDialog.vue | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/api/file.js b/src/api/file.js index 110067e..7f1b5ed 100644 --- a/src/api/file.js +++ b/src/api/file.js @@ -95,6 +95,9 @@ async function aliOSSFileUpload(content, filename) { accessKeySecret: aliOSSConfig.accessKeySecret }); const res = await client.put(dir, buffer); + if(aliOSSConfig.cdnHost != ''){ + return aliOSSConfig.cdnHost +'/'+dir; + } return res.url; } catch (e) { return Promise.reject(e); @@ -118,7 +121,12 @@ async function txCOSFileUpload(file) { if (err) { reject(err); } else { - resolve("https://" + data.Location); + if(txCOSConfig.cdnHost != ''){ + resolve(txCOSConfig.cdnHost+'/'+txCOSConfig.path + '/' + dateFilename); + }else{ + resolve(data.Location); + } + } }); }) diff --git a/src/components/CodemirrorEditor/uploadImgDialog.vue b/src/components/CodemirrorEditor/uploadImgDialog.vue index 2c598cf..ae637f5 100644 --- a/src/components/CodemirrorEditor/uploadImgDialog.vue +++ b/src/components/CodemirrorEditor/uploadImgDialog.vue @@ -52,6 +52,10 @@ + + + + + +