From 8cfd8d3e9c5700480c9be7b78037e3957e98ee71 Mon Sep 17 00:00:00 2001 From: yangzhe Date: Fri, 11 Jul 2025 15:58:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4Markdown=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E6=A0=B7=E5=BC=8F=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E8=87=AA=E5=8A=A8=E6=8D=A2=E8=A1=8C=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E5=9D=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../markdown-viewer/markdown-viewer.vue | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/components/markdown-viewer/markdown-viewer.vue b/components/markdown-viewer/markdown-viewer.vue index 33b011d..16b3661 100644 --- a/components/markdown-viewer/markdown-viewer.vue +++ b/components/markdown-viewer/markdown-viewer.vue @@ -54,9 +54,21 @@ export default { renderedContent() { if (!this.content) return ''; try { - // 添加自定义样式 - const styleTag = this.customStyle ? - `` : ''; + // 添加自定义样式,确保内容自动换行 + const styleTag = ``; // 渲染Markdown为HTML const htmlContent = marked(this.content); @@ -77,5 +89,25 @@ export default { .markdown-container { padding: 20rpx; + overflow-wrap: break-word; + word-wrap: break-word; + word-break: break-word; +} + +/* 全局样式,确保所有元素都能自动换行 */ +.markdown-container >>> * { + max-width: 99% !important; + white-space: normal !important; + word-break: break-word !important; + overflow-wrap: break-word !important; +} + +/* 特别处理代码块 */ +.markdown-container >>> pre, +.markdown-container >>> code { + white-space: pre-wrap !important; + word-break: break-word !important; + overflow-wrap: break-word !important; + max-width: 99% !important; } \ No newline at end of file