feat: C端支持溯源节点视频播放,后台节点支持上传视频
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -178,6 +178,8 @@
|
||||
"nodeLocation": "Location",
|
||||
"nodeTime": "Time",
|
||||
"nodeDesc": "Description",
|
||||
"nodeImages": "Images",
|
||||
"nodeVideos": "Videos",
|
||||
"addCert": "Add Certificate",
|
||||
"certName": "Certificate Name",
|
||||
"certIssuer": "Issuer",
|
||||
|
||||
@@ -178,6 +178,8 @@
|
||||
"nodeLocation": "地点",
|
||||
"nodeTime": "发生时间",
|
||||
"nodeDesc": "说明",
|
||||
"nodeImages": "图片",
|
||||
"nodeVideos": "视频",
|
||||
"addCert": "添加认证文件",
|
||||
"certName": "证书名称",
|
||||
"certIssuer": "颁发机构",
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user