feat: 节点图片支持逐张标题与默认收缩展开,修复C端放大后无法拖动

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-30 12:26:56 +08:00
co-authored by Cursor
parent a16e6f1165
commit f8430bda90
10 changed files with 240 additions and 73 deletions
+1
View File
@@ -73,6 +73,7 @@
- 脚本增强(二):手动模式自动建库。`dev.py` 手动连接外部 MySQL 时,迁移前调用 `_lib.ensure_mysql_database`(依赖 `pymysql`):库已存在则跳过,不存在则以 `utf8mb4`/`utf8mb4_unicode_ci` 创建;建库账号可单独指定(交互询问"建库管理员账号/密码",默认用业务账号,并记忆到 `db_admin`),权限不足/连接失败时打印可手动执行的 `CREATE DATABASE` SQL 并中止。库名做了合法性校验(仅字母数字下划线)。已对 docker MySQL 实测四分支:已存在库识别、新库创建(确认 utf8mb4)、幂等再确保、错误密码报错提示,均符合预期。
说明:启动建库/建表/初始化数据总体行为——表结构由 `prisma migrate deploy` 应用 migrations 自动创建(幂等);数据由 `seed.ts` 幂等初始化(dev.py 默认执行,`--no-seed` 跳过);库本身在 auto/docker 模式由 `MYSQL_DATABASE` 首次初始化创建、在 manual 模式由上述 `ensure_mysql_database` 创建。生产容器 `Dockerfile.api` 启动会 `migrate deploy` 自动建表,但不跑 seed。
- PRD 全面修复(2026-06-29,对照 `aidocs/PRD差距与修复清单.md`):① 出库 §6.4——导入列补齐(批次/出库实况图/上链哈希·时间·区块高度)、后台「单条录入」标签页+实况图上传+上链分区、导入校验文件类型与字段格式、填写哈希则写 ONCHAIN 存证;② 审核 §10.1——`Artwork.auditStatus`(PENDING/APPROVED/REJECTED)+审核字段,`POST /artworks/:id/audit`(AUDITOR),运营编辑后回 PENDING,后台「内容审核」页,公开溯源仅展示 APPROVED;③ 日志保留 §6.5——`@nestjs/schedule` + `LogRetentionService` 每日按 logRetentionDays 清理;④ 查询日志——`QueryLog` 补 code/sku/archiveNo/batchNo/queryCount/firstActivatedAt/browser/os,检索支持 SKU/批次/code,后台列+筛选补齐,`ua.util` 加浏览器解析;⑤ 权限——`/upload` 限 OPERATOR+,路由角色守卫+菜单按角色隐藏,追溯码批量「标记异常 ABNORMAL」接口;⑥ 建档动态字段按类型渲染(日期/多行/数字/链接/图片/文件),模板字段上下排序+启用停用开关;⑦ C 端——唯一追溯码、本次查询时间、未上链提示、隐私说明、证书类型/签发时间、图片懒加载、交易哈希+数据哈希。新增迁移 `fix_pack_audit_log_outbound`。验证:4 包构建通过、后端 9 单测通过、实时接口 14+ 项通过、浏览器 UI 10 项通过。
- 溯源节点图片增强 + 查看器修复(2026-06-30):对照甲方原版 PRD §3.2 链条式溯源模块。① 每张节点图片支持"图片标题"(caption,如设计稿/选胚图/手塑/上釉):`MediaSorter` 加 `captionable` 属性(每格下方标题输入框,caption 存 mediaFiles 项的 name);后台节点弹窗由"图片/视频两上传区"改为单个 captionable MediaSorter(图片+视频混排、可拖拽排序、逐张填标题)。② C 端时间轴节点图片**默认收缩**,显示"查看图片(N)"按钮(标题/时间/地点/说明照常显示),点击展开**横向**显示带标题图片/视频、无图不显示,避免页面过长;点图进查看器(可左右切换、底部显示标题)。③ 修复 C 端图片放大后无法拖动看边缘:`MediaViewer` 之前只有移动端单指拖动、无桌面鼠标拖动——补 mousedown/move/up 平移,并用图片实际渲染尺寸精确约束边界(clampOffset 用 stage/img clientWidth)。seed 节点补充带标题占位图(设计稿/选胚图、手塑/拉胚/上釉/烧制等)便于演示。判定"父子树状节点"为更大改动、用户用例(图片标题=caption)用不到,暂不做。验证:admin/h5 构建通过、浏览器 4/4 核心通过(默认收缩、展开带标题、放大鼠标拖动、轮播放大拖动)。
- 重大重构(2026-06-30,一款多码 / SKU 语义对齐):经与甲方确认,"SKU"实为"一款产品(用档案编号标识)",模型为「一款 → 多批次 → 每套独立编码(一款多码、批次码)」。改造:① 数据模型——`Artwork` 新增 `archiveNo`(款级唯一档案号,自动生成 `ARTVERIS-000001`);`Batch` 归属 `artworkId`(一款多批次);`Artwork 1:N TraceCode`(去掉 1:1 唯一约束);`TraceCode` 移除电商 `sku` 与码级 `archiveNo`、移除 `UNBOUND` 状态(生码即归属款、默认 INACTIVE);`QueryLog` 移除 `sku`、保留 `archiveNo/batchNo` 快照。② 生码流程——改为「选作品 + 数量 → 建批次 + N 套码(直接归属该款)」,移除 bind/unbind 绑定/解绑;`generateBatch`/`gen-code.processor` 写入 artworkId。③ 统计(PRD 4.4)——作品列表/详情/看板按"款"聚合查询次数(该款所有码 queryCount 之和),高频榜与日志带档案号;日志按 SKU 检索改为按档案号。④ 出库——导入/单条移除 sku、archiveNo(档案号款级自动)。⑤ 前端——Artworks 列加档案号/码数/查询总数;ArtworkEdit 追溯码区改为"档案号+码统计+批次+生码入口+查看全部码"(移除绑定/上链);TraceCodes 生码弹窗加"选择作品"必选、列表加档案号、支持 ?artworkId 跳转筛选;Dashboard/QueryLogs/Outbound 同步;C 端数字身份卡展示档案号。⑥ 迁移历史重置为单个 `init`(开发期、无线上数据、无需兼容);dev compose 加 `docker/mysql/init/01-dev-grant.sql` 给业务账号建库权限(供 migrate dev 的 shadow 库)。验证:4 包构建、9 单测、后端 QA 13 项(档案号生成/按作品生码/一款多码/按款统计/公开档案号/日志检索)全过,浏览器 6/7(第 7 项滚动限制非缺陷)。
- 脚本修复(四,2026-06-29):排查并修复 `dev.py` 报 `P1000 Authentication failed (artveris)`。真因有二:① 宿主机另一项目 `E:\code\remote\jvfu` 的 `jvfu_mysql` 占用了 3306,`localhost:3306` 命中了错误的库;② MySQL 8 `caching_sha2_password` 冷启动需安全连接换公钥,Prisma/pymysql 走明文 TCP 首次鉴权失败。修复:① `config.yaml` 改宿主端口 MySQL→3307、Redis→6380(容器内仍 3306/6379),与他项目共存、不动他项目;② 两个 compose 加 `--default-authentication-plugin=mysql_native_password`,并 `down -v` 重置数据卷使账号以 native_password 重建;③ `_lib.wait_db_auth` 用 pymysql 真账号轮询鉴权就绪,替代不可靠的 `wait_port`+`sleep(3)`,auto/manual 模式都先确认可鉴权再迁移;超时给出含"重置数据卷/检查凭据"的清晰提示。已实测冷启动 dev.py 全流程通过(3307 连库、迁移、种子、三端 200)。
- 脚本修复(五,2026-06-29):修复 docker_build.py / docker_dev.py。问题与修复:① 缺 `.dockerignore` 导致 `COPY` 把宿主机 node_modules 覆盖容器内已装依赖(tsc/prisma 找不到)→ 新增根 `.dockerignore` 忽略 node_modules/dist 等;② corepack 默认拉 pnpm 11 与 Node20 不兼容(ERR_UNKNOWN_BUILTIN_MODULE)→ 根 package.json 固定 `packageManager: pnpm@10.28.0`,Dockerfile 加 `COREPACK_ENABLE_DOWNLOAD_PROMPT=0`;③ Dockerfile 只复制部分 workspace 清单致 frozen 安装不全 → 复制全部 app/包清单后全量安装;④ 运行期 prisma CLI 路径错(pnpm 隔离布局在 apps/api/node_modules)→ CMD 改 `node node_modules/prisma/build/index.js`。基础镜像经 daocloud 镜像拉取 node:20-slim / nginx:alpine(本机无法直连 docker.io)。已实测:docker_build.py 构建 API 镜像成功、docker_dev.py 全栈启动(mysql healthy、api Up、admin:80 / h5:8080 / /api/health 全 200)、--down 正常。
+52 -26
View File
@@ -1,44 +1,54 @@
<template>
<div class="media-sorter">
<div class="grid">
<div
v-for="(m, i) in list"
:key="m.key"
class="cell"
:class="{ dragging: dragIndex === i, over: overIndex === i }"
draggable="true"
@dragstart="onDragStart(i)"
@dragover.prevent="onDragOver(i)"
@drop="onDrop(i)"
@dragend="onDragEnd"
>
<video v-if="isVideo(m)" class="thumb" :src="m.url" muted preload="metadata" />
<img v-else class="thumb" :src="m.url" :alt="m.name" />
<div v-if="isVideo(m)" class="play"><n-icon :component="PlayCircleOutline" :size="26" /></div>
<div class="order">{{ i + 1 }}</div>
<button class="del" type="button" :title="t('common.action.delete')" @click="remove(i)">×</button>
<div v-for="(m, i) in list" :key="m.key" class="item">
<div
class="cell"
:class="{ dragging: dragIndex === i, over: overIndex === i }"
draggable="true"
@dragstart="onDragStart(i)"
@dragover.prevent="onDragOver(i)"
@drop="onDrop(i)"
@dragend="onDragEnd"
>
<video v-if="isVideo(m)" class="thumb" :src="m.url" muted preload="metadata" />
<img v-else class="thumb" :src="m.url" :alt="m.name" />
<div v-if="isVideo(m)" class="play"><n-icon :component="PlayCircleOutline" :size="26" /></div>
<div class="order">{{ i + 1 }}</div>
<button class="del" type="button" :title="t('common.action.delete')" @click="remove(i)">×</button>
</div>
<n-input
v-if="captionable"
size="small"
:value="m.name"
:placeholder="t('pages.artwork.imageCaption')"
class="caption-input"
@update:value="(v) => updateCaption(i, v)"
/>
</div>
<!-- 上传中占位 -->
<div v-for="u in uploading" :key="u.id" class="cell uploading">
<n-spin size="small" />
<div v-for="u in uploading" :key="u.id" class="item">
<div class="cell uploading"><n-spin size="small" /></div>
</div>
<!-- 上传按钮 -->
<label v-if="list.length + uploading.length < max" class="cell add">
<input ref="inputRef" type="file" accept="image/*,video/*" multiple hidden @change="onPick" />
<n-icon :component="AddOutline" :size="22" />
<span>{{ t('common.action.upload') }}</span>
<label v-if="list.length + uploading.length < max" class="item">
<span class="cell add">
<input ref="inputRef" type="file" accept="image/*,video/*" multiple hidden @change="onPick" />
<n-icon :component="AddOutline" :size="22" />
<span>{{ t('common.action.upload') }}</span>
</span>
</label>
</div>
<div class="hint">{{ t('pages.artwork.mediaHint') }}</div>
<div class="hint">{{ captionable ? t('pages.artwork.mediaHintCaption') : t('pages.artwork.mediaHint') }}</div>
</div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { NIcon, NSpin } from 'naive-ui';
import { NIcon, NSpin, NInput } from 'naive-ui';
import { AddOutline, PlayCircleOutline } from '@vicons/ionicons5';
import { post } from '@/api/request';
import { message } from '@/utils/feedback';
@@ -50,10 +60,18 @@ interface MediaItem {
type?: string;
}
const props = withDefaults(defineProps<{ modelValue: MediaItem[]; max?: number }>(), { max: 12 });
const props = withDefaults(
defineProps<{ modelValue: MediaItem[]; max?: number; captionable?: boolean }>(),
{ max: 12, captionable: false },
);
const emit = defineEmits<{ (e: 'update:modelValue', v: MediaItem[]): void }>();
const { t } = useI18n();
function updateCaption(i: number, v: string) {
const arr = list.value.map((m, idx) => (idx === i ? { ...m, name: v } : m));
emit('update:modelValue', arr);
}
const inputRef = ref<HTMLInputElement | null>(null);
const list = computed<MediaItem[]>(() => props.modelValue || []);
const uploading = ref<{ id: number }[]>([]);
@@ -86,7 +104,7 @@ async function uploadOne(file: File) {
const res: any = await post(`/upload?type=${type}`, fd);
emit('update:modelValue', [
...list.value,
{ key: res.key, url: res.url, name: res.name, type },
{ key: res.key, url: res.url, name: props.captionable ? '' : res.name, type },
]);
} catch (err) {
message.error((err as Error)?.message || 'upload failed');
@@ -129,6 +147,14 @@ function onDragEnd() {
flex-wrap: wrap;
gap: 10px;
}
.item {
display: flex;
flex-direction: column;
gap: 4px;
}
.caption-input {
width: 96px;
}
.cell {
position: relative;
width: 96px;
+3
View File
@@ -195,6 +195,9 @@
"selectArtworkTip": "Search by archive no. / title to pick an artwork",
"images": "Images / Videos",
"mediaHint": "Images and videos supported. Drag to reorder (order = display order on the consumer page).",
"mediaHintCaption": "Images and videos supported. Add a caption per item (e.g. Sketch, Blank selection). Drag to reorder (= display order on the consumer page).",
"imageCaption": "Caption",
"nodeMedia": "Node Images / Videos",
"basicInfo": "Basic Info",
"dynamicFields": "Fields",
"nodes": "Timeline",
+3
View File
@@ -195,6 +195,9 @@
"selectArtworkTip": "搜索档案号 / 作品名选择作品(款)",
"images": "作品图片 / 视频",
"mediaHint": "支持图片与视频,拖拽可调整顺序(顺序即 C 端展示顺序)",
"mediaHintCaption": "支持图片与视频,可为每张填写标题(如设计稿、选胚图),拖拽调整顺序(即 C 端展示顺序)",
"imageCaption": "图片标题",
"nodeMedia": "节点图片 / 视频",
"basicInfo": "基础信息",
"dynamicFields": "动态字段",
"nodes": "溯源时间轴",
+14 -13
View File
@@ -255,11 +255,8 @@
<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.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 :label="t('pages.artwork.nodeMedia')">
<media-sorter v-model="nodeForm.media" :captionable="true" :max="12" />
</n-form-item>
</n-form>
<template #footer>
@@ -408,21 +405,24 @@ 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: '', images: [], videos: [] });
const nodeForm = reactive<any>({ nodeType: NodeType.CREATE, title: '', occurredAt: null, location: '', description: '', media: [] });
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 ?? '',
images: media.filter((m: any) => !isVideoMedia(m)),
videos: media.filter((m: any) => isVideoMedia(m)),
media: (n?.media ?? []).map((m: any) => ({
key: m.key || m.url,
url: m.url,
name: m.name,
type: m.type || (isVideoMedia(m) ? 'video' : 'image'),
})),
});
nodeModal.value = true;
}
@@ -439,10 +439,11 @@ async function saveNode() {
occurredAt: nodeForm.occurredAt || undefined,
location: nodeForm.location,
description: nodeForm.description,
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' })),
],
mediaFiles: nodeForm.media.map((m: any) => ({
key: m.key,
name: m.name,
type: m.type || (isVideoMedia(m) ? 'video' : 'image'),
})),
};
if (editingNode.value) await artworkApi.updateNode(editingNode.value, payload);
else await artworkApi.createNode(artworkId.value, payload);
+18 -4
View File
@@ -102,9 +102,23 @@ async function ensureSampleData(): Promise<void> {
const CODES_PER_ARTWORK = 3; // 每款示例生码数(演示一款多码)
let artworkSeq = 0;
let totalCodes = 0;
// 为节点生成"带标题"的占位图片(演示:每节点多张、横向、按标题展示)
const nodeMedia = async (labels: string[], bg: string) => {
const arr: { key: string; name: string; type: string }[] = [];
for (const label of labels) {
const key = writeStorage(`seed/${shortId()}.jpg`, await placeholder(label, bg));
arr.push({ key, name: label, type: 'image' });
}
return arr;
};
for (const s of samples) {
const imgKey = writeStorage(`seed/${shortId()}.jpg`, await placeholder(s.title, s.bg));
const img2 = writeStorage(`seed/${shortId()}.jpg`, await placeholder('细节图', s.bg));
const createMedia = await nodeMedia(['设计稿', '选胚图'], s.bg);
const produceMedia = await nodeMedia(['手塑', '拉胚', '上釉', '烧制'], s.bg);
const storageMedia = await nodeMedia(['入库实况'], s.bg);
const outboundMedia = await nodeMedia(['出库实况'], s.bg);
const artwork = await prisma.artwork.create({
data: {
templateId: template.id,
@@ -122,10 +136,10 @@ async function ensureSampleData(): Promise<void> {
],
traceNodes: {
create: [
{ nodeType: 'CREATE', title: '创作设计', location: '景德镇', description: '设计选胚,确定器型与纹样。', sortOrder: 0, mediaFiles: [] },
{ nodeType: 'PRODUCE', title: '制作烧制', location: '景德镇', description: '拉胚、上釉、高温烧制成型。', sortOrder: 1, mediaFiles: [] },
{ nodeType: 'STORAGE', title: '入库托管', location: '艺术品仓储中心', description: '恒温恒湿仓储托管。', sortOrder: 2, mediaFiles: [] },
{ nodeType: 'OUTBOUND', title: '出库流转', location: '艺术品仓储中心', description: '验真出库,交付藏家。', sortOrder: 3, mediaFiles: [] },
{ nodeType: 'CREATE', title: '创作设计', location: '景德镇', description: '设计选胚,确定器型与纹样。', sortOrder: 0, mediaFiles: createMedia },
{ nodeType: 'PRODUCE', title: '制作烧制', location: '景德镇', description: '拉胚、上釉、高温烧制成型。', sortOrder: 1, mediaFiles: produceMedia },
{ nodeType: 'STORAGE', title: '入库托管', location: '艺术品仓储中心', description: '恒温恒湿仓储托管。', sortOrder: 2, mediaFiles: storageMedia },
{ nodeType: 'OUTBOUND', title: '出库流转', location: '艺术品仓储中心', description: '验真出库,交付藏家。', sortOrder: 3, mediaFiles: outboundMedia },
],
},
},
+59 -6
View File
@@ -18,7 +18,7 @@
<button v-if="items.length > 1" class="nav next" :aria-label="t('viewer.next')" @click.stop="next">›</button>
<!-- 媒体区 -->
<div class="stage">
<div ref="stageEl" class="stage">
<video
v-if="curIsVideo"
:key="cur?.url"
@@ -31,18 +31,24 @@
/>
<img
v-else
ref="imgEl"
class="media-img"
:src="cur?.url"
:alt="cur?.name"
:style="imgStyle"
draggable="false"
@touchstart="onTouchStart"
@touchmove.prevent="onTouchMove"
@touchend="onTouchEnd"
@wheel.prevent="onWheel"
@mousedown.prevent="onMouseDown"
@dblclick="onDblClick"
@click.stop
/>
</div>
<!-- 图片标题 -->
<div v-if="!curIsVideo && cur?.name" class="caption">{{ cur.name }}</div>
</div>
</transition>
</template>
@@ -68,13 +74,15 @@ const current = ref(0);
const scale = ref(1);
const tx = ref(0);
const ty = ref(0);
const imgEl = ref<HTMLImageElement | null>(null);
const stageEl = ref<HTMLElement | null>(null);
const cur = computed(() => props.items[current.value]);
const curIsVideo = computed(() => isVideo(cur.value));
const imgStyle = computed(() => ({
transform: `translate(${tx.value}px, ${ty.value}px) scale(${scale.value})`,
transition: gesturing ? 'none' : 'transform 0.18s ease',
cursor: scale.value > 1 ? 'grab' : 'zoom-in',
transition: gesturing || dragging ? 'none' : 'transform 0.18s ease',
cursor: scale.value > 1 ? (dragging ? 'grabbing' : 'grab') : 'zoom-in',
}));
function isVideo(m?: MediaItem) {
@@ -103,11 +111,18 @@ function next() {
}
function clampScale(s: number) {
return Math.min(5, Math.max(1, s));
return Math.min(6, Math.max(1, s));
}
// 按"放大后图片实际溢出可视区"的尺寸约束平移,使拖动恰好能到达图片边缘
function clampOffset() {
const maxX = ((scale.value - 1) * window.innerWidth) / 2 + 40;
const maxY = ((scale.value - 1) * window.innerHeight) / 2 + 40;
const stage = stageEl.value;
const img = imgEl.value;
const vw = stage?.clientWidth ?? window.innerWidth;
const vh = stage?.clientHeight ?? window.innerHeight;
const baseW = img?.clientWidth ?? vw;
const baseH = img?.clientHeight ?? vh;
const maxX = Math.max(0, (baseW * scale.value - vw) / 2);
const maxY = Math.max(0, (baseH * scale.value - vh) / 2);
tx.value = Math.max(-maxX, Math.min(maxX, tx.value));
ty.value = Math.max(-maxY, Math.min(maxY, ty.value));
}
@@ -184,6 +199,30 @@ function onTouchEnd(e: TouchEvent) {
}
}
/* 鼠标拖动(桌面端):放大后可拖动查看四周细节 */
let dragging = false;
let dragStartX = 0;
let dragStartY = 0;
function onMouseDown(e: MouseEvent) {
if (scale.value <= 1) return; // 未放大不拖动
dragging = true;
dragStartX = e.clientX - tx.value;
dragStartY = e.clientY - ty.value;
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mouseup', onMouseUp);
}
function onMouseMove(e: MouseEvent) {
if (!dragging) return;
tx.value = e.clientX - dragStartX;
ty.value = e.clientY - dragStartY;
clampOffset();
}
function onMouseUp() {
dragging = false;
window.removeEventListener('mousemove', onMouseMove);
window.removeEventListener('mouseup', onMouseUp);
}
watch(
() => props.show,
(v) => {
@@ -291,6 +330,20 @@ watch(
max-height: 86%;
background: #000;
}
.caption {
position: absolute;
bottom: 18px;
left: 50%;
transform: translateX(-50%);
max-width: 86%;
padding: 6px 14px;
border-radius: 16px;
background: rgba(0, 0, 0, 0.5);
color: #fff;
font-size: 13px;
text-align: center;
z-index: 2;
}
.viewer-fade-enter-active,
.viewer-fade-leave-active {
transition: opacity 0.2s ease;
+4
View File
@@ -17,6 +17,10 @@
"cert": "Certificates",
"chain": "Digital Identity & Blockchain"
},
"timeline": {
"expandMedia": "View images ({n})",
"collapse": "Collapse"
},
"chain": {
"archiveNo": "Archive No.",
"code": "Trace Code",
+4
View File
@@ -17,6 +17,10 @@
"cert": "认证文件",
"chain": "数字身份与区块链存证"
},
"timeline": {
"expandMedia": "查看图片({n})",
"collapse": "收起图片"
},
"chain": {
"archiveNo": "档案编号",
"code": "唯一追溯码",
+82 -24
View File
@@ -98,19 +98,22 @@
<div class="tl-title">{{ n.title }}</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.media?.length" class="tl-media">
<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" loading="lazy" @click="openViewer([m], 0)" />
</template>
</div>
<template v-if="n.media?.length">
<button class="tl-toggle" @click="toggleNode(i)">
<span class="tl-toggle-ico" :class="{ open: expanded.has(i) }">▸</span>
{{ expanded.has(i) ? t('timeline.collapse') : t('timeline.expandMedia', { n: n.media.length }) }}
</button>
<div v-if="expanded.has(i)" class="tl-media">
<div v-for="(m, j) in n.media" :key="j" class="tl-media-item" @click="openViewer(n.media, j)">
<div class="tl-media-thumb">
<video v-if="isVideo(m)" :src="m.url" muted playsinline preload="metadata" />
<img v-else :src="m.url" loading="lazy" />
<div v-if="isVideo(m)" class="tl-play">▶</div>
</div>
<div v-if="m.name" class="tl-cap text-ellipsis">{{ m.name }}</div>
</div>
</div>
</template>
</div>
</div>
</div>
@@ -206,6 +209,14 @@ const viewerShow = ref(false);
const viewerItems = ref<any[]>([]);
const viewerStart = ref(0);
// 节点图片默认收缩,避免页面过长;点击展开
const expanded = ref<Set<number>>(new Set());
function toggleNode(i: number) {
const s = new Set(expanded.value);
s.has(i) ? s.delete(i) : s.add(i);
expanded.value = s;
}
const otherLangLabel = computed(() => (locale.value === 'zh-CN' ? 'EN' : '中文'));
const stateKey = computed(() => {
const s = data.value?.status;
@@ -260,6 +271,7 @@ async function load(code: string) {
loading.value = true;
data.value = null;
viewerShow.value = false;
expanded.value = new Set();
try {
data.value = await fetchTrace(code);
} catch {
@@ -502,23 +514,69 @@ watch(
font-size: 13px;
color: #374151;
}
.tl-toggle {
margin-top: 8px;
display: inline-flex;
align-items: center;
gap: 6px;
border: 1px solid #d0d7e2;
background: #f4f7fc;
color: var(--brand-2);
border-radius: 999px;
padding: 4px 12px;
font-size: 12px;
cursor: pointer;
}
.tl-toggle-ico {
display: inline-block;
transition: transform 0.18s ease;
}
.tl-toggle-ico.open {
transform: rotate(90deg);
}
.tl-media {
display: flex;
gap: 8px;
margin-top: 8px;
flex-wrap: wrap;
gap: 10px;
margin-top: 10px;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
padding-bottom: 4px;
}
.tl-media img {
width: 72px;
height: 72px;
object-fit: cover;
.tl-media-item {
flex-shrink: 0;
width: 92px;
cursor: pointer;
}
.tl-media-thumb {
position: relative;
width: 92px;
height: 92px;
border-radius: 8px;
overflow: hidden;
background: #e7ecf3;
}
.tl-video {
.tl-media-thumb img,
.tl-media-thumb video {
width: 100%;
max-height: 220px;
border-radius: 8px;
background: #000;
height: 100%;
object-fit: cover;
display: block;
}
.tl-play {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 22px;
background: rgba(0, 0, 0, 0.3);
}
.tl-cap {
font-size: 12px;
color: var(--muted);
margin-top: 4px;
text-align: center;
}
.cert-grid {
display: grid;