mirror of
https://github.com/Luzifer/share.git
synced 2025-01-06 18:56:03 +00:00
Display PDF documents inline on supported devices
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9435cb1324
commit
8c9dc8d307
2 changed files with 28 additions and 2 deletions
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container my-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div
|
<div
|
||||||
|
@ -36,6 +36,19 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="fileType.startsWith('application/pdf') && canViewPDF"
|
||||||
|
class="card position-relative"
|
||||||
|
style="padding-top: calc(297/210*100%);"
|
||||||
|
>
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<iframe
|
||||||
|
class="h-100 position-absolute start-0 top-0 w-100"
|
||||||
|
:src="path"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-else-if="fileType.startsWith('image/')"
|
v-else-if="fileType.startsWith('image/')"
|
||||||
class="card"
|
class="card"
|
||||||
|
@ -125,6 +138,19 @@ const rewrites = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
computed: {
|
||||||
|
canViewPDF(): boolean {
|
||||||
|
/*
|
||||||
|
* iOS reports they can display PDFs but they'll display only
|
||||||
|
* the first page without any means of navigation, therefore we
|
||||||
|
* disable PDF viewing on iOS
|
||||||
|
*/
|
||||||
|
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1
|
||||||
|
|
||||||
|
return navigator.pdfViewerEnabled && !isIOS
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
error: null,
|
error: null,
|
||||||
|
|
|
@ -20,4 +20,4 @@
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vue-i18n": "^9.14.2"
|
"vue-i18n": "^9.14.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue