将oss文件上传返回的http链接改为https链接

This commit is contained in:
YeMingfei666 2024-09-06 13:59:00 +08:00
parent e6d421dfb1
commit a81c8b8352
3 changed files with 14 additions and 3 deletions

View File

@ -11,7 +11,12 @@ const $config = {
bucket: "cashier-oss"
}
import { Notification } from 'element-ui'
function urlConversion(path) {
let reg = /^(https?:\/\/)([0-9a-z.]+)(:[0-9]+)?([/0-9a-z.]+)?(\?[0-9a-z&=]+)?(#[0-9-a-z]+)?/i
path = path.replace(reg, "https://$2$3$4$5$6");
return path
}
async function uploadAndDownloadFile(name, file, headers) {
return new Promise((resolve, reject) => {
try {
@ -85,7 +90,7 @@ class ossClient {
// return resp.requestUrls
console.log('------resp---');
console.log(resp)
return `${resp.requestUrls[0]}`.split('?')[0]
return urlConversion( `${resp.requestUrls[0]}`.split('?')[0])
} catch (e) {
console.log('------e---');
console.log(e);

View File

@ -99,6 +99,12 @@ export default {
this.dialogVisible = true;
},
onExceed(files ) {
const file=files[0];
const isExe = file.name.endsWith(".exe");
if (!isExe) {
this.$message.error("只允许上传.exe文件");
return false; //
}
console.log(files);
if(this.limit == 1&&this.fileList.length>0){
this.fileList.splice(0,1)

View File

@ -72,7 +72,7 @@
<el-table-column label="下载地址" prop="url">
<template v-slot="scope">
<a class="a" :href="scope.row.url" target="_blank">{{ scope.row.url }}</a>
<a class="a" :href="scope.row.url" >{{ scope.row.url }}</a>
</template>
</el-table-column>