feat: C端支持溯源节点视频播放,后台节点支持上传视频

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 22:02:58 +08:00
co-authored by Cursor
parent 94d3ce18de
commit f47ed0233e
5 changed files with 51 additions and 7 deletions
+2
View File
@@ -178,6 +178,8 @@
"nodeLocation": "Location",
"nodeTime": "Time",
"nodeDesc": "Description",
"nodeImages": "Images",
"nodeVideos": "Videos",
"addCert": "Add Certificate",
"certName": "Certificate Name",
"certIssuer": "Issuer",
+2
View File
@@ -178,6 +178,8 @@
"nodeLocation": "地点",
"nodeTime": "发生时间",
"nodeDesc": "说明",
"nodeImages": "图片",
"nodeVideos": "视频",
"addCert": "添加认证文件",
"certName": "证书名称",
"certIssuer": "颁发机构",
+26 -6
View File
@@ -89,7 +89,16 @@
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
<div>{{ n.description }}</div>
<div class="node-media">
<n-image v-for="m in n.media" :key="m.url" :src="m.url" width="64" height="64" object-fit="cover" style="border-radius:6px" />
<template v-for="m in n.media" :key="m.url">
<video
v-if="isVideoMedia(m)"
:src="m.url"
controls
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" />
</template>
</div>
</n-timeline-item>
</n-timeline>
@@ -191,8 +200,11 @@
<n-form-item :label="t('pages.artwork.nodeDesc')">
<n-input v-model:value="nodeForm.description" type="textarea" :rows="2" />
</n-form-item>
<n-form-item :label="t('pages.artwork.images')">
<media-upload v-model="nodeForm.mediaFiles" type="image" :max="6" />
<n-form-item :label="t('pages.artwork.nodeImages')">
<media-upload v-model="nodeForm.images" type="image" :max="6" />
</n-form-item>
<n-form-item :label="t('pages.artwork.nodeVideos')">
<media-upload v-model="nodeForm.videos" type="video" :max="3" />
</n-form-item>
</n-form>
<template #footer>
@@ -337,16 +349,21 @@ async function saveBasic() {
const nodeModal = ref(false);
const nodeSaving = ref(false);
const editingNode = ref<number | null>(null);
const nodeForm = reactive<any>({ nodeType: NodeType.CREATE, title: '', occurredAt: null, location: '', description: '', mediaFiles: [] });
const nodeForm = reactive<any>({ nodeType: NodeType.CREATE, title: '', occurredAt: null, location: '', description: '', images: [], videos: [] });
function isVideoMedia(m: any) {
return m.type === 'video' || /\.(mp4|webm|mov|m4v)$/i.test(m.url || m.key || '');
}
function openNode(n?: any) {
editingNode.value = n?.id ?? null;
const media = (n?.media ?? []).map((m: any) => ({ key: m.key || m.url, url: m.url, name: m.name, type: m.type }));
Object.assign(nodeForm, {
nodeType: n?.nodeType ?? NodeType.CREATE,
title: n?.title ?? '',
occurredAt: n?.occurredAt ? fmtDate(n.occurredAt) : null,
location: n?.location ?? '',
description: n?.description ?? '',
mediaFiles: n?.media ? n.media.map((m: any) => ({ key: m.key || m.url, url: m.url, name: m.name })) : [],
images: media.filter((m: any) => !isVideoMedia(m)),
videos: media.filter((m: any) => isVideoMedia(m)),
});
nodeModal.value = true;
}
@@ -363,7 +380,10 @@ async function saveNode() {
occurredAt: nodeForm.occurredAt || undefined,
location: nodeForm.location,
description: nodeForm.description,
mediaFiles: nodeForm.mediaFiles.map((m: any) => ({ key: m.key, name: m.name, type: 'image' })),
mediaFiles: [
...nodeForm.images.map((m: any) => ({ key: m.key, name: m.name, type: 'image' })),
...nodeForm.videos.map((m: any) => ({ key: m.key, name: m.name, type: 'video' })),
],
};
if (editingNode.value) await artworkApi.updateNode(editingNode.value, payload);
else await artworkApi.createNode(artworkId.value, payload);
+20 -1
View File
@@ -70,7 +70,17 @@
<div class="tl-meta muted">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
<div v-if="n.description" class="tl-desc">{{ n.description }}</div>
<div v-if="n.media?.length" class="tl-media">
<img v-for="(m, j) in n.media" :key="j" :src="m.url" @click="openLightbox(m.url)" />
<template v-for="(m, j) in n.media" :key="j">
<video
v-if="isVideo(m)"
:src="m.url"
class="tl-video"
controls
playsinline
preload="metadata"
/>
<img v-else :src="m.url" @click="openLightbox(m.url)" />
</template>
</div>
</div>
</div>
@@ -160,6 +170,9 @@ function ellipsis(s?: string) {
if (!s) return '-';
return s.length > 16 ? `${s.slice(0, 8)}…${s.slice(-6)}` : s;
}
function isVideo(m: { type?: string; url?: string }) {
return m.type === 'video' || /\.(mp4|webm|mov|m4v)$/i.test(m.url || '');
}
function openLightbox(url: string) {
lightbox.value = url;
}
@@ -405,6 +418,12 @@ watch(
object-fit: cover;
border-radius: 8px;
}
.tl-video {
width: 100%;
max-height: 220px;
border-radius: 8px;
background: #000;
}
.cert-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);