From 71a112b7d78698b7e4df94e6255bf302bf415b35 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: 星期一, 20 十月 2025 16:28:53 +0800
Subject: [PATCH] 修改
---
src/views/build/conpanyFunctionConsult/digitalFileDep/techType/index.vue | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/views/build/conpanyFunctionConsult/digitalFileDep/techType/index.vue b/src/views/build/conpanyFunctionConsult/digitalFileDep/techType/index.vue
index e20fb49..10eb3b0 100644
--- a/src/views/build/conpanyFunctionConsult/digitalFileDep/techType/index.vue
+++ b/src/views/build/conpanyFunctionConsult/digitalFileDep/techType/index.vue
@@ -99,13 +99,24 @@
})
const openFile = async(path)=>{
- try {
- // 1. 获取文件
- const response = await fetch(import.meta.env.VITE_APP_BASE_API + '/' + path);
- const arrayBuffer = await response.arrayBuffer();
- // 2. 创建新窗口
- const win = window.open('', '_blank');
- win.document.write(`
+ const ext = path.split('.').pop().toLowerCase();
+ if (ext === 'doc') {
+ ElMessageBox.confirm('暂不支持线上预览.doc文件,是否下载查看?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
+ window.open(`${import.meta.env.VITE_APP_BASE_API}/${path}`, '_blank');
+ }).catch(() => {
+ console.log('取消预览')
+ });
+ return
+ }else if(ext == 'pdf' || ext == 'jpg' ){
+ window.open(`${import.meta.env.VITE_APP_BASE_API}/${path}`, '_blank');
+ }else{
+ try {
+ // 1. 获取文件
+ const response = await fetch(import.meta.env.VITE_APP_BASE_API + '/' + path);
+ const arrayBuffer = await response.arrayBuffer();
+ // 2. 创建新窗口
+ const win = window.open('', '_blank');
+ win.document.write(`
<!DOCTYPE html>
<html>
<head>
@@ -120,12 +131,13 @@
</body>
</html>
`);
- // 3. 渲染 DOCX
- await renderAsync(arrayBuffer, win.document.getElementById('container'));
+ // 3. 渲染 DOCX
+ await renderAsync(arrayBuffer, win.document.getElementById('container'));
- } catch (error) {
- console.error('预览失败:', error);
- alert(`预览失败: ${error.message}`);
+ } catch (error) {
+ console.error('预览失败:', error);
+ alert(`预览失败: ${error.message}`);
+ }
}
}
const getList = async () => {
--
Gitblit v1.9.2