Files
KnowledgeBase/resources/views/documents/preview.blade.php

71 lines
3.1 KiB
PHP

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>{{ $document->title }} - PDF 预览</title>
@vite(['resources/css/app.css'])
</head>
<body class="bg-gray-100 text-gray-900">
<div class="mx-auto flex min-h-screen max-w-7xl flex-col gap-4 p-4">
<header class="rounded-lg bg-white p-4 shadow-sm">
<div class="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
<div class="min-w-0 flex-1">
<h1 class="truncate text-2xl font-bold">{{ $document->title }}</h1>
<div class="mt-2 flex flex-wrap gap-4 text-sm text-gray-600">
<span>{{ $document->display_file_name }}</span>
<span>{{ $document->uploader->name }}</span>
<span>{{ $document->created_at->format('Y年m月d日 H:i') }}</span>
</div>
@if($document->description)
<p class="mt-3 text-gray-700">{{ $document->description }}</p>
@endif
</div>
<div class="flex flex-wrap gap-2">
<a href="{{ route('documents.download', $document) }}"
class="inline-flex items-center rounded-lg bg-green-600 px-4 py-2 font-medium text-white transition-colors hover:bg-green-700">
下载原文档
</a>
@if($canPreviewPdf)
<a href="{{ $previewPdfUrl }}"
class="inline-flex items-center rounded-lg bg-gray-700 px-4 py-2 font-medium text-white transition-colors hover:bg-gray-800"
target="_blank"
rel="noopener">
打开 PDF
</a>
@endif
</div>
</div>
</header>
<main class="min-h-[70vh] flex-1 overflow-hidden rounded-lg bg-white shadow-sm">
@if($canPreviewPdf)
<iframe
class="w-full bg-gray-100"
style="height: calc(100vh - 150px); min-height: 640px;"
src="{{ $previewPdfUrl }}"
title="{{ $document->title }} PDF 预览"
></iframe>
@else
<div class="flex min-h-[420px] flex-col items-center justify-center p-8 text-center text-gray-600">
<h2 class="mb-2 text-xl font-semibold text-gray-800">PDF 预览暂不可用</h2>
<p class="mb-6">该文档尚未完成转换或原文件不存在。</p>
<a href="{{ route('documents.download', $document) }}"
class="inline-flex items-center rounded-lg bg-green-600 px-6 py-3 font-medium text-white transition-colors hover:bg-green-700">
下载原始文档
</a>
</div>
@endif
</main>
</div>
</body>
</html>