word 搜索优化

This commit is contained in:
cwchen 2025-11-12 11:26:00 +08:00
parent ee0581326a
commit 3d8ea635a8
1 changed files with 21 additions and 83 deletions

View File

@ -50,6 +50,7 @@
import * as docxPreview from 'docx-preview/dist/docx-preview.js'
const DEFAULT_DOC_URL = 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/11/11/887b35d28b2149b6a7555fb639be9411.docx'
// const DEFAULT_DOC_URL = 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/11/12/efec85cd3793469d9d0a6991d7d08f9b.doc'
export default {
name: 'DocumentSearchWord',
@ -132,8 +133,11 @@ export default {
inWrapper: true,
ignoreFonts: false,
breakPages: false,
ignoreWidth: false,
ignoreHeight: false,
})
this.wrapContentWithArticle(container)
this.normalizeTableStyles(container)
this.injectFontResolver(container)
this.docRendered = true
this.loading = false
@ -381,7 +385,6 @@ export default {
'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'ul', 'ol', 'blockquote', 'table'
]
console.log(node);
//
const allElements = Array.from(node.querySelectorAll(selectors.join(',')))
@ -473,6 +476,22 @@ export default {
elements.forEach(el => {
article.appendChild(el)
})
},
normalizeTableStyles(container) {
if (!container) return
const tables = container.querySelectorAll('table')
tables.forEach((table) => {
table.style.width = 'auto'
table.style.display = 'table'
table.style.tableLayout = 'auto'
table.style.textAlign = 'left'
table.style.margin = '0 auto'
const pTags = table.querySelectorAll('td p.docx-viewer.docx-viewer_TableParagraph')
pTags.forEach((p) => {
p.style.lineHeight = '1.2'
})
})
}
},
}
@ -531,6 +550,7 @@ export default {
padding: 0 8px;
}
.viewer-container {
flex: 1;
background: #ffffff;
@ -575,77 +595,6 @@ export default {
color: #1f2a62;
}
::v-deep .docx-wrapper table {
width: 100% !important;
border-collapse: separate !important;
border-spacing: 0 !important;
margin: 24px 0 !important;
background: rgba(255, 255, 255, 0.96) !important;
border-radius: 14px;
overflow: hidden;
box-shadow: inset 0 0 0 1px rgba(68, 112, 255, 0.2);
}
::v-deep .docx-wrapper table thead th {
background: linear-gradient(135deg, rgba(68, 112, 255, 0.45), rgba(68, 112, 255, 0.22)) !important;
color: #f5f7ff !important;
font-weight: 600 !important;
text-transform: uppercase;
letter-spacing: 0.6px;
padding: 14px 18px !important;
border-bottom: 1px solid rgba(36, 71, 182, 0.3) !important;
}
::v-deep .docx-wrapper table td,
::v-deep .docx-wrapper table th {
border-left: 1px solid rgba(68, 112, 255, 0.22) !important;
border-right: 1px solid rgba(68, 112, 255, 0.22) !important;
padding: 14px 18px !important;
vertical-align: top !important;
background: transparent !important;
color: #27325d !important;
font-size: 13px !important;
}
::v-deep .docx-wrapper table tr:nth-child(even) td {
background: rgba(242, 245, 255, 0.9) !important;
}
::v-deep .docx-wrapper table tr:nth-child(odd) td {
background: rgba(255, 255, 255, 0.98) !important;
}
::v-deep .docx-wrapper table tr:hover td {
background: rgba(68, 112, 255, 0.16) !important;
color: #1e2a62 !important;
}
::v-deep .docx-wrapper table td:first-child,
::v-deep .docx-wrapper table th:first-child {
border-left: none !important;
}
::v-deep .docx-wrapper table td:last-child,
::v-deep .docx-wrapper table th:last-child {
border-right: none !important;
}
::v-deep .docx-wrapper table tr:last-child td {
border-bottom: none !important;
}
::v-deep .docx-wrapper table caption {
caption-side: top !important;
padding: 12px 0 !important;
font-weight: 600 !important;
color: #3f57c0 !important;
font-size: 15px !important;
}
::v-deep .docx-wrapper table strong,
::v-deep .docx-wrapper table b {
color: #2a3aa8 !important;
}
::v-deep .docx-wrapper h1,
::v-deep .docx-wrapper h2,
@ -729,17 +678,6 @@ export default {
font-size: 13px;
}
.doc-content table td,
.doc-content table th {
border: 1px solid rgba(0, 0, 0, 0.18);
padding: 10px 12px;
vertical-align: top;
}
.doc-content table th {
background: rgba(68, 112, 255, 0.1);
font-weight: 600;
}
.doc-content img {
max-width: 100%;