hookehuyr

fix(PdfPreview): 添加自定义PDF配置以解决字体加载错误

在PdfPreview组件中添加了customPdfOption配置,包括cMapPacked和cMapUrl,以解决PDF字体加载错误的问题。具体配置参考了pdfjs的官方文档。

refactor(StudyDetailPage): 调整条件渲染和高度计算逻辑

将v-else改为v-if以更清晰地控制渲染逻辑,并调整了topWrapper的高度计算,增加了30px的额外空间。
......@@ -67,7 +67,12 @@ const initPdfViewer = () => {
fileName: props.title,
lang: "en",
print: false,
watermarkOptions: undefined
watermarkOptions: undefined,
customPdfOption: {
// customPdfOption是 pdfjs getDocument 函数中一些配置参数 具体可参考 https://mozilla.github.io/pdf.js/api/draft/module-pdfjsLib.html#~DocumentInitParameters
cMapPacked: true, //指定 CMap 是否是二进制打包的
cMapUrl: "https://cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/", //预定义 Adob​​e CMaps 所在的 URL。可解决字体加载错误
},
}
});
});
......
......@@ -66,7 +66,7 @@
</div>
<!-- 默认展示区 -->
<div v-else class="relative" style="border-bottom: 1px solid #e5e7eb;">
<div v-if="!course.course_type" class="relative" style="border-bottom: 1px solid #e5e7eb;">
<div class="h-24 bg-white flex items-center justify-center px-4">
<h3 class="text-lg font-medium text-gray-900 truncate">{{ course.title }}</h3>
</div>
......@@ -385,7 +385,7 @@ onMounted(async () => {
const topWrapper = document.querySelector('.top-wrapper');
const bottomWrapper = document.querySelector('.bottom-wrapper');
if (topWrapper) {
topWrapperHeight.value = topWrapper.clientHeight + 'px';
topWrapperHeight.value = topWrapper.clientHeight + 30 + 'px';
}
if (bottomWrapper) {
bottomWrapperHeight.value = bottomWrapper.clientHeight + 'px';
......