73 lines
1.4 KiB
Vue
73 lines
1.4 KiB
Vue
<!-- eslint-disable vue/no-v-html -->
|
|
<template>
|
|
<!-- 用 v-html 渲染解析后的 HTML -->
|
|
<div class="markdown-body" v-html="safeHtml" />
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
interface Props {
|
|
content: string;
|
|
}
|
|
|
|
const props = defineProps<Props>();
|
|
|
|
const contentWithAbsoluteUrls = convertMedia(props.content);
|
|
|
|
// 将 Markdown 转换成 HTML
|
|
const safeHtml = computed(() => renderMarkdown(contentWithAbsoluteUrls));
|
|
// const safeHtml = computed(() => renderMarkdown(props.content))
|
|
|
|
console.log('Rendered HTML:', safeHtml.value);
|
|
</script>
|
|
|
|
<style>
|
|
.markdown-body {
|
|
padding: 10px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.markdown-body h1 {
|
|
color: var(--el-color-primary);
|
|
font-size: 1.5em;
|
|
margin-bottom: 0.5em;
|
|
text-align: center;
|
|
}
|
|
|
|
.markdown-body h2 {
|
|
color: var(--el-color-primary);
|
|
font-size: 1.5em;
|
|
margin-bottom: 0.5em;
|
|
}
|
|
|
|
.markdown-body h3 {
|
|
color: var(--el-color-primary);
|
|
font-size: 1.2em;
|
|
margin-bottom: 0.5em;
|
|
}
|
|
|
|
.markdown-body p {
|
|
text-indent: 2em;
|
|
text-align: justify;
|
|
margin: 0.5em 0;
|
|
margin-bottom: 1em;
|
|
}
|
|
|
|
.markdown-body ol {
|
|
list-style-type: decimal;
|
|
padding-left: 2em;
|
|
margin-bottom: 1em;
|
|
}
|
|
|
|
.markdown-body ul {
|
|
list-style-type: disc;
|
|
padding-left: 2em;
|
|
margin-bottom: 1em;
|
|
}
|
|
|
|
.markdown-body hr {
|
|
border: none;
|
|
border-top: 1px solid var(--el-border-color);
|
|
margin: 20px 0;
|
|
}
|
|
</style>
|