added new logout button and fixed pdf viewing

This commit is contained in:
2025-08-14 11:10:09 +02:00
parent 1c2a0416bb
commit 7ef49b4924
4 changed files with 35 additions and 6 deletions
@@ -14,7 +14,6 @@ Vue.component('tt-fullscreen-viewer', {
panStart: { x: 0, y: 0 },
lastPinchDist: 0,
isLoading: true,
// NEW: Flag to determine if running as a PWA/standalone app
isStandalone: false,
}),
computed: {
@@ -125,7 +124,8 @@ Vue.component('tt-fullscreen-viewer', {
const script = document.createElement('script');
script.id = 'pdfjs-script';
script.src = 'https://mozilla.github.io/pdf.js/build/pdf.js'; // CDN URL
script.type = 'module';
script.src = 'https://unpkg.com/pdfjs-dist@5.4.54/build/pdf.mjs'; // CDN URL
script.onload = () => resolve();
script.onerror = (err) => {
console.error("Failed to load PDF.js script.", err);
@@ -143,7 +143,7 @@ Vue.component('tt-fullscreen-viewer', {
try {
await this.loadPdfJsScript();
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://mozilla.github.io/pdf.js/build/pdf.worker.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@5.4.54/build/pdf.worker.min.mjs';
const pdf = await pdfjsLib.getDocument(url).promise;
// For simplicity, we render the first page. Add pagination controls as needed.
@@ -151,9 +151,17 @@ Vue.component('tt-fullscreen-viewer', {
const canvas = this.$refs.pdfCanvas;
if (!canvas) return; // Exit if canvas is not available
const container = canvas.parentElement; // Get the container to calculate size from
if (!container) return;
const context = canvas.getContext('2d');
const viewport = page.getViewport({ scale: 1.5 });
const unscaledViewport = page.getViewport({ scale: 1 });
const scale = Math.min(
container.clientWidth / unscaledViewport.width,
container.clientHeight / unscaledViewport.height
);
const viewport = page.getViewport({ scale: scale });
canvas.height = viewport.height;
canvas.width = viewport.width;
@@ -217,8 +225,8 @@ Vue.component('tt-fullscreen-viewer', {
</div>
</template>
<div v-else-if="isPdf(currentItem) && isStandalone" v-show="!isLoading" class="tt-fullscreen-pdf-container">
<canvas ref="pdfCanvas" class="tt-fullscreen-pdf"></canvas>
<div v-else-if="isPdf(currentItem) && isStandalone" v-show="!isLoading" class="tt-fullscreen-pdf-standalone-container">
<canvas ref="pdfCanvas" class="tt-fullscreen-pdf-standalone"></canvas>
</div>
<iframe v-else-if="isPdf(currentItem)" v-show="!isLoading" :src="contentSrc" class="tt-fullscreen-pdf"