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
+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;