mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-07-01 19:42:48 +08:00
499 lines
17 KiB
HTML
499 lines
17 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{$post.title} - 排版导出</title>
|
|
<link rel="stylesheet" href="/static/lib/layui/css/layui.css">
|
|
<style>
|
|
body { background: #f2f2f2; margin: 0; padding: 20px; }
|
|
|
|
.export-header {
|
|
background: #fff;
|
|
padding: 15px 20px;
|
|
border-radius: 4px;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
box-shadow: 0 1px 4px rgba(0,0,0,0.08);
|
|
}
|
|
.export-header h2 { margin: 0; font-size: 18px; color: #333; }
|
|
.export-header .header-info { color: #999; font-size: 13px; margin-top: 4px; }
|
|
.export-actions { display: flex; gap: 10px; align-items: center; }
|
|
|
|
.image-section {
|
|
background: #fff;
|
|
border-radius: 4px;
|
|
padding: 20px;
|
|
margin-bottom: 20px;
|
|
box-shadow: 0 1px 4px rgba(0,0,0,0.08);
|
|
}
|
|
.image-section h3 {
|
|
margin: 0 0 15px 0;
|
|
font-size: 16px;
|
|
color: #333;
|
|
border-bottom: 1px solid #eee;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
/* 长图卡片 */
|
|
.long-image-card {
|
|
height: 70px;
|
|
display: flex;
|
|
align-items: center;
|
|
background: #fff;
|
|
border: 1px solid #e8e8e8;
|
|
border-radius: 4px;
|
|
padding: 0 16px;
|
|
box-sizing: border-box;
|
|
}
|
|
.long-image-card .card-info {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
.long-image-card .card-icon {
|
|
width: 32px;
|
|
height: 32px;
|
|
background: #f0f0f0;
|
|
border-radius: 4px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 16px;
|
|
color: #999;
|
|
}
|
|
.long-image-card .card-label {
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
.long-image-card .card-dims {
|
|
font-size: 12px;
|
|
color: #999;
|
|
}
|
|
.long-image-card .card-actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
}
|
|
|
|
/* 缩略图网格 */
|
|
.thumb-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
gap: 16px;
|
|
}
|
|
.thumb-item {
|
|
background: #fafafa;
|
|
border: 1px solid #e8e8e8;
|
|
border-radius: 4px;
|
|
overflow: hidden;
|
|
cursor: pointer;
|
|
transition: box-shadow 0.2s, transform 0.15s;
|
|
position: relative;
|
|
}
|
|
.thumb-item:hover {
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
transform: translateY(-2px);
|
|
}
|
|
.thumb-item img {
|
|
width: 100%;
|
|
height: auto;
|
|
display: block;
|
|
}
|
|
.thumb-bar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 6px 10px;
|
|
background: #fff;
|
|
border-top: 1px solid #e8e8e8;
|
|
}
|
|
.thumb-bar .thumb-label {
|
|
font-size: 12px;
|
|
color: #666;
|
|
}
|
|
.thumb-bar .thumb-dl {
|
|
background: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
padding: 2px 6px;
|
|
color: #1e9fff;
|
|
font-size: 12px;
|
|
border-radius: 2px;
|
|
}
|
|
.thumb-bar .thumb-dl:hover {
|
|
background: #e8f4ff;
|
|
}
|
|
|
|
/* 全屏预览 */
|
|
.preview-overlay {
|
|
display: none;
|
|
position: fixed;
|
|
top: 0; left: 0; right: 0; bottom: 0;
|
|
background: rgba(0,0,0,0.85);
|
|
z-index: 19999;
|
|
justify-content: center;
|
|
align-items: center;
|
|
flex-direction: column;
|
|
}
|
|
.preview-overlay.active { display: flex; }
|
|
|
|
.preview-topbar {
|
|
position: absolute;
|
|
top: 0; left: 0; right: 0;
|
|
height: 48px;
|
|
background: rgba(0,0,0,0.6);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 0 20px;
|
|
color: #fff;
|
|
font-size: 14px;
|
|
z-index: 20001;
|
|
}
|
|
.preview-topbar button {
|
|
background: none;
|
|
border: 1px solid rgba(255,255,255,0.4);
|
|
color: #fff;
|
|
cursor: pointer;
|
|
padding: 4px 12px;
|
|
border-radius: 3px;
|
|
font-size: 13px;
|
|
}
|
|
.preview-topbar button:hover { background: rgba(255,255,255,0.15); }
|
|
.preview-topbar-actions { display: flex; gap: 8px; align-items: center; }
|
|
|
|
.preview-body {
|
|
max-width: 90vw;
|
|
max-height: calc(85vh - 48px);
|
|
height: calc(85vh - 48px);
|
|
margin-top: 48px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
.preview-body img {
|
|
max-height: calc(85vh - 48px);
|
|
max-width: 90vw;
|
|
height: auto;
|
|
width: auto;
|
|
object-fit: contain;
|
|
border-radius: 2px;
|
|
box-shadow: 0 4px 24px rgba(0,0,0,0.4);
|
|
user-select: none;
|
|
}
|
|
.preview-body img.portrait-fill {
|
|
height: calc(85vh - 48px);
|
|
width: auto;
|
|
max-width: 90vw;
|
|
}
|
|
|
|
/* 底部缩略图导航 */
|
|
.preview-nav {
|
|
position: absolute;
|
|
bottom: 0; left: 0; right: 0;
|
|
background: rgba(0,0,0,0.6);
|
|
padding: 10px 20px;
|
|
display: flex;
|
|
gap: 8px;
|
|
overflow-x: auto;
|
|
justify-content: center;
|
|
z-index: 20001;
|
|
}
|
|
.preview-nav-item {
|
|
width: 48px;
|
|
height: 64px;
|
|
flex-shrink: 0;
|
|
border: 2px solid transparent;
|
|
border-radius: 3px;
|
|
overflow: hidden;
|
|
cursor: pointer;
|
|
opacity: 0.5;
|
|
transition: opacity 0.15s, border-color 0.15s;
|
|
}
|
|
.preview-nav-item.active {
|
|
border-color: #1e9fff;
|
|
opacity: 1;
|
|
}
|
|
.preview-nav-item:hover { opacity: 0.85; }
|
|
.preview-nav-item img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
/* 左右切换箭头 */
|
|
.preview-arrow {
|
|
position: absolute;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
width: 44px;
|
|
height: 44px;
|
|
background: rgba(255,255,255,0.1);
|
|
border: 1px solid rgba(255,255,255,0.2);
|
|
border-radius: 50%;
|
|
color: #fff;
|
|
font-size: 22px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 20001;
|
|
user-select: none;
|
|
transition: background 0.15s;
|
|
}
|
|
.preview-arrow:hover { background: rgba(255,255,255,0.25); }
|
|
.preview-arrow.prev { left: 20px; }
|
|
.preview-arrow.next { right: 20px; }
|
|
|
|
.export-footer {
|
|
text-align: center;
|
|
padding: 20px;
|
|
color: #999;
|
|
font-size: 13px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="export-header">
|
|
<div>
|
|
<h2>{$post.title} - 排版导出</h2>
|
|
<div class="header-info">
|
|
共 {$output.page_count} 页
|
|
| 生成时间:{$output.create_time|date='Y-m-d H:i:s'}
|
|
</div>
|
|
</div>
|
|
<div class="export-actions">
|
|
<a href="{:url('post/phoneImage', ['id' => $post.id])}" class="layui-btn layui-btn-sm layui-btn-primary">
|
|
<i class="layui-icon layui-icon-return"></i> 返回排版
|
|
</a>
|
|
<a href="{$downloadZipUrl|raw}" class="layui-btn layui-btn-sm layui-btn-normal">
|
|
<i class="layui-icon layui-icon-download-circle"></i> 下载全部 ZIP
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
{if condition="$longImage"}
|
|
<div class="image-section">
|
|
<h3>长图</h3>
|
|
<div class="long-image-card">
|
|
<div class="card-info">
|
|
<span class="card-icon"><i class="layui-icon layui-icon-picture"></i></span>
|
|
<span class="card-label">长图</span>
|
|
<span class="card-dims">{$longImage.width} x {$longImage.height} px</span>
|
|
</div>
|
|
<div class="card-actions">
|
|
<button class="layui-btn layui-btn-sm layui-btn-primary btn-view-long-image" data-src="{$longImage.image_src|raw}">查看原图</button>
|
|
<button class="layui-btn layui-btn-sm layui-btn-normal btn-download-image" data-src="{$longImage.image_src|raw}" data-filename="long_image.jpg">下载</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
|
|
{if condition="count($pages) > 0"}
|
|
<div class="image-section">
|
|
<h3>分页图片({$output.page_count} 页)</h3>
|
|
<div class="thumb-grid">
|
|
{volist name="pages" id="page"}
|
|
<div class="thumb-item" data-index="{$i-1}">
|
|
<img src="{$page.image_src|raw}" alt="第{$page.page}页">
|
|
<div class="thumb-bar">
|
|
<span class="thumb-label">第 {$page.page} 页</span>
|
|
<button class="thumb-dl btn-download-image"
|
|
data-src="{$page.image_src|raw}" data-filename="page_{$page.page}.jpg">
|
|
下载
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{/volist}
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
|
|
<div class="export-footer">
|
|
排版导出 - 共 {$output.page_count} 页
|
|
</div>
|
|
|
|
<!-- 全屏预览浮层 -->
|
|
<div class="preview-overlay" id="previewOverlay">
|
|
<div class="preview-topbar">
|
|
<span id="previewTitle">第 1 页</span>
|
|
<div class="preview-topbar-actions">
|
|
<button id="previewDownload"><i class="layui-icon layui-icon-download-circle"></i> 下载此页</button>
|
|
<button id="previewClose">关闭</button>
|
|
</div>
|
|
</div>
|
|
<div class="preview-arrow prev" id="previewPrev">‹</div>
|
|
<div class="preview-arrow next" id="previewNext">›</div>
|
|
<div class="preview-body">
|
|
<img id="previewImg" src="" alt="">
|
|
</div>
|
|
<div class="preview-nav" id="previewNav"></div>
|
|
</div>
|
|
|
|
<script src="/static/lib/jquery/jquery-3.4.1.min.js"></script>
|
|
<script src="/static/lib/layui/layui.js"></script>
|
|
<script>
|
|
layui.use(['layer'], function () {
|
|
var layer = layui.layer;
|
|
|
|
// 收集所有图片数据(仅分页,不含长图)
|
|
var allImages = [];
|
|
{volist name="pages" id="p"}
|
|
allImages.push({ src: '{$p.image_src|raw}', label: '第 {$p.page} 页', filename: 'page_{$p.page}.jpg' });
|
|
{/volist}
|
|
|
|
var currentIndex = 0;
|
|
|
|
// ===== 查看长图(通过 Blob URL 在新标签打开) =====
|
|
function viewLongImage(src) {
|
|
try {
|
|
var parts = src.split(',');
|
|
var byteString = atob(parts[1]);
|
|
var mimeString = parts[0].split(':')[1].split(';')[0];
|
|
var ab = new ArrayBuffer(byteString.length);
|
|
var ia = new Uint8Array(ab);
|
|
for (var i = 0; i < byteString.length; i++) {
|
|
ia[i] = byteString.charCodeAt(i);
|
|
}
|
|
var blob = new Blob([ab], {type: mimeString});
|
|
var url = URL.createObjectURL(blob);
|
|
window.open(url, '_blank');
|
|
} catch(e) {
|
|
layer.msg('打开长图失败');
|
|
}
|
|
}
|
|
|
|
// 长图查看按钮
|
|
$(document).on('click', '.btn-view-long-image', function () {
|
|
viewLongImage($(this).data('src'));
|
|
});
|
|
|
|
// ===== 下载单张图片 =====
|
|
function downloadImage(src, filename) {
|
|
if (!src) { layer.msg('图片地址无效'); return; }
|
|
if (src.indexOf('data:') === 0) {
|
|
var link = document.createElement('a');
|
|
link.download = filename || 'image.jpg';
|
|
link.href = src;
|
|
link.click();
|
|
return;
|
|
}
|
|
var img = new Image();
|
|
img.crossOrigin = 'anonymous';
|
|
img.onload = function () {
|
|
var canvas = document.createElement('canvas');
|
|
canvas.width = img.naturalWidth;
|
|
canvas.height = img.naturalHeight;
|
|
canvas.getContext('2d').drawImage(img, 0, 0);
|
|
var link = document.createElement('a');
|
|
link.download = filename || 'image.jpg';
|
|
link.href = canvas.toDataURL('image/jpeg', 0.92);
|
|
link.click();
|
|
};
|
|
img.onerror = function () { window.open(src); };
|
|
img.src = src;
|
|
}
|
|
|
|
// 缩略图上的下载按钮
|
|
$(document).on('click', '.btn-download-image', function (e) {
|
|
e.stopPropagation();
|
|
downloadImage($(this).data('src'), $(this).data('filename'));
|
|
});
|
|
|
|
// ===== 全屏预览 =====
|
|
function showPreview(index) {
|
|
if (index < 0 || index >= allImages.length) return;
|
|
currentIndex = index;
|
|
var item = allImages[index];
|
|
|
|
var $img = $('#previewImg');
|
|
$img.attr('src', item.src);
|
|
// 重置样式
|
|
$img.removeClass('portrait-fill').css({ 'height': '', 'width': '' });
|
|
|
|
// 根据图片方向动态调整预览尺寸
|
|
var tempImg = new Image();
|
|
tempImg.onload = function () {
|
|
var isPortrait = tempImg.naturalHeight > tempImg.naturalWidth;
|
|
if (isPortrait) {
|
|
$img.addClass('portrait-fill');
|
|
}
|
|
};
|
|
tempImg.src = item.src;
|
|
|
|
$('#previewTitle').text(item.label + ' (' + (index + 1) + '/' + allImages.length + ')');
|
|
$('#previewDownload').data('src', item.src).data('filename', item.filename);
|
|
|
|
// 底部导航高亮
|
|
$('#previewNav .preview-nav-item').removeClass('active');
|
|
$('#previewNav .preview-nav-item').eq(index).addClass('active');
|
|
|
|
$('#previewOverlay').addClass('active');
|
|
document.body.style.overflow = 'hidden';
|
|
}
|
|
|
|
function closePreview() {
|
|
$('#previewOverlay').removeClass('active');
|
|
document.body.style.overflow = '';
|
|
}
|
|
|
|
// 点击缩略图打开预览
|
|
$(document).on('click', '.thumb-item', function (e) {
|
|
if ($(e.target).closest('.btn-download-image').length) return;
|
|
var idx = parseInt($(this).data('index'), 10);
|
|
showPreview(idx);
|
|
});
|
|
|
|
// 构建底部导航缩略图
|
|
var navHtml = '';
|
|
for (var i = 0; i < allImages.length; i++) {
|
|
navHtml += '<div class="preview-nav-item" data-nav-index="' + i + '"><img src="' + allImages[i].src + '"></div>';
|
|
}
|
|
$('#previewNav').html(navHtml);
|
|
|
|
// 底部导航点击
|
|
$(document).on('click', '.preview-nav-item', function () {
|
|
showPreview(parseInt($(this).data('nav-index'), 10));
|
|
});
|
|
|
|
// 关闭
|
|
$('#previewClose').on('click', closePreview);
|
|
$('#previewOverlay').on('click', function (e) {
|
|
if (e.target === this) closePreview();
|
|
});
|
|
|
|
// 上一页 / 下一页
|
|
$('#previewPrev').on('click', function (e) {
|
|
e.stopPropagation();
|
|
if (currentIndex > 0) showPreview(currentIndex - 1);
|
|
});
|
|
$('#previewNext').on('click', function (e) {
|
|
e.stopPropagation();
|
|
if (currentIndex < allImages.length - 1) showPreview(currentIndex + 1);
|
|
});
|
|
|
|
// 键盘快捷键
|
|
$(document).on('keydown.preview', function (e) {
|
|
if (!$('#previewOverlay').hasClass('active')) return;
|
|
if (e.key === 'Escape') closePreview();
|
|
if (e.key === 'ArrowLeft' || e.key === 'Left') { e.preventDefault(); $('#previewPrev').click(); }
|
|
if (e.key === 'ArrowRight' || e.key === 'Right') { e.preventDefault(); $('#previewNext').click(); }
|
|
});
|
|
|
|
// 预览中的下载
|
|
$('#previewDownload').on('click', function () {
|
|
downloadImage($(this).data('src'), $(this).data('filename'));
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|