fix: 统一后台详情图片预览

This commit is contained in:
Nixevol
2026-07-05 05:07:01 +08:00
parent 0182c06e3e
commit 3619929195
2 changed files with 43 additions and 2 deletions
+1
View File
@@ -158,6 +158,7 @@
- 客户端基础信息字段排版(2026-07-05):溯源详情页基础信息字段行由 flex 改为 grid,标签列桌面端固定 132px、窄屏 118px,值列自适应;标签单行省略、值列加粗并允许换行,避免“创作年代 / 出品时间”等长标签把字段行撑乱或与值错位。
- 图片预览滚轮缩放兜底(2026-07-05):后台和客户端共用的 `openMediaViewer` 在 PhotoSwipe `wheel` 事件中补充自定义缩放处理,拦截默认滚轮行为并按鼠标位置缩放当前图片;缩放上限至少放宽到初始比例 6 倍或 4 倍,避免认证文件、较小证书图等因 PhotoSwipe 默认上限判断导致鼠标滚轮看似无法放大。视频项仍通过 `isZoomable()` 自动跳过。
- 后台排序媒体预览分流(2026-07-05):`MediaSorter` 用于作品主图和溯源节点媒体排序上传;点击图片时现在只把图片项传入 PhotoSwipe 预览队列,打开样式与认证文件等图片预览保持一致,避免混入视频项影响图片查看体验。点击视频仍沿用原有媒体预览逻辑。
- 后台详情页图片预览统一(2026-07-05):艺术品详情页中溯源时间轴图片和认证文件封面不再使用 Naive UI `n-image` 预览层,统一改为普通缩略图点击后调用后台 `openMediaViewer`。这样打开样式与后台其他图片预览一致,并能使用 PhotoSwipe 的鼠标滚轮缩放兜底;视频仍保持原页面内原生 video 控件。
## 当前代码基准与注意事项
+42 -2
View File
@@ -181,7 +181,13 @@
preload="metadata"
style="max-height: 90px; border-radius: 6px; background: #000"
/>
<n-image v-else :src="m.url" width="64" height="64" object-fit="cover" style="border-radius:6px" />
<img
v-else
class="node-media-image"
:src="m.url"
:alt="m.name || n.title"
@click="previewNodeImage(n.media, m)"
/>
</template>
</div>
</n-timeline-item>
@@ -203,7 +209,13 @@
<n-grid-item v-for="c in certs" :key="c.id ?? c.localId" span="2 m:1">
<n-card size="small" :title="c.name">
<template #cover>
<n-image v-if="c.watermarkUrl || c.originUrl" :src="c.watermarkUrl || c.originUrl" object-fit="cover" style="height:140px;width:100%" />
<img
v-if="c.watermarkUrl || c.originUrl"
class="cert-preview-image"
:src="c.watermarkUrl || c.originUrl"
:alt="c.name"
@click="previewCert(c)"
/>
<div v-else class="cert-pending">{{ t('pages.artwork.watermarkPending') }}</div>
</template>
<div class="cert-meta">{{ c.issuer || '-' }}</div>
@@ -324,6 +336,7 @@ import { artworkApi, templateApi } from '@/api';
import { useAuthStore } from '@/stores/auth';
import MediaUpload from '@/components/MediaUpload.vue';
import MediaSorter from '@/components/MediaSorter.vue';
import { openMediaViewer } from '@/composables/openMediaViewer';
import { message, dialog } from '@/utils/feedback';
import { fmtDate, fmtSecond } from '@/utils/format';
@@ -659,6 +672,19 @@ const nodeForm = reactive<any>({ nodeType: NodeType.CREATE, title: '', occurredA
function isVideoMedia(m: any) {
return m.type === 'video' || /\.(mp4|webm|mov|m4v)$/i.test(m.url || m.key || '');
}
function toViewerItem(m: any) {
return { url: m.url || m.key, name: m.name || m.key, type: m.type };
}
function previewNodeImage(media: any[] = [], current: any) {
const images = (media || []).filter((item) => !isVideoMedia(item) && (item.url || item.key));
const index = images.findIndex((item) => item === current);
void openMediaViewer(images.map(toViewerItem), Math.max(index, 0));
}
function previewCert(cert: any) {
const url = cert.watermarkUrl || cert.originUrl;
if (!url) return;
void openMediaViewer([{ url, name: cert.name || cert.originKey || cert.watermarkKey }]);
}
function openNode(n?: any) {
editingNode.value = n?.id ?? null;
editingNodeLocalId.value = n?.localId ?? null;
@@ -810,10 +836,24 @@ onMounted(async () => {
margin-top: 6px;
flex-wrap: wrap;
}
.node-media-image {
width: 64px;
height: 64px;
border-radius: 6px;
object-fit: cover;
cursor: zoom-in;
}
.cert-meta {
font-size: 12px;
color: #6b7280;
}
.cert-preview-image {
width: 100%;
height: 140px;
object-fit: cover;
cursor: zoom-in;
display: block;
}
.cert-pending {
height: 140px;
display: flex;