Skip to content

Commit

Permalink
Merge pull request #34 from dislazy/master
Browse files Browse the repository at this point in the history
* close #33
  • Loading branch information
yanglbme authored Oct 14, 2020
2 parents ee4ad8d + c368988 commit 9848a76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/api/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

}
});
})
Expand Down
14 changes: 12 additions & 2 deletions src/components/CodemirrorEditor/uploadImgDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<el-form-item label="Bucket 所在区域" :required="true">
<el-input v-model.trim="formAliOSS.region"
placeholder="如:oss-cn-shenzhen"></el-input>
</el-form-item>
<el-form-item label="自定义CDN域名" :required="false">
<el-input v-model.trim="formAliOSS.cdnHost"
placeholder="如:https://imagecdn.alidaodao.com"></el-input>
</el-form-item>
<el-form-item label="存储路径">
<el-input v-model.trim="formAliOSS.path"
Expand Down Expand Up @@ -81,6 +85,10 @@
<el-form-item label="Bucket 所在区域" :required="true">
<el-input v-model.trim="formTxCOS.region"
placeholder="如:ap-guangzhou"></el-input>
</el-form-item>
<el-form-item label="自定义CDN域名" :required="false">
<el-input v-model.trim="formTxCOS.cdnHost"
placeholder="如:https://imagecdn.alidaodao.com"></el-input>
</el-form-item>
<el-form-item label="存储路径">
<el-input v-model.trim="formTxCOS.path"
Expand Down Expand Up @@ -122,14 +130,16 @@ export default {
accessKeySecret: "",
bucket: "",
region: "",
path: ""
path: "",
cdnHost:""
},
formTxCOS: {
secretId: "",
secretKey: "",
bucket: "",
region: "",
path: ""
path: "",
cdnHost:""
},
options: [{
value: "default",
Expand Down

0 comments on commit 9848a76

Please sign in to comment.