tj
2025-04-30 7f199d396989b430f625c152df5c5da708ed86ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<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>