update
This commit is contained in:
@@ -75,7 +75,7 @@ async def download_html(guide_id: str):
|
|||||||
html_path, _ = final_paths(guide["topic"], guide["format"])
|
html_path, _ = final_paths(guide["topic"], guide["format"])
|
||||||
if not html_path.exists():
|
if not html_path.exists():
|
||||||
raise HTTPException(404, "Datei nicht gefunden")
|
raise HTTPException(404, "Datei nicht gefunden")
|
||||||
return FileResponse(html_path, filename=html_path.name, media_type="text/html")
|
return FileResponse(html_path, media_type="text/html", content_disposition_type="inline")
|
||||||
|
|
||||||
|
|
||||||
@router.post("/guides/{guide_id}/rework")
|
@router.post("/guides/{guide_id}/rework")
|
||||||
|
|||||||
@@ -1,17 +1,28 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { pdfUrl, htmlUrl } from '../api.js'
|
import { computed } from 'vue'
|
||||||
|
import { htmlUrl } from '../api.js'
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
previewGuide: { type: Object, default: null },
|
previewGuide: { type: Object, default: null },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const LANDSCAPE_FORMATS = ['OnePager', 'Cheatsheet']
|
||||||
|
const isLandscape = computed(() => LANDSCAPE_FORMATS.includes(props.previewGuide?.format))
|
||||||
|
|
||||||
|
function injectPadding(e) {
|
||||||
|
if (isLandscape.value) return
|
||||||
|
const doc = e.target.contentDocument
|
||||||
|
if (!doc) return
|
||||||
|
const style = doc.createElement('style')
|
||||||
|
style.textContent = '@media screen { body { padding: 2.5rem 3rem; } }'
|
||||||
|
doc.head?.appendChild(style)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="detail">
|
<div class="detail">
|
||||||
<div class="preview" v-if="previewGuide">
|
<div class="preview" v-if="previewGuide">
|
||||||
<object :data="pdfUrl(previewGuide.id)" type="application/pdf" class="preview-frame">
|
<iframe :src="htmlUrl(previewGuide.id)" class="preview-frame" :class="{ landscape: isLandscape }" title="Guide-Vorschau" @load="injectPadding"></iframe>
|
||||||
<p>PDF kann nicht angezeigt werden. <a :href="pdfUrl(previewGuide.id)" target="_blank">Direkt öffnen</a></p>
|
|
||||||
</object>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="empty-preview" v-else>
|
<div class="empty-preview" v-else>
|
||||||
@@ -30,6 +41,9 @@ defineProps({
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 2rem;
|
||||||
|
background: #f0f1f4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.preview-header {
|
.preview-header {
|
||||||
@@ -62,8 +76,15 @@ defineProps({
|
|||||||
|
|
||||||
.preview-frame {
|
.preview-frame {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-width: 900px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
border: none;
|
border: none;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-frame.landscape {
|
||||||
|
max-width: 1180px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-preview {
|
.empty-preview {
|
||||||
|
|||||||
Reference in New Issue
Block a user