feat: C端支持溯源节点视频播放,后台节点支持上传视频
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -65,4 +65,5 @@
|
|||||||
- 已知优化点(非阻塞):admin 因 `app.use(naive)` 全量引入,index chunk 较大(~452KB gzip),内部后台可接受;如需可改按需引入或 manualChunks。
|
- 已知优化点(非阻塞):admin 因 `app.use(naive)` 全量引入,index chunk 较大(~452KB gzip),内部后台可接受;如需可改按需引入或 manualChunks。
|
||||||
- 迭代(用户新需求):1) 语言包合并为单 json/语言(`locales/zh-CN.json`、`en-US.json`,含 common/menu/pages),默认中文;语言切换改为图标按钮(地球图标 + zh-CN 标记,下拉选择)。2) 主题改用 Naive 官方 light/darkTheme + 清凉青绿主色(theme.ts 仅最小覆盖),`useTheme` 组合式(light/dark/auto,auto 跟随系统),`ThemeSwitch` 图标下拉;App 用 n-global-style + :theme 切换;移除前端硬编码深蓝,统一 CSS 变量 `--brand`。3) 侧边栏改 `show-trigger="arrow-circle"`(官方垂直居中圆形收缩按钮),sider 取消 inverted 跟随主题。4) 追溯码新增分组(trace_code_group 表/groupId):分组管理弹窗、列表/生码按分组、短链列渲染为可点击 `<a target=_blank>`;5) 追溯码批量:DataTable 选择列 + 批量分组/启用/停用(后端 `/trace-codes/batch/group`、`/batch/status`,启用按激活/绑定状态恢复)。后端分组与批量已 API 验证通过。
|
- 迭代(用户新需求):1) 语言包合并为单 json/语言(`locales/zh-CN.json`、`en-US.json`,含 common/menu/pages),默认中文;语言切换改为图标按钮(地球图标 + zh-CN 标记,下拉选择)。2) 主题改用 Naive 官方 light/darkTheme + 清凉青绿主色(theme.ts 仅最小覆盖),`useTheme` 组合式(light/dark/auto,auto 跟随系统),`ThemeSwitch` 图标下拉;App 用 n-global-style + :theme 切换;移除前端硬编码深蓝,统一 CSS 变量 `--brand`。3) 侧边栏改 `show-trigger="arrow-circle"`(官方垂直居中圆形收缩按钮),sider 取消 inverted 跟随主题。4) 追溯码新增分组(trace_code_group 表/groupId):分组管理弹窗、列表/生码按分组、短链列渲染为可点击 `<a target=_blank>`;5) 追溯码批量:DataTable 选择列 + 批量分组/启用/停用(后端 `/trace-codes/batch/group`、`/batch/status`,启用按激活/绑定状态恢复)。后端分组与批量已 API 验证通过。
|
||||||
- 追溯码批量导出(按 PRD 6.3):导出支持 Excel/CSV 两种格式,可按当前筛选(分组/批次/状态/关键词)或所选 ids 导出;列含批次编号、分组、追溯码、随机短码、短链、二维码数据(DataURL)、生成时间;CSV 加 UTF-8 BOM。后端 `GET /trace-codes/export?format=xlsx|csv&groupId&batchId&status&keyword&ids`;后台改为"导出"下拉(Excel/CSV × 当前筛选/所选)。已 API 验证 xlsx/csv/所选。
|
- 追溯码批量导出(按 PRD 6.3):导出支持 Excel/CSV 两种格式,可按当前筛选(分组/批次/状态/关键词)或所选 ids 导出;列含批次编号、分组、追溯码、随机短码、短链、二维码数据(DataURL)、生成时间;CSV 加 UTF-8 BOM。后端 `GET /trace-codes/export?format=xlsx|csv&groupId&batchId&status&keyword&ids`;后台改为"导出"下拉(Excel/CSV × 当前筛选/所选)。已 API 验证 xlsx/csv/所选。
|
||||||
|
- C 端视频播放:节点媒体区分图片/视频(按 `type==='video'` 或扩展名判断),C 端用 `<video controls playsinline>` 播放、`<img>` 显示图片;后台节点弹窗拆分"图片/视频"两个上传区(视频走 /upload?type=video,≤100MB),保存时按 type 合并 mediaFiles;后台节点展示也用 video 播放。已 API 验证 type=video 贯通到公开溯源。
|
||||||
|
|
||||||
|
|||||||
@@ -178,6 +178,8 @@
|
|||||||
"nodeLocation": "Location",
|
"nodeLocation": "Location",
|
||||||
"nodeTime": "Time",
|
"nodeTime": "Time",
|
||||||
"nodeDesc": "Description",
|
"nodeDesc": "Description",
|
||||||
|
"nodeImages": "Images",
|
||||||
|
"nodeVideos": "Videos",
|
||||||
"addCert": "Add Certificate",
|
"addCert": "Add Certificate",
|
||||||
"certName": "Certificate Name",
|
"certName": "Certificate Name",
|
||||||
"certIssuer": "Issuer",
|
"certIssuer": "Issuer",
|
||||||
|
|||||||
@@ -178,6 +178,8 @@
|
|||||||
"nodeLocation": "地点",
|
"nodeLocation": "地点",
|
||||||
"nodeTime": "发生时间",
|
"nodeTime": "发生时间",
|
||||||
"nodeDesc": "说明",
|
"nodeDesc": "说明",
|
||||||
|
"nodeImages": "图片",
|
||||||
|
"nodeVideos": "视频",
|
||||||
"addCert": "添加认证文件",
|
"addCert": "添加认证文件",
|
||||||
"certName": "证书名称",
|
"certName": "证书名称",
|
||||||
"certIssuer": "颁发机构",
|
"certIssuer": "颁发机构",
|
||||||
|
|||||||
@@ -89,7 +89,16 @@
|
|||||||
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
||||||
<div>{{ n.description }}</div>
|
<div>{{ n.description }}</div>
|
||||||
<div class="node-media">
|
<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>
|
</div>
|
||||||
</n-timeline-item>
|
</n-timeline-item>
|
||||||
</n-timeline>
|
</n-timeline>
|
||||||
@@ -191,8 +200,11 @@
|
|||||||
<n-form-item :label="t('pages.artwork.nodeDesc')">
|
<n-form-item :label="t('pages.artwork.nodeDesc')">
|
||||||
<n-input v-model:value="nodeForm.description" type="textarea" :rows="2" />
|
<n-input v-model:value="nodeForm.description" type="textarea" :rows="2" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item :label="t('pages.artwork.images')">
|
<n-form-item :label="t('pages.artwork.nodeImages')">
|
||||||
<media-upload v-model="nodeForm.mediaFiles" type="image" :max="6" />
|
<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-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -337,16 +349,21 @@ async function saveBasic() {
|
|||||||
const nodeModal = ref(false);
|
const nodeModal = ref(false);
|
||||||
const nodeSaving = ref(false);
|
const nodeSaving = ref(false);
|
||||||
const editingNode = ref<number | null>(null);
|
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) {
|
function openNode(n?: any) {
|
||||||
editingNode.value = n?.id ?? null;
|
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, {
|
Object.assign(nodeForm, {
|
||||||
nodeType: n?.nodeType ?? NodeType.CREATE,
|
nodeType: n?.nodeType ?? NodeType.CREATE,
|
||||||
title: n?.title ?? '',
|
title: n?.title ?? '',
|
||||||
occurredAt: n?.occurredAt ? fmtDate(n.occurredAt) : null,
|
occurredAt: n?.occurredAt ? fmtDate(n.occurredAt) : null,
|
||||||
location: n?.location ?? '',
|
location: n?.location ?? '',
|
||||||
description: n?.description ?? '',
|
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;
|
nodeModal.value = true;
|
||||||
}
|
}
|
||||||
@@ -363,7 +380,10 @@ async function saveNode() {
|
|||||||
occurredAt: nodeForm.occurredAt || undefined,
|
occurredAt: nodeForm.occurredAt || undefined,
|
||||||
location: nodeForm.location,
|
location: nodeForm.location,
|
||||||
description: nodeForm.description,
|
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);
|
if (editingNode.value) await artworkApi.updateNode(editingNode.value, payload);
|
||||||
else await artworkApi.createNode(artworkId.value, payload);
|
else await artworkApi.createNode(artworkId.value, payload);
|
||||||
|
|||||||
@@ -70,7 +70,17 @@
|
|||||||
<div class="tl-meta muted">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
<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.description" class="tl-desc">{{ n.description }}</div>
|
||||||
<div v-if="n.media?.length" class="tl-media">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -160,6 +170,9 @@ function ellipsis(s?: string) {
|
|||||||
if (!s) return '-';
|
if (!s) return '-';
|
||||||
return s.length > 16 ? `${s.slice(0, 8)}…${s.slice(-6)}` : s;
|
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) {
|
function openLightbox(url: string) {
|
||||||
lightbox.value = url;
|
lightbox.value = url;
|
||||||
}
|
}
|
||||||
@@ -405,6 +418,12 @@ watch(
|
|||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
.tl-video {
|
||||||
|
width: 100%;
|
||||||
|
max-height: 220px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
.cert-grid {
|
.cert-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
|||||||
Reference in New Issue
Block a user