<script setup lang="ts">
|
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
import PdfViewer from '@/components/pdf/PdfViewer.vue'
|
import PdfViewerFull from '@/components/pdf/PdfViewerFull.vue'
|
import { ProductCenter } from '@/models/portalModels'
|
|
const pdfUrl = ref('')
|
const projectInfo = ref<ProductCenter>({} as ProductCenter)
|
|
onMounted(() => {
|
// 获取 sessionStorage 中的 pdfItem
|
const pdfItem = sessionStorage.getItem('pdfItem')
|
console.log('pdfItem:', pdfItem)
|
|
if (pdfItem) {
|
try {
|
projectInfo.value = JSON.parse(pdfItem)
|
if (projectInfo.value.url) {
|
pdfUrl.value = projectInfo.value.url
|
} else {
|
console.warn('pdfItem 中没有 url 字段')
|
}
|
} catch (e) {
|
console.error('解析 pdfItem 出错:', e)
|
}
|
} else {
|
console.warn('sessionStorage 中未找到 pdfItem')
|
}
|
|
|
|
})
|
|
onBeforeUnmount(() => {
|
// 组件卸载时移除事件监听
|
|
})
|
</script>
|
|
<template>
|
|
<div class="text-center" style="width: 100%;">
|
<h1 class="fw-bold">{{ projectInfo.name }}</h1>
|
<div class="d-flex justify-content-center align-items-center d-none d-md-flex" >
|
<!-- 动态加载组件 -->
|
<PdfViewerFull v-if="pdfUrl" style="width: 60%;" :src="pdfUrl" :scale="1.0" />
|
</div>
|
|
<div class="w-100 d-flex justify-content-center align-items-center d-block d-md-none main-layout" >
|
<!-- <PdfViewerFull v-if="pdfUrl" style="width: 100%;" :src="pdfUrl" :scale="1.0" /> -->
|
<!-- <PdfViewer v-if="pdfUrl" :src="pdfUrl" :scale="0.8" /> -->
|
<PdfViewerFull v-if="pdfUrl" style="width: 90%; ":src="pdfUrl" :scale="1.0" />
|
|
</div>
|
</div>
|
|
</template>
|