diff --git a/src/views/utility/index.vue b/src/views/utility/index.vue index e321861..59550f2 100644 --- a/src/views/utility/index.vue +++ b/src/views/utility/index.vue @@ -142,13 +142,23 @@ export default { // 打开文件所在文件夹 // 注意:浏览器安全限制禁止直接访问本地文件系统 handleOpenPath(row) { - try { - this.$message.error( - `由于浏览器安全限制,无法直接打开本地文件夹。

文件夹路径:${row.folderPath}

请在文件资源管理器中手动打开此路径。` - ); - } catch (e) { - this.$message.error("打开失败:" + e.message); - } + // const link = document.createElement("a"); + // link.href = row.filePath; + // link.download = row.name; + // link.click(); + // 4. 创建a标签模拟点击下载 + const link = document.createElement("a"); + link.href = row.filePath; + link.download = row.name; // 自定义文件名 + 后缀 + document.body.appendChild(link); + link.click(); + // 5. 释放内存 + document.body.removeChild(link); + window.URL.revokeObjectURL(downloadUrl); + // 弹窗引导操作 + this.$message.info( + "文件已开始下载,请在浏览器下载列表右键打开文件所在文件夹" + ); }, }, };