hookehuyr

refactor(PdfPreview): 优化代码格式并添加加载状态

- 调整模板中的 `van-popup` 属性换行,提高代码可读性
- 添加 `loading` 状态变量,用于管理 PDF 加载状态
- 统一 CSS 样式缩进,保持代码风格一致
......@@ -3,7 +3,8 @@
* @Description: PDF预览组件
-->
<template>
<van-popup v-if="show" :show="show" @update:show="emit('update:show', $event)" position="right" :style="{ height: '100%', width: '100%' }">
<van-popup v-if="show" :show="show" @update:show="emit('update:show', $event)" position="right"
:style="{ height: '100%', width: '100%' }">
<div id="pdf-container"></div>
<van-button class="close-btn" type="default" icon="cross" round @click="emit('update:show', false)" />
</van-popup>
......@@ -32,6 +33,7 @@ const props = defineProps({
const emit = defineEmits(['update:show']);
// PDF Worker路径
const loading = ref(false);
const pdfPath = new URL("@sunsetglow/vue-pdf-viewer/dist/libs/pdf.worker.min.js", import.meta.url).href;
// 监听show属性变化
......@@ -49,9 +51,7 @@ const initPdfViewer = () => {
loadFileUrl: props.url,
pdfPath: pdfPath,
loading: (load, fileInfo) => {
if (!load) {
// configPdfApiOptions.onSearch("", false);
}
loading.value = load;
},
pdfOption: {
search: false,
......@@ -76,21 +76,21 @@ const initPdfViewer = () => {
<style scoped>
#pdf-container {
width: 100%;
padding: 0px;
height: 100%;
width: 100%;
padding: 0px;
height: 100%;
}
.close-btn {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 100;
width: 40px;
height: 40px;
padding: 0;
border-radius: 50%;
background: rgba(0, 0, 0, 0.6);
color: #fff;
position: fixed;
right: 20px;
bottom: 20px;
z-index: 100;
width: 40px;
height: 40px;
padding: 0;
border-radius: 50%;
background: rgba(0, 0, 0, 0.6);
color: #fff;
}
</style>
......