|
@@ -44,8 +44,9 @@ export default {
|
|
this.pdfUrl = decodeURIComponent(pdfUrl)
|
|
this.pdfUrl = decodeURIComponent(pdfUrl)
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- // const pdfAssets = getAssetsFile('example-min.pdf')
|
|
|
|
- this.pdfUrl = 'https://cdn-common.jianyu360.com/cdn/assets/file/example.pdf'
|
|
|
|
|
|
+ const pdfAssets = getAssetsFile('example-min.pdf')
|
|
|
|
+ // this.pdfUrl = 'https://cdn-common.jianyu360.cn/cdn/assets/file/example.pdf'
|
|
|
|
+ this.pdfUrl = pdfAssets
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -65,6 +66,7 @@ export default {
|
|
url: pdfUrl,
|
|
url: pdfUrl,
|
|
disableRange: true,
|
|
disableRange: true,
|
|
disableAutoFetch: false, // 启动自动分块加载
|
|
disableAutoFetch: false, // 启动自动分块加载
|
|
|
|
+ workerSrc: 'pdfjs-dist/build/pdf.worker.mjs',
|
|
// 添加缓存头
|
|
// 添加缓存头
|
|
httpHeaders: {
|
|
httpHeaders: {
|
|
'Cache-Control': 'max-age=3600' // 缓存 1 小时
|
|
'Cache-Control': 'max-age=3600' // 缓存 1 小时
|
|
@@ -120,7 +122,8 @@ export default {
|
|
calculateScale(page) {
|
|
calculateScale(page) {
|
|
const containerWidth = document.getElementById('pdf-view-container').clientWidth
|
|
const containerWidth = document.getElementById('pdf-view-container').clientWidth
|
|
const viewport = page.getViewport({ scale: 1 })
|
|
const viewport = page.getViewport({ scale: 1 })
|
|
- return containerWidth / viewport.width
|
|
|
|
|
|
+ // 增加一个倍数来提高清晰度,例如 1.5
|
|
|
|
+ return (containerWidth / viewport.width) * 3
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|