From a52ca1c83e77f366fe56a3af1d0ae38f46beb85d Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期二, 10 六月 2025 09:32:02 +0800 Subject: [PATCH] 建议快照 拓展字段1列表 --- src/components/MarkdownView/index.vue | 35 +++++++++++++++++++++++++++-------- 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/components/MarkdownView/index.vue b/src/components/MarkdownView/index.vue index 74764d5..65541f6 100644 --- a/src/components/MarkdownView/index.vue +++ b/src/components/MarkdownView/index.vue @@ -34,8 +34,16 @@ /** 渲染 markdown */ const renderedMarkdown = computed(() => { - return md.render(props.content) + return formatContent(props.content) }) + +/** 保留换行符 */ +const formatContent = (text) => { + if (text) { + return text.replace(/\n/g, '<br>') + } + return text +} /** 初始化 **/ onMounted(async () => { @@ -51,14 +59,25 @@ <style lang="scss"> .markdown-view { - font-family: PingFang SC; - font-size: 0.95rem; - font-weight: 400; - line-height: 1.6rem; - letter-spacing: 0em; - text-align: left; - color: #3b3e55; max-width: 100%; + overflow-y: auto; /* 垂直方向溢出时显示滚动条 */ + overflow-x: hidden; /* 水平方向隐藏滚动条 */ + + /* Firefox */ + scrollbar-width: thin; + scrollbar-color: rgba(0, 0, 0, 0.15) transparent; + + /* WebKit */ + &::-webkit-scrollbar { + width: 6px; + background: transparent; + } + &::-webkit-scrollbar-thumb { + border-radius: 4px; + background: rgba(0, 0, 0, 0.15); + transition: background 0.3s; + &:hover { background: rgba(0, 0, 0, 0.25); } + } pre { position: relative; -- Gitblit v1.9.3