diff --git a/public/config.js b/public/config.js index 0b0d293..bd7e2e6 100644 --- a/public/config.js +++ b/public/config.js @@ -7,4 +7,9 @@ window.config = { assetsUrl: 'https://insider.rangutech.com/app_static_data/images/', // 演示系统 featureUrl: 'http://192.168.3.32:5174/#/', + + // 内网文件下载地址 + oldDownLoadUrl: 'http://192.168.3.5:9193', + // 重定向文件下载链接 + redirectDownloadUrl: 'https://work.rangutech.cn:1006', } diff --git a/src/views/pc/download/index.vue b/src/views/pc/download/index.vue index 221d470..46ce9e8 100644 --- a/src/views/pc/download/index.vue +++ b/src/views/pc/download/index.vue @@ -108,6 +108,18 @@ const getList = () => { }) } +function replaceDomain(url, oldOrigin, newOrigin) { + try { + const u = new URL(url) + // 替换协议、主机名和端口 + const newUrlObj = new URL(newOrigin + u.pathname + u.search + u.hash) + return newUrlObj.toString() + } catch (e) { + // 降级处理:字符串替换 + return url.replace(oldOrigin, newOrigin) + } +} + /** * 下载文件 */ @@ -123,7 +135,9 @@ const downloadFileFN = (data) => { .then((res) => { console.log('res===>', res) if (res.code === 0 && res.data) { - window.open(res.data) + const newUrl = res.data.replace(window.config.oldDownLoadUrl, window.config.redirectDownloadUrl) + console.log(newUrl) + window.open(newUrl) } }) .catch((err) => {