From 7843beb715d20817996dfecf194c306d2ba36a0a Mon Sep 17 00:00:00 2001 From: zhangtianqi <ztq17634040974@163.com> Date: Thu, 28 Dec 2023 22:56:32 +0800 Subject: [PATCH] 禅道:漏洞上传文件 --- hg-monitor-web-base/src/main/resources/static/src/controller/main-biz-card.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.html | 1 - hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.js | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/hg-monitor-web-base/src/main/resources/static/src/controller/main-biz-card.js b/hg-monitor-web-base/src/main/resources/static/src/controller/main-biz-card.js index c993ecc..133f55c 100644 --- a/hg-monitor-web-base/src/main/resources/static/src/controller/main-biz-card.js +++ b/hg-monitor-web-base/src/main/resources/static/src/controller/main-biz-card.js @@ -128,6 +128,9 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions </div> <div><input type="hidden" id="vulnerabilitiesId" name="vulnerabilitiesId" value="${d.id}"></div> </div> + <div class="layui-form-item"> + <button type="button" class="download">下载附件</button> + </div> </form> ` //漏洞处理抽屉 @@ -143,6 +146,50 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions move: false, success:()=>{ form.render(); + if(d.filePath){ + + let docMime = d.fileName.slice(d.fileName.lastIndexOf('.') + 1); // 获取文件的后缀 + console.log(docMime,"-------"); + // 判断下载的文件类型 + let mineType = ""; + switch (docMime) { + case "xls": + mineType = "application/vnd.ms-excel"; + break; + case "xlsx": + mineType = "application/vnd.ms-excel"; + break; + case "docx": + mineType = "application/msword"; + break; + case "doc": + mineType = "application/msword"; + break; + case "zip": + mineType = "application/zip"; + break; + case "html": + mineType = "text/html"; + break; + case "markdown": + mineType = "text/markdown"; + break; + default: + break; + } + let url = window.URL.createObjectURL(new Blob([d.filePath], { type: mineType })); + console.log(url); + let link = document.createElement("a"); + link.style.display = "none"; + link.href = url; + link.setAttribute("download", d.fileName); + document.body.appendChild(link); + link.click(); + // 销毁超连接 + window.URL.revokeObjectURL(url); + }else{ + layer.msg("无附件信息", {offset: '15px', icon: 7, time: 1000}); + } }, yes:(index)=>{ var formData = form.val('vulnerabilityForm'); diff --git a/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.html b/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.html index fca3bbd..5f7552c 100644 --- a/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.html +++ b/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.html @@ -118,7 +118,6 @@ ref="upload" action="#" style="display: inline" - :auto-upload="false" :limit="1" :on-exceed="handleExceed" :auto-upload="false" diff --git a/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.js b/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.js index c11fac8..9c1d1b2 100644 --- a/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.js +++ b/hg-monitor-web-qh/src/main/resources/static/vue3/src/views/documentationManagement/vulnerability.js @@ -263,7 +263,7 @@ export default { default: break; } - let url = window.URL.createObjectURL(new Blob([row.filePath], { type: "application/msword" })); + let url = window.URL.createObjectURL(new Blob([row.filePath], { type: mineType })); let link = document.createElement("a"); link.style.display = "none"; link.href = url; -- libgit2 0.24.0