Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sdream-ai-fe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
侯明涛
sdream-ai-fe
Commits
2c69520a
Commit
2c69520a
authored
Sep 09, 2025
by
weiw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修改docx文件预览
parent
31710951
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
src/components/FilePreviewModal/DocxPreview.css
+13
-0
src/components/FilePreviewModal/DocxPreview.tsx
+10
-1
src/components/FilePreviewModal/index.tsx
+2
-2
No files found.
src/components/FilePreviewModal/DocxPreview.css
0 → 100644
View file @
2c69520a
/* src/components/FilePreviewModal/DocxPreview.css */
.docx-document
{
width
:
100%
!important
;
padding
:
20px
20px
!important
;
margin-bottom
:
0px
!important
;
height
:
100%
!important
;
box-shadow
:
none
!important
;
}
.docx-document-wrapper
{
padding
:
0
!important
;
}
\ No newline at end of file
src/components/FilePreviewModal/DocxPreview.tsx
View file @
2c69520a
// src/components/FilePreviewModal/DocxPreview.tsx
import
React
,
{
useEffect
,
useRef
}
from
'react'
import
{
renderAsync
}
from
'docx-preview'
import
'./DocxPreview.css'
// 导入样式文件
interface
DocxPreviewProps
{
src
:
string
...
...
@@ -27,12 +28,16 @@ export const DocxPreview: React.FC<DocxPreviewProps> = ({ src, className = '', o
}
return
renderAsync
(
blob
,
containerRef
.
current
!
,
undefined
,
{
className
,
className
:
'docx-document'
,
// 使用特定类名避免样式冲突
inWrapper
:
true
,
breakPages
:
true
,
ignoreWidth
:
false
,
ignoreHeight
:
false
,
ignoreFonts
:
false
,
// 添加更多配置以改善渲染效果
renderHeaders
:
true
,
renderFooters
:
true
,
renderFootnotes
:
true
,
})
})
.
then
(()
=>
{
...
...
@@ -56,6 +61,10 @@ export const DocxPreview: React.FC<DocxPreviewProps> = ({ src, className = '', o
backgroundColor
:
'#fff'
,
maxWidth
:
'100%'
,
boxSizing
:
'border-box'
,
// 添加以下样式以改善显示效果
lineHeight
:
'1.6'
,
wordWrap
:
'break-word'
,
wordBreak
:
'break-word'
,
}
}
/>
)
...
...
src/components/FilePreviewModal/index.tsx
View file @
2c69520a
...
...
@@ -89,7 +89,7 @@ export const FilePreviewModal: React.FC<FilePreviewModalProps> = ({ isOpen, onCl
<
DocxPreview
key=
{
docUrl
}
// 添加key确保组件重新挂载
src=
{
docUrl
}
className=
"w-full"
className=
"w-full
min-h-full
"
onRendered=
{
handleDocumentRendered
}
onError=
{
handleDocumentError
}
/>
...
...
@@ -184,7 +184,7 @@ export const FilePreviewModal: React.FC<FilePreviewModalProps> = ({ isOpen, onCl
onClose=
{
handleClose
}
// 使用改进的关闭函数
size=
"3xl"
classNames=
{
{
base
:
'max-h-[90vh] max-w-[
5
0vw]'
,
base
:
'max-h-[90vh] max-w-[
8
0vw]'
,
body
:
'py-4'
,
header
:
'border-b border-divider'
,
footer
:
'border-t border-divider'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment