feat: 作品页支持模块化编排与自定义内容模块
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<div
|
||||
class="cell previewable"
|
||||
:class="{ dragging: dragIndex === i, over: overIndex === i }"
|
||||
draggable="true"
|
||||
:draggable="!disabled"
|
||||
@click="preview(i)"
|
||||
@dragstart="onDragStart(i)"
|
||||
@dragover.prevent="onDragOver(i)"
|
||||
@@ -16,12 +16,13 @@
|
||||
<img v-else class="thumb" :src="mediaSrc(m)" :alt="m.name" loading="lazy" />
|
||||
<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.stop="remove(i)">×</button>
|
||||
<button v-if="!disabled" class="del" type="button" :title="t('common.action.delete')" @click.stop="remove(i)">×</button>
|
||||
</div>
|
||||
<n-input
|
||||
v-if="captionable"
|
||||
size="small"
|
||||
:value="m.name"
|
||||
:disabled="disabled"
|
||||
:placeholder="t('pages.artwork.imageCaption')"
|
||||
class="caption-input"
|
||||
@update:value="(v) => updateCaption(i, v)"
|
||||
@@ -32,7 +33,7 @@
|
||||
<div class="cell uploading"><n-spin size="small" /></div>
|
||||
</div>
|
||||
|
||||
<label v-if="list.length + uploading.length < max" class="item">
|
||||
<label v-if="!disabled && 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" />
|
||||
@@ -62,8 +63,8 @@ interface MediaItem {
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ modelValue: MediaItem[]; max?: number; captionable?: boolean }>(),
|
||||
{ max: 12, captionable: false },
|
||||
defineProps<{ modelValue: MediaItem[]; max?: number; captionable?: boolean; disabled?: boolean }>(),
|
||||
{ max: 12, captionable: false, disabled: false },
|
||||
);
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: MediaItem[]): void }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -0,0 +1,473 @@
|
||||
<template>
|
||||
<div class="trace-module-editor">
|
||||
<div class="module-toolbar">
|
||||
<div>
|
||||
<div class="module-toolbar-title">{{ t('pages.traceModules.title') }}</div>
|
||||
<div class="module-toolbar-hint">{{ t('pages.traceModules.hint') }}</div>
|
||||
</div>
|
||||
<n-dropdown
|
||||
v-if="!disabled"
|
||||
trigger="click"
|
||||
:options="addOptions"
|
||||
@select="addModule"
|
||||
>
|
||||
<n-button type="primary" size="small" :disabled="modules.length >= MAX_TRACE_MODULES">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.traceModules.add') }}
|
||||
</n-button>
|
||||
</n-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="module-list">
|
||||
<section
|
||||
v-for="(module, index) in modules"
|
||||
:key="module.id"
|
||||
class="module-card"
|
||||
:class="{ hidden: !module.visible, over: overIndex === index, collapsed: !isExpanded(module) }"
|
||||
@dragover.prevent="overIndex = index"
|
||||
@drop="onDrop(index)"
|
||||
>
|
||||
<header class="module-head">
|
||||
<button
|
||||
v-if="!disabled"
|
||||
type="button"
|
||||
class="drag-handle"
|
||||
draggable="true"
|
||||
:title="t('pages.traceModules.drag')"
|
||||
:aria-label="t('pages.traceModules.drag')"
|
||||
@dragstart="dragIndex = index"
|
||||
@dragend="onDragEnd"
|
||||
>
|
||||
⋮⋮
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="expand-toggle"
|
||||
:class="{ open: isExpanded(module) }"
|
||||
:title="isExpanded(module) ? t('pages.traceModules.collapse') : t('pages.traceModules.expand')"
|
||||
:aria-label="isExpanded(module) ? t('pages.traceModules.collapse') : t('pages.traceModules.expand')"
|
||||
@click="toggleExpand(module.id)"
|
||||
>
|
||||
<n-icon :component="ChevronDownOutline" :size="18" />
|
||||
</button>
|
||||
<span class="module-order">{{ index + 1 }}</span>
|
||||
<n-tag size="small" :bordered="false">{{ moduleTypeName(module.type) }}</n-tag>
|
||||
<n-input
|
||||
v-if="module.type !== 'HERO_CAROUSEL'"
|
||||
class="module-title-input"
|
||||
size="small"
|
||||
clearable
|
||||
:disabled="disabled"
|
||||
:maxlength="120"
|
||||
:value="module.title"
|
||||
:placeholder="t('pages.traceModules.defaultTitle', { title: moduleTypeName(module.type) })"
|
||||
@update:value="(value) => patchModule(index, { title: value })"
|
||||
/>
|
||||
<div v-else class="module-title-spacer" />
|
||||
<span class="visible-label">{{ t('pages.traceModules.visible') }}</span>
|
||||
<n-switch
|
||||
size="small"
|
||||
:disabled="disabled"
|
||||
:value="module.visible"
|
||||
@update:value="(value) => patchModule(index, { visible: value })"
|
||||
/>
|
||||
<div v-if="!disabled" class="module-actions">
|
||||
<n-button quaternary circle size="small" :disabled="index === 0" @click="move(index, -1)">
|
||||
<template #icon><n-icon :component="ArrowUpOutline" /></template>
|
||||
</n-button>
|
||||
<n-button
|
||||
quaternary
|
||||
circle
|
||||
size="small"
|
||||
:disabled="index === modules.length - 1"
|
||||
@click="move(index, 1)"
|
||||
>
|
||||
<template #icon><n-icon :component="ArrowDownOutline" /></template>
|
||||
</n-button>
|
||||
<n-button
|
||||
v-if="isCustom(module.type)"
|
||||
quaternary
|
||||
circle
|
||||
size="small"
|
||||
:disabled="modules.length >= MAX_TRACE_MODULES"
|
||||
:title="t('common.action.copy')"
|
||||
@click="copyModule(index)"
|
||||
>
|
||||
<template #icon><n-icon :component="CopyOutline" /></template>
|
||||
</n-button>
|
||||
<n-button
|
||||
v-if="isCustom(module.type)"
|
||||
quaternary
|
||||
circle
|
||||
size="small"
|
||||
type="error"
|
||||
:title="t('common.action.delete')"
|
||||
@click="removeModule(index)"
|
||||
>
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div v-show="isExpanded(module)" class="module-body">
|
||||
<template v-if="module.type === 'IMAGE_TEXT'">
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.traceModules.imagePosition')">
|
||||
<n-select
|
||||
:disabled="disabled"
|
||||
:value="imageTextConfig(module).imagePosition || 'TOP'"
|
||||
:options="imagePositionOptions"
|
||||
@update:value="(value) => patchConfig(index, { imagePosition: value })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<template v-if="!templateMode">
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.traceModules.innerHeading')">
|
||||
<n-input
|
||||
:disabled="disabled"
|
||||
:maxlength="120"
|
||||
:value="imageTextConfig(module).heading"
|
||||
@update:value="(value) => patchConfig(index, { heading: value })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2" :label="t('pages.traceModules.body')">
|
||||
<n-input
|
||||
type="textarea"
|
||||
:disabled="disabled"
|
||||
:maxlength="5000"
|
||||
:autosize="{ minRows: 3, maxRows: 10 }"
|
||||
:value="imageTextConfig(module).body"
|
||||
@update:value="(value) => patchConfig(index, { body: value })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2" :label="t('pages.traceModules.image')">
|
||||
<media-upload
|
||||
:model-value="imageTextMedia(module)"
|
||||
type="image"
|
||||
:max="1"
|
||||
:disabled="disabled"
|
||||
@update:model-value="(items) => patchConfig(index, { image: items[0] })"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
</template>
|
||||
</n-grid>
|
||||
<n-alert v-if="templateMode" type="info" :show-icon="false">
|
||||
{{ t('pages.traceModules.templateContentHint') }}
|
||||
</n-alert>
|
||||
</template>
|
||||
|
||||
<template v-else-if="module.type === 'HORIZONTAL_GALLERY'">
|
||||
<artwork-showcase-editor
|
||||
v-if="!templateMode"
|
||||
:model-value="galleryItems(module)"
|
||||
:max="30"
|
||||
:disabled="disabled"
|
||||
@update:model-value="(items) => patchConfig(index, { items })"
|
||||
/>
|
||||
<n-alert v-else type="info" :show-icon="false">
|
||||
{{ t('pages.traceModules.templateContentHint') }}
|
||||
</n-alert>
|
||||
</template>
|
||||
|
||||
<slot
|
||||
v-else-if="!templateMode"
|
||||
name="system"
|
||||
:module="module"
|
||||
:index="index"
|
||||
>
|
||||
<n-empty size="small" :description="t('pages.traceModules.systemDataHint')" />
|
||||
</slot>
|
||||
|
||||
<n-alert v-else type="default" :show-icon="false">
|
||||
{{ t('pages.traceModules.systemDataHint') }}
|
||||
</n-alert>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ArrowDownOutline,
|
||||
ArrowUpOutline,
|
||||
AddOutline,
|
||||
ChevronDownOutline,
|
||||
CopyOutline,
|
||||
TrashOutline,
|
||||
} from '@vicons/ionicons5';
|
||||
import {
|
||||
cloneTraceLayout,
|
||||
createDefaultTraceLayout,
|
||||
MAX_TRACE_MODULES,
|
||||
type TraceHorizontalGalleryConfig,
|
||||
type TraceImageTextConfig,
|
||||
type TraceLayout,
|
||||
type TraceModule,
|
||||
type TraceModuleType,
|
||||
} from '@artveris/shared';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import ArtworkShowcaseEditor from '@/components/ArtworkShowcaseEditor.vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue?: TraceLayout;
|
||||
disabled?: boolean;
|
||||
templateMode?: boolean;
|
||||
}>(),
|
||||
{ disabled: false, templateMode: false },
|
||||
);
|
||||
const emit = defineEmits<{ (event: 'update:modelValue', value: TraceLayout): void }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const modules = computed(() => props.modelValue?.modules ?? createDefaultTraceLayout().modules);
|
||||
const dragIndex = ref<number | null>(null);
|
||||
const overIndex = ref<number | null>(null);
|
||||
// 卡片折叠是纯编辑态 UI,不写入布局 JSON;默认收起便于总览排序,新增/复制的模块自动展开
|
||||
const expandedIds = ref<Set<string>>(new Set());
|
||||
let customSequence = 0;
|
||||
|
||||
function isExpanded(module: TraceModule) {
|
||||
return expandedIds.value.has(module.id);
|
||||
}
|
||||
|
||||
function toggleExpand(id: string) {
|
||||
const next = new Set(expandedIds.value);
|
||||
next.has(id) ? next.delete(id) : next.add(id);
|
||||
expandedIds.value = next;
|
||||
}
|
||||
|
||||
function expandModule(id: string) {
|
||||
expandedIds.value = new Set(expandedIds.value).add(id);
|
||||
}
|
||||
|
||||
const addOptions = computed(() => [
|
||||
{ label: t('pages.traceModules.types.IMAGE_TEXT'), key: 'IMAGE_TEXT' },
|
||||
{ label: t('pages.traceModules.types.HORIZONTAL_GALLERY'), key: 'HORIZONTAL_GALLERY' },
|
||||
]);
|
||||
const imagePositionOptions = computed(() => [
|
||||
{ label: t('pages.traceModules.positions.TOP'), value: 'TOP' },
|
||||
{ label: t('pages.traceModules.positions.BOTTOM'), value: 'BOTTOM' },
|
||||
{ label: t('pages.traceModules.positions.LEFT'), value: 'LEFT' },
|
||||
{ label: t('pages.traceModules.positions.RIGHT'), value: 'RIGHT' },
|
||||
]);
|
||||
|
||||
function moduleTypeName(type: TraceModuleType) {
|
||||
return t(`pages.traceModules.types.${type}`);
|
||||
}
|
||||
|
||||
function isCustom(type: TraceModuleType) {
|
||||
return type === 'IMAGE_TEXT' || type === 'HORIZONTAL_GALLERY';
|
||||
}
|
||||
|
||||
function commit(nextModules: TraceModule[]) {
|
||||
emit('update:modelValue', { version: 1, modules: nextModules });
|
||||
}
|
||||
|
||||
function patchModule(index: number, patch: Partial<TraceModule>) {
|
||||
commit(modules.value.map((module, itemIndex) => (itemIndex === index ? { ...module, ...patch } : module)));
|
||||
}
|
||||
|
||||
function patchConfig(index: number, patch: Record<string, unknown>) {
|
||||
const module = modules.value[index];
|
||||
if (!module) return;
|
||||
patchModule(index, { config: { ...(module.config ?? {}), ...patch } });
|
||||
}
|
||||
|
||||
function move(index: number, offset: -1 | 1) {
|
||||
const target = index + offset;
|
||||
if (target < 0 || target >= modules.value.length) return;
|
||||
const next = [...modules.value];
|
||||
const [module] = next.splice(index, 1);
|
||||
next.splice(target, 0, module);
|
||||
commit(next);
|
||||
}
|
||||
|
||||
function customId(type: TraceModuleType) {
|
||||
customSequence += 1;
|
||||
const random =
|
||||
typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
||||
? crypto.randomUUID().replace(/-/g, '').slice(0, 12)
|
||||
: `${Date.now()}${customSequence}`;
|
||||
return `custom_${type.toLowerCase()}_${random}`;
|
||||
}
|
||||
|
||||
function addModule(type: TraceModuleType) {
|
||||
if (modules.value.length >= MAX_TRACE_MODULES) return;
|
||||
const module: TraceModule = {
|
||||
id: customId(type),
|
||||
type,
|
||||
visible: true,
|
||||
config: type === 'IMAGE_TEXT' ? { imagePosition: 'TOP' } : { items: [] },
|
||||
};
|
||||
commit([...modules.value, module]);
|
||||
expandModule(module.id);
|
||||
}
|
||||
|
||||
function copyModule(index: number) {
|
||||
if (modules.value.length >= MAX_TRACE_MODULES) return;
|
||||
const current = modules.value[index];
|
||||
if (!current || !isCustom(current.type)) return;
|
||||
const copied = cloneTraceLayout({ version: 1, modules: [current] }).modules[0];
|
||||
copied.id = customId(copied.type);
|
||||
commit([...modules.value.slice(0, index + 1), copied, ...modules.value.slice(index + 1)]);
|
||||
expandModule(copied.id);
|
||||
}
|
||||
|
||||
function removeModule(index: number) {
|
||||
commit(modules.value.filter((_, itemIndex) => itemIndex !== index));
|
||||
}
|
||||
|
||||
function imageTextConfig(module: TraceModule): TraceImageTextConfig {
|
||||
return (module.config ?? {}) as TraceImageTextConfig;
|
||||
}
|
||||
|
||||
function imageTextMedia(module: TraceModule) {
|
||||
const image = imageTextConfig(module).image;
|
||||
return image ? [image] : [];
|
||||
}
|
||||
|
||||
function galleryItems(module: TraceModule) {
|
||||
return ((module.config ?? {}) as TraceHorizontalGalleryConfig).items ?? [];
|
||||
}
|
||||
|
||||
function onDrop(target: number) {
|
||||
const source = dragIndex.value;
|
||||
if (source === null || source === target) return onDragEnd();
|
||||
const next = [...modules.value];
|
||||
const [module] = next.splice(source, 1);
|
||||
next.splice(target, 0, module);
|
||||
commit(next);
|
||||
onDragEnd();
|
||||
}
|
||||
|
||||
function onDragEnd() {
|
||||
dragIndex.value = null;
|
||||
overIndex.value = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.trace-module-editor {
|
||||
width: 100%;
|
||||
}
|
||||
.module-toolbar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.module-toolbar-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
.module-toolbar-hint {
|
||||
margin-top: 4px;
|
||||
color: #98a2b3;
|
||||
font-size: 12px;
|
||||
}
|
||||
.module-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.module-card {
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--n-border-color, #e0e0e6);
|
||||
border-radius: 10px;
|
||||
background: var(--n-color, #fff);
|
||||
transition: border-color 0.15s ease, opacity 0.15s ease;
|
||||
}
|
||||
.module-card.over {
|
||||
border-color: var(--brand, #138a72);
|
||||
}
|
||||
.module-card.hidden {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.module-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 52px;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid var(--n-border-color, #e0e0e6);
|
||||
background: rgba(19, 138, 114, 0.035);
|
||||
}
|
||||
.module-card.collapsed .module-head {
|
||||
border-bottom: none;
|
||||
}
|
||||
.expand-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: #667085;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.18s ease;
|
||||
}
|
||||
.expand-toggle:hover {
|
||||
background: rgba(19, 138, 114, 0.08);
|
||||
}
|
||||
.expand-toggle.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.drag-handle {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: #8b95a5;
|
||||
cursor: grab;
|
||||
}
|
||||
.drag-handle:hover {
|
||||
background: rgba(19, 138, 114, 0.08);
|
||||
}
|
||||
.module-order {
|
||||
width: 22px;
|
||||
color: #98a2b3;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.module-title-input {
|
||||
min-width: 160px;
|
||||
flex: 1;
|
||||
}
|
||||
.module-title-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.visible-label {
|
||||
color: #667085;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.module-actions {
|
||||
display: inline-flex;
|
||||
gap: 2px;
|
||||
}
|
||||
.module-body {
|
||||
padding: 14px;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.module-head {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.module-title-input,
|
||||
.module-title-spacer {
|
||||
order: 2;
|
||||
width: 100%;
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.module-actions {
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -280,7 +280,8 @@
|
||||
"disableConfirmContent": "Disable \"{name}\"? It will no longer be available when creating new artwork files.",
|
||||
"namePlaceholder": "Enter template name",
|
||||
"fieldKeyTip": "Unique English key",
|
||||
"sortHint": "Field order = display order on consumer page; use arrows to reorder",
|
||||
"sortHint": "Field order = display order inside the artwork introduction module; use arrows to reorder",
|
||||
"defaultTraceLayout": "Default Consumer Page Layout",
|
||||
"defaultFields": {
|
||||
"craft": "Craft",
|
||||
"year": "Creation Era / Release Time",
|
||||
@@ -290,6 +291,42 @@
|
||||
"dataOwner": "Data Ownership"
|
||||
}
|
||||
},
|
||||
"traceModules": {
|
||||
"title": "Page Modules",
|
||||
"clientLayout": "Consumer Page Composer",
|
||||
"hint": "Module order matches the consumer page. Configure visibility and titles, or add custom content modules.",
|
||||
"add": "Add Module",
|
||||
"drag": "Drag to reorder modules",
|
||||
"expand": "Expand module content",
|
||||
"collapse": "Collapse module content",
|
||||
"visible": "Visible",
|
||||
"defaultTitle": "Leave empty for default: {title}",
|
||||
"imagePosition": "Image Position",
|
||||
"innerHeading": "Content Heading",
|
||||
"body": "Body",
|
||||
"image": "Image",
|
||||
"templateContentHint": "Templates only save module structure and presentation. Add artwork-specific content after creating the artwork.",
|
||||
"systemDataHint": "This module reads existing artwork data. The template only controls order, visibility and title.",
|
||||
"authenticityHint": "Authenticity status is generated from each consumer query. These options only control presentation and never disable activation, counting or query logs.",
|
||||
"blockchainHint": "This module reads each trace code's on-chain status and transaction details. These options only control presentation.",
|
||||
"types": {
|
||||
"HERO_CAROUSEL": "Hero Carousel",
|
||||
"AUTHENTICITY_STATUS": "Authenticity Status",
|
||||
"PRODUCT_INTRO": "Artwork Introduction",
|
||||
"SHOWCASE": "Artwork Showcase",
|
||||
"CERTIFICATES": "Copyright Certificates",
|
||||
"TIMELINE": "Trace Timeline",
|
||||
"BLOCKCHAIN": "Digital Identity & Blockchain",
|
||||
"IMAGE_TEXT": "Image & Text",
|
||||
"HORIZONTAL_GALLERY": "Horizontal Gallery"
|
||||
},
|
||||
"positions": {
|
||||
"TOP": "Image above",
|
||||
"BOTTOM": "Image below",
|
||||
"LEFT": "Image left (stacked on mobile)",
|
||||
"RIGHT": "Image right (stacked on mobile)"
|
||||
}
|
||||
},
|
||||
"audit": {
|
||||
"status": "Audit Status",
|
||||
"approve": "Approve",
|
||||
|
||||
@@ -280,7 +280,8 @@
|
||||
"disableConfirmContent": "确认停用“{name}”?停用后新建档案时将不能选择该模板。",
|
||||
"namePlaceholder": "请输入模板名称",
|
||||
"fieldKeyTip": "英文唯一标识",
|
||||
"sortHint": "字段顺序即客户端展示顺序,可用上下箭头调整",
|
||||
"sortHint": "字段顺序即作品介绍模块内的展示顺序,可用上下箭头调整",
|
||||
"defaultTraceLayout": "客户端默认页面布局",
|
||||
"defaultFields": {
|
||||
"craft": "工艺",
|
||||
"year": "创作年代 / 出品时间",
|
||||
@@ -290,6 +291,42 @@
|
||||
"dataOwner": "数据权属"
|
||||
}
|
||||
},
|
||||
"traceModules": {
|
||||
"title": "页面模块",
|
||||
"clientLayout": "客户端页面编排",
|
||||
"hint": "模块顺序即客户端展示顺序;可调整显隐、标题并添加自定义内容模块。",
|
||||
"add": "添加模块",
|
||||
"drag": "拖拽调整模块顺序",
|
||||
"expand": "展开模块内容",
|
||||
"collapse": "收起模块内容",
|
||||
"visible": "显示",
|
||||
"defaultTitle": "留空使用默认标题:{title}",
|
||||
"imagePosition": "图文位置",
|
||||
"innerHeading": "内容标题",
|
||||
"body": "正文",
|
||||
"image": "图片",
|
||||
"templateContentHint": "模板仅保存模块结构和展示方式,具体作品内容请在建档后填写。",
|
||||
"systemDataHint": "该模块读取作品现有业务数据,模板只设置顺序、显隐和标题。",
|
||||
"authenticityHint": "防伪状态由消费者每次查询结果自动生成;此处只调整显示位置、显隐和标题,不影响激活、计数与查询日志。",
|
||||
"blockchainHint": "区块链模块自动读取每个追溯码的上链状态和交易信息;此处只调整显示位置、显隐和标题。",
|
||||
"types": {
|
||||
"HERO_CAROUSEL": "顶部作品轮播",
|
||||
"AUTHENTICITY_STATUS": "防伪状态",
|
||||
"PRODUCT_INTRO": "作品介绍",
|
||||
"SHOWCASE": "作品展示",
|
||||
"CERTIFICATES": "版权证书",
|
||||
"TIMELINE": "溯源时间轴",
|
||||
"BLOCKCHAIN": "数字身份与区块链存证",
|
||||
"IMAGE_TEXT": "图文模块",
|
||||
"HORIZONTAL_GALLERY": "横向滚动图区"
|
||||
},
|
||||
"positions": {
|
||||
"TOP": "图片在上",
|
||||
"BOTTOM": "图片在下",
|
||||
"LEFT": "图片在左(移动端转为纵向)",
|
||||
"RIGHT": "图片在右(移动端转为纵向)"
|
||||
}
|
||||
},
|
||||
"audit": {
|
||||
"status": "审核状态",
|
||||
"approve": "通过",
|
||||
|
||||
@@ -78,175 +78,210 @@
|
||||
<n-select
|
||||
v-model:value="form.templateId"
|
||||
:options="templateOptions"
|
||||
:disabled="!isNew"
|
||||
:disabled="!isNew || !auth.canWrite"
|
||||
@update:value="onTemplateChange"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2 m:1" path="title" :label="t('pages.artwork.title')">
|
||||
<n-input v-model:value="form.title" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.artwork.artist')">
|
||||
<n-input v-model:value="form.artist" />
|
||||
<n-input v-model:value="form.title" :disabled="!auth.canWrite" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi v-if="!isNew" span="2 m:1" :label="t('common.label.status')">
|
||||
<n-select v-model:value="form.status" :options="statusOptions" />
|
||||
<n-select v-model:value="form.status" :options="statusOptions" :disabled="!auth.canWrite" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.dynamicFields') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi
|
||||
v-for="f in currentFields"
|
||||
:key="f.fieldKey"
|
||||
span="2 m:1"
|
||||
:label="f.required ? `${f.label} *` : f.label"
|
||||
>
|
||||
<n-date-picker
|
||||
v-if="f.type === 'DATE'"
|
||||
v-model:formatted-value="form.dynamicFields[f.fieldKey]"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="date"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
v-else-if="f.type === 'TEXTAREA'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
/>
|
||||
<n-input-number
|
||||
v-else-if="f.type === 'NUMBER'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
v-else-if="f.type === 'LINK'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
placeholder="https://"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'IMAGE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="image"
|
||||
:max="1"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'FILE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="file"
|
||||
:max="1"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<n-input v-else v-model:value="form.dynamicFields[f.fieldKey]" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.coverMedia') }}</n-divider>
|
||||
<media-sorter v-model="form.images" :max="12" />
|
||||
</n-form>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
|
||||
<!-- 作品展示 -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.showcase')" :bordered="false">
|
||||
<artwork-showcase-editor
|
||||
v-model="form.showcaseImages"
|
||||
:max="30"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.traceModules.clientLayout')" :bordered="false">
|
||||
<trace-module-editor
|
||||
v-model="form.traceLayout"
|
||||
:disabled="!auth.canWrite"
|
||||
>
|
||||
<template #system="{ module }">
|
||||
<media-sorter
|
||||
v-if="module.type === 'HERO_CAROUSEL'"
|
||||
v-model="form.images"
|
||||
:max="12"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
|
||||
<!-- 溯源时间轴 -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.nodes')" :bordered="false">
|
||||
<template #header-extra>
|
||||
<n-space align="center">
|
||||
<n-checkbox v-model:checked="form.showOutboundTimeline" :disabled="!auth.canWrite">
|
||||
{{ t('pages.artwork.showOutboundTimeline') }}
|
||||
</n-checkbox>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openNode()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addNode') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
<n-empty v-if="!nodes.length" :description="t('common.msg.noData')" />
|
||||
<n-timeline v-else>
|
||||
<n-timeline-item v-for="n in nodes" :key="n.id ?? n.localId" type="info" :title="n.title">
|
||||
<template #header>
|
||||
<div class="node-head">
|
||||
<span>{{ t(`common.nodeType.${n.nodeType}`) }} · {{ n.title }}</span>
|
||||
<span v-if="auth.canWrite" class="node-ops">
|
||||
<n-button text size="tiny" @click="openNode(n)">{{ t('common.action.edit') }}</n-button>
|
||||
<n-button text size="tiny" type="error" @click="removeNode(n)">{{ t('common.action.delete') }}</n-button>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
||||
<div>{{ n.description }}</div>
|
||||
<div class="node-media">
|
||||
<template v-for="m in n.media" :key="m.url || m.key">
|
||||
<video
|
||||
v-if="isVideoMedia(m)"
|
||||
:src="mediaUrl(m)"
|
||||
controls
|
||||
preload="metadata"
|
||||
style="max-height: 90px; border-radius: 6px; background: #000"
|
||||
<n-alert
|
||||
v-else-if="module.type === 'AUTHENTICITY_STATUS'"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
>
|
||||
{{ t('pages.traceModules.authenticityHint') }}
|
||||
</n-alert>
|
||||
|
||||
<n-form
|
||||
v-else-if="module.type === 'PRODUCT_INTRO'"
|
||||
label-placement="top"
|
||||
>
|
||||
<n-form-item :label="t('pages.artwork.artist')">
|
||||
<n-input v-model:value="form.artist" :disabled="!auth.canWrite" />
|
||||
</n-form-item>
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.dynamicFields') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi
|
||||
v-for="f in currentFields"
|
||||
:key="f.fieldKey"
|
||||
span="2 m:1"
|
||||
:label="f.required ? `${f.label} *` : f.label"
|
||||
>
|
||||
<n-date-picker
|
||||
v-if="f.type === 'DATE'"
|
||||
v-model:formatted-value="form.dynamicFields[f.fieldKey]"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="date"
|
||||
clearable
|
||||
:disabled="!auth.canWrite"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<img
|
||||
<n-input
|
||||
v-else-if="f.type === 'TEXTAREA'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
<n-input-number
|
||||
v-else-if="f.type === 'NUMBER'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
:disabled="!auth.canWrite"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
v-else-if="f.type === 'LINK'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
:disabled="!auth.canWrite"
|
||||
placeholder="https://"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'IMAGE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="image"
|
||||
:max="1"
|
||||
:disabled="!auth.canWrite"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'FILE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="file"
|
||||
:max="1"
|
||||
:disabled="!auth.canWrite"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = mediaKey(v[0]) || '')"
|
||||
/>
|
||||
<n-input
|
||||
v-else
|
||||
class="node-media-image"
|
||||
:src="mediaUrl(m)"
|
||||
:alt="m.name || n.title"
|
||||
loading="lazy"
|
||||
@click="previewNodeImage(n.media, m)"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</n-timeline-item>
|
||||
</n-timeline>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
</n-form>
|
||||
|
||||
<!-- 版权证书 -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.certificates')" :bordered="false">
|
||||
<template #header-extra>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openCert()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addCert') }}
|
||||
</n-button>
|
||||
<artwork-showcase-editor
|
||||
v-else-if="module.type === 'SHOWCASE'"
|
||||
v-model="form.showcaseImages"
|
||||
:max="30"
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
|
||||
<template v-else-if="module.type === 'TIMELINE'">
|
||||
<div class="module-content-toolbar">
|
||||
<n-checkbox v-model:checked="form.showOutboundTimeline" :disabled="!auth.canWrite">
|
||||
{{ t('pages.artwork.showOutboundTimeline') }}
|
||||
</n-checkbox>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openNode()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addNode') }}
|
||||
</n-button>
|
||||
</div>
|
||||
<n-empty v-if="!nodes.length" :description="t('common.msg.noData')" />
|
||||
<n-timeline v-else>
|
||||
<n-timeline-item v-for="n in nodes" :key="n.id ?? n.localId" type="info" :title="n.title">
|
||||
<template #header>
|
||||
<div class="node-head">
|
||||
<span>{{ t(`common.nodeType.${n.nodeType}`) }} · {{ n.title }}</span>
|
||||
<span v-if="auth.canWrite" class="node-ops">
|
||||
<n-button text size="tiny" @click="openNode(n)">{{ t('common.action.edit') }}</n-button>
|
||||
<n-button text size="tiny" type="error" @click="removeNode(n)">{{ t('common.action.delete') }}</n-button>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
||||
<div>{{ n.description }}</div>
|
||||
<div class="node-media">
|
||||
<template v-for="m in n.media" :key="m.url || m.key">
|
||||
<video
|
||||
v-if="isVideoMedia(m)"
|
||||
:src="mediaUrl(m)"
|
||||
controls
|
||||
preload="metadata"
|
||||
style="max-height: 90px; border-radius: 6px; background: #000"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
class="node-media-image"
|
||||
:src="mediaUrl(m)"
|
||||
:alt="m.name || n.title"
|
||||
loading="lazy"
|
||||
@click="previewNodeImage(n.media, m)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</n-timeline-item>
|
||||
</n-timeline>
|
||||
</template>
|
||||
|
||||
<template v-else-if="module.type === 'CERTIFICATES'">
|
||||
<div class="module-content-toolbar">
|
||||
<div />
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openCert()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.addCert') }}
|
||||
</n-button>
|
||||
</div>
|
||||
<n-empty v-if="!certs.length" :description="t('common.msg.noData')" />
|
||||
<n-grid v-else :cols="4" :x-gap="12" :y-gap="12" item-responsive responsive="screen">
|
||||
<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>
|
||||
<img
|
||||
v-if="c.watermarkUrl || c.originUrl"
|
||||
class="cert-preview-image"
|
||||
:src="certUrl(c)"
|
||||
:alt="c.name"
|
||||
loading="lazy"
|
||||
@click="previewCert(c)"
|
||||
/>
|
||||
<div v-else class="cert-pending">{{ t('pages.artwork.watermarkPending') }}</div>
|
||||
</template>
|
||||
<div class="cert-meta">{{ c.issuer || '-' }}</div>
|
||||
<template #footer>
|
||||
<n-button v-if="auth.canWrite" text size="tiny" type="error" @click="removeCert(c)">
|
||||
{{ t('common.action.delete') }}
|
||||
</n-button>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
</template>
|
||||
|
||||
<n-alert
|
||||
v-else-if="module.type === 'BLOCKCHAIN'"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
>
|
||||
{{ t('pages.traceModules.blockchainHint') }}
|
||||
</n-alert>
|
||||
</template>
|
||||
<n-empty v-if="!certs.length" :description="t('common.msg.noData')" />
|
||||
<n-grid v-else :cols="4" :x-gap="12" :y-gap="12" item-responsive responsive="screen">
|
||||
<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>
|
||||
<img
|
||||
v-if="c.watermarkUrl || c.originUrl"
|
||||
class="cert-preview-image"
|
||||
:src="certUrl(c)"
|
||||
:alt="c.name"
|
||||
loading="lazy"
|
||||
@click="previewCert(c)"
|
||||
/>
|
||||
<div v-else class="cert-pending">{{ t('pages.artwork.watermarkPending') }}</div>
|
||||
</template>
|
||||
<div class="cert-meta">{{ c.issuer || '-' }}</div>
|
||||
<template #footer>
|
||||
<n-button v-if="auth.canWrite" text size="tiny" type="error" @click="removeCert(c)">
|
||||
{{ t('common.action.delete') }}
|
||||
</n-button>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</trace-module-editor>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
|
||||
<n-grid-item v-if="!isNew">
|
||||
<n-card :title="t('pages.artwork.changeRecords')" :bordered="false">
|
||||
@@ -349,12 +384,23 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NTag, type DataTableColumns, type FormInst, type FormRules } from 'naive-ui';
|
||||
import { ArrowBackOutline, AddOutline } from '@vicons/ionicons5';
|
||||
import { ArtworkStatus, CertType, NodeType } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkStatus,
|
||||
CertType,
|
||||
cloneTraceLayout,
|
||||
createDefaultTraceLayout,
|
||||
NodeType,
|
||||
parseTraceLayout,
|
||||
resolveTraceLayout,
|
||||
type TraceLayout,
|
||||
type TraceModule,
|
||||
} from '@artveris/shared';
|
||||
import { artworkApi, templateApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import MediaSorter from '@/components/MediaSorter.vue';
|
||||
import ArtworkShowcaseEditor from '@/components/ArtworkShowcaseEditor.vue';
|
||||
import TraceModuleEditor from '@/components/TraceModuleEditor.vue';
|
||||
import { openMediaViewer } from '@/composables/openMediaViewer';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmtDate, fmtSecond } from '@/utils/format';
|
||||
@@ -377,6 +423,7 @@ const form = reactive<any>({
|
||||
dynamicFields: {},
|
||||
images: [],
|
||||
showcaseImages: [],
|
||||
traceLayout: createDefaultTraceLayout(),
|
||||
showOutboundTimeline: false,
|
||||
});
|
||||
const submitReviewForm = reactive({ title: '', reason: '' });
|
||||
@@ -436,8 +483,11 @@ function defaultTraceNodes() {
|
||||
];
|
||||
}
|
||||
|
||||
function onTemplateChange() {
|
||||
function onTemplateChange(templateId?: number | null) {
|
||||
if (templateId !== undefined) form.templateId = templateId;
|
||||
form.dynamicFields = {};
|
||||
const template = templates.value.find((item) => item.id === form.templateId);
|
||||
form.traceLayout = cloneTraceLayout(resolveTraceLayout(template?.defaultTraceLayout));
|
||||
}
|
||||
|
||||
// 动态字段 IMAGE/FILE 适配:dynamicFields 存 url 字符串,MediaUpload 需要 MediaItem[]
|
||||
@@ -515,6 +565,7 @@ function applyArtworkToForm(a: any) {
|
||||
type: 'image',
|
||||
description: m.description || '',
|
||||
}));
|
||||
form.traceLayout = traceLayoutForForm(a.traceLayout);
|
||||
}
|
||||
|
||||
function applySnapshotToForm(snapshot: any) {
|
||||
@@ -526,6 +577,7 @@ function applySnapshotToForm(snapshot: any) {
|
||||
status: snapshot.artwork.status,
|
||||
showOutboundTimeline: snapshot.artwork.showOutboundTimeline ?? false,
|
||||
showcaseImages: snapshot.artwork.showcaseImages ?? [],
|
||||
traceLayout: snapshot.artwork.traceLayout,
|
||||
dynamicFields: snapshot.artwork.dynamicFields,
|
||||
images: snapshot.artwork.images,
|
||||
});
|
||||
@@ -594,6 +646,58 @@ function buildCertPayload() {
|
||||
}));
|
||||
}
|
||||
|
||||
function traceLayoutForForm(value: any): TraceLayout {
|
||||
if (value?.version === 1 && Array.isArray(value.modules)) {
|
||||
return JSON.parse(JSON.stringify(value)) as TraceLayout;
|
||||
}
|
||||
return createDefaultTraceLayout();
|
||||
}
|
||||
|
||||
function traceMediaPayload(item?: any) {
|
||||
if (!item?.key) return undefined;
|
||||
return {
|
||||
key: item.key,
|
||||
name: item.name || undefined,
|
||||
type: 'image' as const,
|
||||
description: item.description || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function buildTraceLayoutPayload(): TraceLayout {
|
||||
const modules = (form.traceLayout?.modules || []).map((module: TraceModule) => {
|
||||
const base: TraceModule = {
|
||||
id: module.id,
|
||||
type: module.type,
|
||||
visible: module.visible === true,
|
||||
...(module.title?.trim() ? { title: module.title.trim() } : {}),
|
||||
};
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config: any = module.config || {};
|
||||
const image = traceMediaPayload(config.image);
|
||||
return {
|
||||
...base,
|
||||
config: {
|
||||
imagePosition: config.imagePosition || 'TOP',
|
||||
...(config.heading?.trim() ? { heading: config.heading.trim() } : {}),
|
||||
...(config.body?.trim() ? { body: config.body.trim() } : {}),
|
||||
...(image ? { image } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config: any = module.config || {};
|
||||
return {
|
||||
...base,
|
||||
config: {
|
||||
items: (config.items || []).map(traceMediaPayload).filter(Boolean),
|
||||
},
|
||||
};
|
||||
}
|
||||
return base;
|
||||
});
|
||||
return parseTraceLayout({ version: 1, modules });
|
||||
}
|
||||
|
||||
async function saveArtwork(asDraft: boolean) {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
@@ -625,6 +729,7 @@ async function saveArtwork(asDraft: boolean) {
|
||||
description: m.description,
|
||||
type: 'image',
|
||||
})),
|
||||
traceLayout: buildTraceLayoutPayload(),
|
||||
revisionTitle: submitReviewForm.title || undefined,
|
||||
revisionReason: submitReviewForm.reason || undefined,
|
||||
traceNodes: buildNodePayload(),
|
||||
@@ -659,6 +764,7 @@ function buildComparableSnapshot() {
|
||||
dynamicFields: normalizeJson(form.dynamicFields || {}),
|
||||
images: normalizeMedia(form.images),
|
||||
showcaseImages: normalizeMedia(form.showcaseImages),
|
||||
traceLayout: buildTraceLayoutPayload(),
|
||||
},
|
||||
traceNodes: nodes.value.map((node, index) => ({
|
||||
nodeType: node.nodeType,
|
||||
@@ -877,6 +983,13 @@ onMounted(async () => {
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
.module-content-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.node-ops {
|
||||
display: inline-flex;
|
||||
gap: 8px;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
v-model:show="showModal"
|
||||
preset="card"
|
||||
:title="editing ? t('pages.template.edit') : t('pages.template.create')"
|
||||
style="width: 720px; max-width: 94vw"
|
||||
style="width: 960px; max-width: 94vw"
|
||||
>
|
||||
<n-form ref="formRef" :model="form" :rules="rules">
|
||||
<n-form-item path="name" :label="t('pages.template.name')">
|
||||
@@ -81,6 +81,12 @@
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-divider>{{ t('pages.template.defaultTraceLayout') }}</n-divider>
|
||||
<trace-module-editor
|
||||
v-model="form.defaultTraceLayout"
|
||||
template-mode
|
||||
:disabled="!auth.canWrite"
|
||||
/>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<div style="text-align: right">
|
||||
@@ -105,7 +111,15 @@ import {
|
||||
ArrowDownOutline,
|
||||
PowerOutline,
|
||||
} from '@vicons/ionicons5';
|
||||
import { FieldType, TemplateStatus } from '@artveris/shared';
|
||||
import {
|
||||
cloneTraceLayout,
|
||||
createDefaultTraceLayout,
|
||||
FieldType,
|
||||
resolveTraceLayout,
|
||||
templateTraceLayout,
|
||||
TemplateStatus,
|
||||
type TraceLayout,
|
||||
} from '@artveris/shared';
|
||||
import { templateApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
@@ -113,6 +127,7 @@ import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
import TraceModuleEditor from '@/components/TraceModuleEditor.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
@@ -130,7 +145,19 @@ const showModal = ref(false);
|
||||
const editing = ref<number | null>(null);
|
||||
const saving = ref(false);
|
||||
const formRef = ref<FormInst | null>(null);
|
||||
const form = reactive<{ name: string; remark: string; status: string; fields: any[] }>({ name: '', remark: '', status: 'ENABLED', fields: [] });
|
||||
const form = reactive<{
|
||||
name: string;
|
||||
remark: string;
|
||||
status: string;
|
||||
fields: any[];
|
||||
defaultTraceLayout: TraceLayout;
|
||||
}>({
|
||||
name: '',
|
||||
remark: '',
|
||||
status: 'ENABLED',
|
||||
fields: [],
|
||||
defaultTraceLayout: createDefaultTraceLayout(),
|
||||
});
|
||||
const rules: FormRules = { name: { required: true, message: () => t('pages.template.namePlaceholder'), trigger: 'blur' } };
|
||||
|
||||
function createDefaultTemplateFields() {
|
||||
@@ -271,6 +298,7 @@ function openCreate() {
|
||||
form.remark = '';
|
||||
form.status = 'ENABLED';
|
||||
form.fields = createDefaultTemplateFields();
|
||||
form.defaultTraceLayout = createDefaultTraceLayout();
|
||||
showModal.value = true;
|
||||
}
|
||||
function openEdit(r: any) {
|
||||
@@ -279,6 +307,7 @@ function openEdit(r: any) {
|
||||
form.remark = r.remark || '';
|
||||
form.status = r.status || 'ENABLED';
|
||||
form.fields = (r.fields || []).map((f: any) => ({ ...f }));
|
||||
form.defaultTraceLayout = cloneTraceLayout(resolveTraceLayout(r.defaultTraceLayout));
|
||||
showModal.value = true;
|
||||
}
|
||||
async function save() {
|
||||
@@ -295,7 +324,12 @@ async function save() {
|
||||
try {
|
||||
// 排序:按当前顺序写 sortOrder
|
||||
const fields = form.fields.map((f, i) => ({ ...f, sortOrder: i }));
|
||||
const payload: any = { name: form.name, remark: form.remark, fields };
|
||||
const payload: any = {
|
||||
name: form.name,
|
||||
remark: form.remark,
|
||||
fields,
|
||||
defaultTraceLayout: templateTraceLayout(form.defaultTraceLayout),
|
||||
};
|
||||
if (editing.value) payload.status = form.status;
|
||||
if (editing.value) {
|
||||
await templateApi.update(editing.value, payload);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `template`
|
||||
ADD COLUMN `default_trace_layout` JSON NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `artwork`
|
||||
ADD COLUMN `trace_layout` JSON NULL;
|
||||
@@ -184,13 +184,14 @@ model SysUser {
|
||||
}
|
||||
|
||||
model Template {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
remark String?
|
||||
status TemplateStatus @default(ENABLED)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
remark String?
|
||||
defaultTraceLayout Json? @map("default_trace_layout")
|
||||
status TemplateStatus @default(ENABLED)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
fields TemplateField[]
|
||||
artworks Artwork[]
|
||||
@@ -222,6 +223,7 @@ model Artwork {
|
||||
dynamicFields Json? @map("dynamic_fields")
|
||||
images Json?
|
||||
showcaseImages Json? @map("showcase_images")
|
||||
traceLayout Json? @map("trace_layout")
|
||||
showOutboundTimeline Boolean @default(false) @map("show_outbound_timeline")
|
||||
status ArtworkStatus @default(DRAFT)
|
||||
auditStatus AuditStatus @default(PENDING) @map("audit_status")
|
||||
|
||||
@@ -5,6 +5,7 @@ import { dirname, join, resolve } from 'path';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import { randomBytes, randomInt, createHash } from 'crypto';
|
||||
import sharp from 'sharp';
|
||||
import { createDefaultTraceLayout } from '@artveris/shared';
|
||||
import { addWatermark } from '../src/certificate/watermark.util';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
@@ -24,6 +25,41 @@ const DEFAULT_TEMPLATE_FIELDS = [
|
||||
{ fieldKey: 'dataOwner', label: '数据权属', type: 'TEXT', required: false, sortOrder: 5 },
|
||||
] as const;
|
||||
|
||||
function sampleTraceLayout(
|
||||
index: number,
|
||||
introImage: { key: string; name: string; type: string },
|
||||
galleryItems: Array<{ key: string; name: string; description: string; type: string }>,
|
||||
) {
|
||||
const layout = createDefaultTraceLayout();
|
||||
const authenticity = layout.modules.find((module) => module.type === 'AUTHENTICITY_STATUS');
|
||||
return {
|
||||
...layout,
|
||||
modules: [
|
||||
...layout.modules.filter((module) => module.type !== 'AUTHENTICITY_STATUS'),
|
||||
{
|
||||
id: `seed-image-text-${index + 1}`,
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
title: '创作说明',
|
||||
config: {
|
||||
heading: '匠心创作',
|
||||
body: '作品从构思、选材到成型均由艺术家全程把控,保留手工创作的独特痕迹。',
|
||||
imagePosition: index % 2 === 0 ? 'LEFT' : 'RIGHT',
|
||||
image: introImage,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: `seed-gallery-${index + 1}`,
|
||||
type: 'HORIZONTAL_GALLERY',
|
||||
visible: true,
|
||||
title: '多角度鉴赏',
|
||||
config: { items: galleryItems },
|
||||
},
|
||||
...(authenticity ? [authenticity] : []),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function writeStorage(key: string, buf: Buffer): string {
|
||||
const full = join(storageDir, key);
|
||||
mkdirSync(dirname(full), { recursive: true });
|
||||
@@ -107,6 +143,12 @@ async function ensureSampleData(): Promise<void> {
|
||||
const existing = await prisma.template.findFirst({ where: { name: '陶瓷溯源模板' } });
|
||||
if (existing) {
|
||||
await ensureTemplateDefaultFields(existing.id);
|
||||
if (!existing.defaultTraceLayout) {
|
||||
await prisma.template.update({
|
||||
where: { id: existing.id },
|
||||
data: { defaultTraceLayout: createDefaultTraceLayout() as any },
|
||||
});
|
||||
}
|
||||
console.log('示例数据已存在,跳过。');
|
||||
return;
|
||||
}
|
||||
@@ -117,6 +159,7 @@ async function ensureSampleData(): Promise<void> {
|
||||
data: {
|
||||
name: '陶瓷溯源模板',
|
||||
remark: '适用于陶瓷类艺术品',
|
||||
defaultTraceLayout: createDefaultTraceLayout() as any,
|
||||
fields: {
|
||||
create: DEFAULT_TEMPLATE_FIELDS.map((field) => ({ ...field })),
|
||||
},
|
||||
@@ -195,6 +238,11 @@ async function ensureSampleData(): Promise<void> {
|
||||
{ key: img2, name: '细节' },
|
||||
],
|
||||
showcaseImages,
|
||||
traceLayout: sampleTraceLayout(
|
||||
artworkSeq,
|
||||
{ key: img2, name: '创作细节', type: 'image' },
|
||||
showcaseImages,
|
||||
) as any,
|
||||
traceNodes: {
|
||||
create: [
|
||||
{ nodeType: 'CREATE', title: '创作设计', location: '景德镇', description: '设计选胚,确定器型与纹样。', sortOrder: 0, mediaFiles: createMedia },
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { ArtworkRevisionStatus, ArtworkStatus, AuditStatus, RoleType } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkRevisionStatus,
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
createDefaultTraceLayout,
|
||||
RoleType,
|
||||
} from '@artveris/shared';
|
||||
import type { AuthUser } from '../common/decorators/current-user.decorator';
|
||||
import { CertificateController } from '../certificate/certificate.controller';
|
||||
import { TraceNodeController } from '../trace-node/trace-node.controller';
|
||||
@@ -9,7 +15,7 @@ function user(role: RoleType, id = 9): AuthUser {
|
||||
return { id, username: role.toLowerCase(), role };
|
||||
}
|
||||
|
||||
function createHarness() {
|
||||
function createHarness(template: any = { id: 1 }) {
|
||||
const tx = {
|
||||
artwork: {
|
||||
create: jest.fn().mockImplementation(({ data }) => ({
|
||||
@@ -22,6 +28,7 @@ function createHarness() {
|
||||
dynamicFields: data.dynamicFields,
|
||||
images: data.images,
|
||||
showcaseImages: data.showcaseImages,
|
||||
traceLayout: data.traceLayout,
|
||||
showOutboundTimeline: data.showOutboundTimeline,
|
||||
traceNodes: [],
|
||||
certificates: [],
|
||||
@@ -33,7 +40,7 @@ function createHarness() {
|
||||
},
|
||||
};
|
||||
const prisma = {
|
||||
template: { findFirst: jest.fn().mockResolvedValue({ id: 1 }) },
|
||||
template: { findFirst: jest.fn().mockResolvedValue(template) },
|
||||
$transaction: jest.fn().mockImplementation(async (callback: any) => callback(tx)),
|
||||
};
|
||||
const service = new ArtworkService(prisma as any, {} as any, {} as any);
|
||||
@@ -150,6 +157,51 @@ it('stores showcase images in the artwork and its initial revision snapshot', as
|
||||
).toEqual(showcaseImages);
|
||||
});
|
||||
|
||||
it('deep-copies the template layout into a new artwork and its initial revision', async () => {
|
||||
const defaultTraceLayout = createDefaultTraceLayout();
|
||||
defaultTraceLayout.modules.push({
|
||||
id: 'custom-intro',
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
title: '创作说明',
|
||||
config: { imagePosition: 'LEFT' },
|
||||
});
|
||||
const { service, tx } = createHarness({ id: 1, defaultTraceLayout });
|
||||
|
||||
await service.create(
|
||||
{ templateId: 1, title: '使用模板布局的作品', status: ArtworkStatus.ACTIVE } as any,
|
||||
user(RoleType.SUPER_ADMIN),
|
||||
);
|
||||
|
||||
const stored = tx.artwork.create.mock.calls[0][0].data.traceLayout;
|
||||
const snapshotted =
|
||||
tx.artworkRevision.create.mock.calls[0][0].data.afterSnapshot.artwork.traceLayout;
|
||||
expect(stored).toEqual(defaultTraceLayout);
|
||||
expect(stored).not.toBe(defaultTraceLayout);
|
||||
expect(snapshotted).toEqual(defaultTraceLayout);
|
||||
stored.modules[0].visible = false;
|
||||
expect(defaultTraceLayout.modules[0].visible).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects an invalid layout before creating an artwork', async () => {
|
||||
const { service, tx } = createHarness();
|
||||
const invalid = createDefaultTraceLayout();
|
||||
invalid.modules.push({ ...invalid.modules[0] });
|
||||
|
||||
await expect(
|
||||
service.create(
|
||||
{
|
||||
templateId: 1,
|
||||
title: '非法布局',
|
||||
status: ArtworkStatus.ACTIVE,
|
||||
traceLayout: invalid,
|
||||
} as any,
|
||||
user(RoleType.SUPER_ADMIN),
|
||||
),
|
||||
).rejects.toThrow('页面模块配置无效');
|
||||
expect(tx.artwork.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
function updateHarness() {
|
||||
const current = {
|
||||
artwork: {
|
||||
@@ -289,6 +341,32 @@ describe('ArtworkService.update approval policy', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('applies a super-admin module layout change immediately', async () => {
|
||||
const { service, tx, applySnapshot } = updateHarness();
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
const authenticity = traceLayout.modules.find(
|
||||
(module) => module.type === 'AUTHENTICITY_STATUS',
|
||||
)!;
|
||||
traceLayout.modules = [
|
||||
...traceLayout.modules.filter((module) => module !== authenticity),
|
||||
{ ...authenticity, title: '真伪核验' },
|
||||
];
|
||||
|
||||
await service.update(7, { traceLayout } as any, user(RoleType.SUPER_ADMIN));
|
||||
|
||||
expect(
|
||||
tx.artworkRevision.create.mock.calls[0][0].data.afterSnapshot.artwork.traceLayout,
|
||||
).toEqual(traceLayout);
|
||||
expect(applySnapshot).toHaveBeenCalledWith(
|
||||
tx,
|
||||
7,
|
||||
expect.objectContaining({
|
||||
artwork: expect.objectContaining({ traceLayout }),
|
||||
}),
|
||||
expect.objectContaining({ auditStatus: AuditStatus.APPROVED, auditedBy: 9 }),
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps an operator revision pending and does not overwrite an approved formal version', async () => {
|
||||
const { service, tx, applySnapshot } = updateHarness();
|
||||
|
||||
@@ -327,6 +405,22 @@ describe('ArtworkService.update approval policy', () => {
|
||||
expect(applySnapshot).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('keeps an operator module layout change only in the pending snapshot', async () => {
|
||||
const { service, tx, applySnapshot } = updateHarness();
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
traceLayout.modules[1] = { ...traceLayout.modules[1], visible: false };
|
||||
|
||||
await service.update(7, { traceLayout } as any, user(RoleType.OPERATOR));
|
||||
|
||||
expect(
|
||||
tx.artworkRevision.create.mock.calls[0][0].data.afterSnapshot.artwork.traceLayout,
|
||||
).toEqual(traceLayout);
|
||||
expect(tx.artworkRevision.create.mock.calls[0][0].data.status).toBe(
|
||||
ArtworkRevisionStatus.PENDING,
|
||||
);
|
||||
expect(applySnapshot).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('treats a legacy snapshot without showcase images as an empty list', async () => {
|
||||
const { service, tx } = updateHarness();
|
||||
|
||||
@@ -456,6 +550,93 @@ describe('ArtworkService.audit approval boundary', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ArtworkService trace module compatibility and media', () => {
|
||||
it('does not overwrite the current layout when applying a historical snapshot without one', async () => {
|
||||
const tx = {
|
||||
artwork: { update: jest.fn().mockResolvedValue(undefined) },
|
||||
traceNode: { deleteMany: jest.fn().mockResolvedValue({ count: 0 }) },
|
||||
certificate: { findMany: jest.fn().mockResolvedValue([]), deleteMany: jest.fn() },
|
||||
};
|
||||
const service = new ArtworkService({} as any, {} as any, {} as any);
|
||||
|
||||
await (service as any).applySnapshot(
|
||||
tx,
|
||||
7,
|
||||
{
|
||||
artwork: {
|
||||
templateId: 1,
|
||||
title: '历史快照',
|
||||
artist: null,
|
||||
status: ArtworkStatus.ACTIVE,
|
||||
dynamicFields: {},
|
||||
images: [],
|
||||
showcaseImages: [],
|
||||
showOutboundTimeline: false,
|
||||
},
|
||||
traceNodes: [],
|
||||
certificates: [],
|
||||
},
|
||||
{
|
||||
auditStatus: AuditStatus.APPROVED,
|
||||
auditRemark: null,
|
||||
auditedBy: 12,
|
||||
auditedAt: new Date(),
|
||||
},
|
||||
);
|
||||
|
||||
expect(tx.artwork.update.mock.calls[0][0].data.traceLayout).toBeUndefined();
|
||||
});
|
||||
|
||||
it('relocates image-text and horizontal-gallery media into the artwork directory', async () => {
|
||||
let sequence = 0;
|
||||
const storage = {
|
||||
sanitizeSegment: jest.fn((value: string) => value),
|
||||
relocateMedia: jest.fn(async (items: any[], dir: string) => {
|
||||
const mapped = items.map((item) => ({
|
||||
...item,
|
||||
key: `${dir}/module-${++sequence}.jpg`,
|
||||
}));
|
||||
return {
|
||||
items: mapped,
|
||||
changed: mapped.length > 0,
|
||||
keyMap: new Map(items.map((item, index) => [item.key, mapped[index].key])),
|
||||
};
|
||||
}),
|
||||
};
|
||||
const service = new ArtworkService({} as any, storage as any, {} as any);
|
||||
const layout = createDefaultTraceLayout();
|
||||
layout.modules.push(
|
||||
{
|
||||
id: 'custom-image',
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
config: { imagePosition: 'TOP', image: { key: 'uploads/intro.jpg', type: 'image' } },
|
||||
},
|
||||
{
|
||||
id: 'custom-gallery',
|
||||
type: 'HORIZONTAL_GALLERY',
|
||||
visible: true,
|
||||
config: { items: [{ key: 'uploads/gallery.jpg', type: 'image' }] },
|
||||
},
|
||||
);
|
||||
|
||||
const result = await (service as any).relocateTraceLayoutMedia(
|
||||
layout,
|
||||
'1/ARTVERIS-000007',
|
||||
);
|
||||
|
||||
expect(result.changed).toBe(true);
|
||||
expect(result.keyMap.get('uploads/intro.jpg')).toMatch(/^1\/ARTVERIS-000007\//);
|
||||
expect(result.keyMap.get('uploads/gallery.jpg')).toMatch(/^1\/ARTVERIS-000007\//);
|
||||
expect(result.layout.modules[7].config.image.key).toMatch(
|
||||
/^1\/ARTVERIS-000007\//,
|
||||
);
|
||||
expect(result.layout.modules[8].config.items[0].key).toMatch(
|
||||
/^1\/ARTVERIS-000007\//,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ArtworkController.create', () => {
|
||||
it('passes the complete authenticated user to the service for role-based approval', () => {
|
||||
const service = { create: jest.fn() };
|
||||
|
||||
@@ -2,7 +2,20 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectQueue } from '@nestjs/bullmq';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { Queue } from 'bullmq';
|
||||
import { ArtworkRevisionStatus, ArtworkStatus, AuditStatus, ErrorCode, QUEUE_NAMES, RoleType } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkRevisionStatus,
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
ErrorCode,
|
||||
parseTraceLayout,
|
||||
QUEUE_NAMES,
|
||||
resolveTraceLayout,
|
||||
RoleType,
|
||||
type TraceHorizontalGalleryConfig,
|
||||
type TraceImageTextConfig,
|
||||
type TraceLayout,
|
||||
type TraceModuleMedia,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
@@ -57,6 +70,7 @@ interface ArtworkSnapshot {
|
||||
dynamicFields: Record<string, unknown>;
|
||||
images: MediaItem[];
|
||||
showcaseImages: MediaItem[];
|
||||
traceLayout?: TraceLayout;
|
||||
showOutboundTimeline: boolean;
|
||||
};
|
||||
traceNodes: TraceNodeSnapshot[];
|
||||
@@ -85,6 +99,130 @@ export class ArtworkService {
|
||||
.map((i) => ({ ...i, url: this.storage.getUrl(i.key) }));
|
||||
}
|
||||
|
||||
private parseArtworkTraceLayout(value: unknown): TraceLayout {
|
||||
try {
|
||||
return parseTraceLayout(value);
|
||||
} catch (error) {
|
||||
throw new BusinessException(
|
||||
ErrorCode.VALIDATION_FAILED,
|
||||
`页面模块配置无效:${(error as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private traceLayoutWithUrls(value: unknown) {
|
||||
const layout = resolveTraceLayout(value);
|
||||
return {
|
||||
...layout,
|
||||
modules: layout.modules.map((module) => {
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(config.image
|
||||
? { image: { ...config.image, url: this.storage.getUrl(config.image.key) } }
|
||||
: {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
items: (config.items ?? []).map((item) => ({
|
||||
...item,
|
||||
url: this.storage.getUrl(item.key),
|
||||
})),
|
||||
},
|
||||
};
|
||||
}
|
||||
return module;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
private remapTraceLayout(layout: TraceLayout, keyMap: Map<string, string>): TraceLayout {
|
||||
if (!keyMap.size) return layout;
|
||||
const remapItem = (item: TraceModuleMedia): TraceModuleMedia => ({
|
||||
...item,
|
||||
key: keyMap.get(item.key) ?? item.key,
|
||||
});
|
||||
return {
|
||||
...layout,
|
||||
modules: layout.modules.map((module) => {
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(config.image ? { image: remapItem(config.image) } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
items: (config.items ?? []).map(remapItem),
|
||||
},
|
||||
};
|
||||
}
|
||||
return module;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
private async relocateTraceLayoutMedia(
|
||||
layout: TraceLayout,
|
||||
dir: string,
|
||||
): Promise<{ layout: TraceLayout; changed: boolean; keyMap: Map<string, string> }> {
|
||||
let changed = false;
|
||||
const keyMap = new Map<string, string>();
|
||||
const modules: TraceLayout['modules'] = [];
|
||||
for (let index = 0; index < layout.modules.length; index += 1) {
|
||||
const module = layout.modules[index];
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
const relocated = await this.storage.relocateMedia(
|
||||
config.image ? [config.image] : [],
|
||||
dir,
|
||||
`模块图文-${this.storage.sanitizeSegment(module.title || String(index + 1))}`,
|
||||
);
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
changed ||= relocated.changed;
|
||||
modules.push({
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(relocated.items[0] ? { image: relocated.items[0] } : {}),
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
const relocated = await this.storage.relocateMedia(
|
||||
config.items ?? [],
|
||||
dir,
|
||||
`模块图库-${this.storage.sanitizeSegment(module.title || String(index + 1))}`,
|
||||
);
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
changed ||= relocated.changed;
|
||||
modules.push({ ...module, config: { ...config, items: relocated.items } });
|
||||
continue;
|
||||
}
|
||||
modules.push(module);
|
||||
}
|
||||
return { layout: { ...layout, modules }, changed, keyMap };
|
||||
}
|
||||
|
||||
private buildArchiveNo(id: number): string {
|
||||
return `ARTVERIS-${String(id).padStart(6, '0')}`;
|
||||
}
|
||||
@@ -128,6 +266,18 @@ export class ArtworkService {
|
||||
});
|
||||
}
|
||||
|
||||
const currentLayout = resolveTraceLayout(artwork.traceLayout);
|
||||
const remappedLayout = this.remapTraceLayout(currentLayout, keyMap);
|
||||
const layoutRemapped = JSON.stringify(currentLayout) !== JSON.stringify(remappedLayout);
|
||||
const traceLayout = await this.relocateTraceLayoutMedia(remappedLayout, dir);
|
||||
traceLayout.keyMap.forEach((v, k) => keyMap.set(k, v));
|
||||
if (layoutRemapped || traceLayout.changed) {
|
||||
await this.prisma.artwork.update({
|
||||
where: { id: artworkId },
|
||||
data: { traceLayout: traceLayout.layout as unknown as Prisma.InputJsonValue },
|
||||
});
|
||||
}
|
||||
|
||||
for (const node of artwork.traceNodes) {
|
||||
const media = await this.storage.relocateMedia(
|
||||
(node.mediaFiles ?? []) as unknown as MediaItem[],
|
||||
@@ -189,6 +339,10 @@ export class ArtworkService {
|
||||
const traceNodes =
|
||||
dto.traceNodes === undefined ? DEFAULT_TRACE_NODES : this.normalizeTraceNodeDto(dto.traceNodes);
|
||||
const certificates = this.normalizeCertificateDto(dto.certificates ?? []);
|
||||
const traceLayout =
|
||||
dto.traceLayout === undefined
|
||||
? resolveTraceLayout(tpl.defaultTraceLayout)
|
||||
: this.parseArtworkTraceLayout(dto.traceLayout);
|
||||
|
||||
const { created: artwork, revisionId } = await this.prisma.$transaction(async (tx) => {
|
||||
const created = await tx.artwork.create({
|
||||
@@ -204,6 +358,7 @@ export class ArtworkService {
|
||||
dynamicFields: (dto.dynamicFields ?? {}) as Prisma.InputJsonValue,
|
||||
images: (dto.images ?? []) as unknown as Prisma.InputJsonValue,
|
||||
showcaseImages: (dto.showcaseImages ?? []) as unknown as Prisma.InputJsonValue,
|
||||
traceLayout: traceLayout as unknown as Prisma.InputJsonValue,
|
||||
showOutboundTimeline: dto.showOutboundTimeline ?? false,
|
||||
createdBy: userId,
|
||||
traceNodes: traceNodes.length
|
||||
@@ -391,6 +546,7 @@ export class ArtworkService {
|
||||
...a,
|
||||
images: this.mapMedia(a.images),
|
||||
showcaseImages: this.mapMedia(a.showcaseImages),
|
||||
traceLayout: this.traceLayoutWithUrls(a.traceLayout),
|
||||
traceNodes: a.traceNodes.map((n) => ({ ...n, mediaFiles: this.mapMedia(n.mediaFiles) })),
|
||||
certificates: a.certificates.map((c) => ({
|
||||
...c,
|
||||
@@ -407,6 +563,8 @@ export class ArtworkService {
|
||||
async update(id: number, dto: UpdateArtworkDto, user: AuthUser) {
|
||||
const userId = user.id;
|
||||
const artwork = await this.ensureExists(id);
|
||||
let dtoTraceLayout =
|
||||
dto.traceLayout === undefined ? undefined : this.parseArtworkTraceLayout(dto.traceLayout);
|
||||
// 先把既有媒体归位(含历史日期目录的旧文件),拿到 old->new 映射改写 DTO 引用;
|
||||
// 再把 DTO 里新上传的媒体(仍在通用上传目录)归位,保证快照/落库全部使用最终 key
|
||||
const keyMap = await this.relocateArtworkMedia(id);
|
||||
@@ -414,11 +572,15 @@ export class ArtworkService {
|
||||
|
||||
let dtoImages = this.remapMedia(dto.images as MediaItem[] | undefined, keyMap);
|
||||
if (dtoImages && dir) {
|
||||
dtoImages = (await this.storage.relocateMedia(dtoImages, dir, '作品图')).items;
|
||||
const relocated = await this.storage.relocateMedia(dtoImages, dir, '作品图');
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
dtoImages = relocated.items;
|
||||
}
|
||||
let dtoShowcaseImages = this.remapMedia(dto.showcaseImages as MediaItem[] | undefined, keyMap);
|
||||
if (dtoShowcaseImages && dir) {
|
||||
dtoShowcaseImages = (await this.storage.relocateMedia(dtoShowcaseImages, dir, '作品展示')).items;
|
||||
const relocated = await this.storage.relocateMedia(dtoShowcaseImages, dir, '作品展示');
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
dtoShowcaseImages = relocated.items;
|
||||
}
|
||||
let dtoNodes = dto.traceNodes ? this.normalizeTraceNodeDto(dto.traceNodes) : undefined;
|
||||
if (dtoNodes && dir) {
|
||||
@@ -448,6 +610,14 @@ export class ArtworkService {
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (dtoTraceLayout) {
|
||||
dtoTraceLayout = this.remapTraceLayout(dtoTraceLayout, keyMap);
|
||||
if (dir) {
|
||||
const relocated = await this.relocateTraceLayoutMedia(dtoTraceLayout, dir);
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
dtoTraceLayout = relocated.layout;
|
||||
}
|
||||
}
|
||||
|
||||
const current = await this.getSnapshot(id);
|
||||
const nextStatus = dto.status === ArtworkStatus.DRAFT ? ArtworkStatus.ACTIVE : dto.status ?? current.artwork.status;
|
||||
@@ -460,6 +630,7 @@ export class ArtworkService {
|
||||
dynamicFields: dto.dynamicFields ?? current.artwork.dynamicFields,
|
||||
images: (dtoImages ?? current.artwork.images) as MediaItem[],
|
||||
showcaseImages: (dtoShowcaseImages ?? current.artwork.showcaseImages ?? []) as MediaItem[],
|
||||
traceLayout: dtoTraceLayout ?? current.artwork.traceLayout ?? resolveTraceLayout(null),
|
||||
showOutboundTimeline: dto.showOutboundTimeline ?? current.artwork.showOutboundTimeline ?? false,
|
||||
},
|
||||
traceNodes: dtoNodes ?? current.traceNodes,
|
||||
@@ -672,6 +843,7 @@ export class ArtworkService {
|
||||
dynamicFields: Prisma.JsonValue | null;
|
||||
images: Prisma.JsonValue | null;
|
||||
showcaseImages?: Prisma.JsonValue | null;
|
||||
traceLayout?: Prisma.JsonValue | null;
|
||||
showOutboundTimeline?: boolean;
|
||||
traceNodes: Array<{
|
||||
nodeType: string;
|
||||
@@ -700,6 +872,7 @@ export class ArtworkService {
|
||||
dynamicFields: (record.dynamicFields as Record<string, unknown>) ?? {},
|
||||
images: (Array.isArray(record.images) ? record.images : []) as unknown as MediaItem[],
|
||||
showcaseImages: (Array.isArray(record.showcaseImages) ? record.showcaseImages : []) as unknown as MediaItem[],
|
||||
traceLayout: resolveTraceLayout(record.traceLayout),
|
||||
showOutboundTimeline: record.showOutboundTimeline ?? false,
|
||||
},
|
||||
traceNodes: record.traceNodes
|
||||
@@ -744,6 +917,7 @@ export class ArtworkService {
|
||||
dynamicFields: this.normalizeJson(snapshot.artwork.dynamicFields ?? {}),
|
||||
images: this.normalizeMedia(snapshot.artwork.images),
|
||||
showcaseImages: this.normalizeMedia(snapshot.artwork.showcaseImages),
|
||||
traceLayout: resolveTraceLayout(snapshot.artwork.traceLayout),
|
||||
showOutboundTimeline: snapshot.artwork.showOutboundTimeline ?? false,
|
||||
},
|
||||
traceNodes: snapshot.traceNodes.map((node, index) => ({
|
||||
@@ -806,6 +980,7 @@ export class ArtworkService {
|
||||
...snapshot.artwork,
|
||||
images: this.mapMedia(snapshot.artwork.images),
|
||||
showcaseImages: this.mapMedia(snapshot.artwork.showcaseImages),
|
||||
traceLayout: this.traceLayoutWithUrls(snapshot.artwork.traceLayout),
|
||||
},
|
||||
traceNodes: snapshot.traceNodes.map((node) => ({
|
||||
...node,
|
||||
@@ -847,6 +1022,10 @@ export class ArtworkService {
|
||||
dynamicFields: snapshot.artwork.dynamicFields as Prisma.InputJsonObject,
|
||||
images: snapshot.artwork.images as unknown as Prisma.InputJsonValue,
|
||||
showcaseImages: (snapshot.artwork.showcaseImages ?? []) as unknown as Prisma.InputJsonValue,
|
||||
traceLayout:
|
||||
snapshot.artwork.traceLayout === undefined
|
||||
? undefined
|
||||
: (resolveTraceLayout(snapshot.artwork.traceLayout) as unknown as Prisma.InputJsonValue),
|
||||
showOutboundTimeline: snapshot.artwork.showOutboundTimeline ?? false,
|
||||
...auditData,
|
||||
},
|
||||
|
||||
@@ -83,6 +83,11 @@ export class CreateArtworkDto {
|
||||
@Type(() => MediaItemDto)
|
||||
showcaseImages?: MediaItemDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端页面模块布局' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
traceLayout?: Record<string, unknown>;
|
||||
|
||||
@ApiPropertyOptional({ description: '状态', enum: ArtworkStatus })
|
||||
@IsOptional()
|
||||
@IsEnum(ArtworkStatus)
|
||||
@@ -215,6 +220,11 @@ export class UpdateArtworkDto {
|
||||
@Type(() => MediaItemDto)
|
||||
showcaseImages?: MediaItemDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端页面模块布局' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
traceLayout?: Record<string, unknown>;
|
||||
|
||||
@ApiPropertyOptional({ description: '状态', enum: ArtworkStatus })
|
||||
@IsOptional()
|
||||
@IsEnum(ArtworkStatus)
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { ArtworkStatus, AuditStatus, TraceCodeStatus } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
createDefaultTraceLayout,
|
||||
TraceCodeStatus,
|
||||
} from '@artveris/shared';
|
||||
import { PublicTraceService } from './public-trace.service';
|
||||
|
||||
function createHarness(options: {
|
||||
artworkStatus?: ArtworkStatus;
|
||||
showOutboundTimeline?: boolean;
|
||||
withOutbound?: boolean;
|
||||
traceLayout?: any;
|
||||
} = {}) {
|
||||
const outbound = options.withOutbound
|
||||
? {
|
||||
@@ -58,6 +64,7 @@ function createHarness(options: {
|
||||
},
|
||||
],
|
||||
dynamicFields: null,
|
||||
traceLayout: options.traceLayout ?? null,
|
||||
showOutboundTimeline: options.showOutboundTimeline ?? false,
|
||||
template: { fields: [] },
|
||||
traceNodes: [],
|
||||
@@ -69,8 +76,14 @@ function createHarness(options: {
|
||||
if (select && Object.keys(select).length === 1 && select.id) return { id: code.id };
|
||||
return code;
|
||||
}),
|
||||
updateMany: jest.fn(),
|
||||
updateMany: jest.fn().mockResolvedValue({ count: 1 }),
|
||||
update: jest.fn(),
|
||||
findUniqueOrThrow: jest.fn().mockResolvedValue({
|
||||
...code,
|
||||
status: TraceCodeStatus.ACTIVE,
|
||||
queryCount: 1,
|
||||
firstActivatedAt: new Date('2026-07-19T08:00:00.000Z'),
|
||||
}),
|
||||
},
|
||||
artwork: { findFirst: jest.fn().mockResolvedValue(artwork) },
|
||||
queryLog: { create: jest.fn().mockResolvedValue({}) },
|
||||
@@ -155,3 +168,94 @@ describe('PublicTraceService artwork showcase', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PublicTraceService module layout', () => {
|
||||
it('returns the legacy default order for artwork without a saved layout', async () => {
|
||||
const { service } = createHarness({ artworkStatus: ArtworkStatus.ACTIVE });
|
||||
|
||||
const result = await service.preview('482731000001', 'inactive');
|
||||
|
||||
expect((result as any).artwork.traceLayout.modules.map((module: any) => module.type)).toEqual([
|
||||
'HERO_CAROUSEL',
|
||||
'AUTHENTICITY_STATUS',
|
||||
'PRODUCT_INTRO',
|
||||
'SHOWCASE',
|
||||
'CERTIFICATES',
|
||||
'TIMELINE',
|
||||
'BLOCKCHAIN',
|
||||
]);
|
||||
});
|
||||
|
||||
it('filters hidden modules and converts custom module media keys to public URLs', async () => {
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
traceLayout.modules[1] = { ...traceLayout.modules[1], visible: false };
|
||||
traceLayout.modules.push({
|
||||
id: 'custom-story',
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
title: '创作故事',
|
||||
config: {
|
||||
heading: '釉色灵感',
|
||||
body: '源于山水。',
|
||||
imagePosition: 'LEFT',
|
||||
image: {
|
||||
key: 'artwork/10/story.jpg',
|
||||
name: '创作手稿',
|
||||
description: '艺术家手稿',
|
||||
type: 'image',
|
||||
},
|
||||
},
|
||||
});
|
||||
const { service } = createHarness({
|
||||
artworkStatus: ArtworkStatus.ACTIVE,
|
||||
traceLayout,
|
||||
});
|
||||
|
||||
const result = await service.preview('482731000001', 'inactive');
|
||||
const modules = (result as any).artwork.traceLayout.modules;
|
||||
|
||||
expect(modules.some((module: any) => module.type === 'AUTHENTICITY_STATUS')).toBe(false);
|
||||
expect(modules.find((module: any) => module.id === 'custom-story').config.image).toEqual({
|
||||
name: '创作手稿',
|
||||
description: '艺术家手稿',
|
||||
type: 'image',
|
||||
url: '/uploads/artwork/10/story.jpg',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps first-scan activation and query logging when the authenticity module is hidden', async () => {
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
traceLayout.modules[1] = { ...traceLayout.modules[1], visible: false };
|
||||
const { service, prisma } = createHarness({
|
||||
artworkStatus: ArtworkStatus.ACTIVE,
|
||||
traceLayout,
|
||||
});
|
||||
|
||||
const result = await service.trace('482731000001', { ip: '127.0.0.1' });
|
||||
|
||||
expect(result.status).toBe('OK');
|
||||
expect((result as any).antiCounterfeit.firstQuery).toBe(true);
|
||||
expect(prisma.traceCode.updateMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: expect.objectContaining({ status: TraceCodeStatus.INACTIVE }),
|
||||
}),
|
||||
);
|
||||
expect(prisma.queryLog.create).toHaveBeenCalled();
|
||||
expect(
|
||||
(result as any).artwork.traceLayout.modules.some(
|
||||
(module: any) => module.type === 'AUTHENTICITY_STATUS',
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps active preview free of activation, counting and query-log side effects', async () => {
|
||||
const { service, prisma } = createHarness({ artworkStatus: ArtworkStatus.ACTIVE });
|
||||
|
||||
const result = await service.preview('482731000001', 'active');
|
||||
|
||||
expect(result.status).toBe('OK');
|
||||
expect(prisma.traceCode.updateMany).not.toHaveBeenCalled();
|
||||
expect(prisma.traceCode.update).not.toHaveBeenCalled();
|
||||
expect(prisma.queryLog.create).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common';
|
||||
import type Redis from 'ioredis';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { ArtworkStatus, AuditStatus, QueryResult, ProofStatus, TRACE_CODE_PATTERN, TraceCodeStatus } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
QueryResult,
|
||||
ProofStatus,
|
||||
resolveTraceLayout,
|
||||
TRACE_CODE_PATTERN,
|
||||
TraceCodeStatus,
|
||||
type TraceHorizontalGalleryConfig,
|
||||
type TraceImageTextConfig,
|
||||
type TraceModuleMedia,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { SettingsService } from '../settings/settings.service';
|
||||
@@ -52,6 +63,44 @@ export class PublicTraceService {
|
||||
}));
|
||||
}
|
||||
|
||||
private mapTraceLayout(value: unknown) {
|
||||
const publicMedia = (item: TraceModuleMedia) => ({
|
||||
name: item.name,
|
||||
type: item.type ?? 'image',
|
||||
description: item.description,
|
||||
url: this.storage.getUrl(item.key),
|
||||
});
|
||||
const layout = resolveTraceLayout(value);
|
||||
return {
|
||||
...layout,
|
||||
modules: layout.modules
|
||||
.filter((module) => module.visible)
|
||||
.map((module) => {
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(config.image ? { image: publicMedia(config.image) } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
items: (config.items ?? []).map(publicMedia),
|
||||
},
|
||||
};
|
||||
}
|
||||
return module;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
private buildTimeline(
|
||||
nodes: Array<{
|
||||
nodeType: string;
|
||||
@@ -328,6 +377,7 @@ export class PublicTraceService {
|
||||
archiveNo: artwork.archiveNo,
|
||||
images: this.mapMedia(artwork.images),
|
||||
showcaseImages: this.mapMedia(artwork.showcaseImages),
|
||||
traceLayout: this.mapTraceLayout(artwork.traceLayout),
|
||||
showOutboundTimeline: artwork.showOutboundTimeline,
|
||||
fields: this.buildFields(artwork.template.fields, artwork.dynamicFields),
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
IsEnum,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
@@ -62,6 +63,11 @@ export class CreateTemplateDto {
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => TemplateFieldDto)
|
||||
fields!: TemplateFieldDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端默认页面模块布局(建档时复制)' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
defaultTraceLayout?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateTemplateDto {
|
||||
@@ -88,6 +94,11 @@ export class UpdateTemplateDto {
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => TemplateFieldDto)
|
||||
fields?: TemplateFieldDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端默认页面模块布局(仅影响后续新建作品)' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
defaultTraceLayout?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class QueryTemplateDto extends PaginationDto {
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { ErrorCode, TemplateStatus } from '@artveris/shared';
|
||||
import {
|
||||
createDefaultTraceLayout,
|
||||
ErrorCode,
|
||||
parseTraceLayout,
|
||||
templateTraceLayout,
|
||||
TemplateStatus,
|
||||
type TraceLayout,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { buildPage } from '../common/utils/pagination.util';
|
||||
@@ -11,6 +18,24 @@ import { CreateTemplateDto, QueryTemplateDto, UpdateTemplateDto, TemplateFieldDt
|
||||
export class TemplateService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
private parseDefaultTraceLayout(value: unknown): TraceLayout {
|
||||
try {
|
||||
return parseTraceLayout(value ?? createDefaultTraceLayout(), { template: true });
|
||||
} catch (error) {
|
||||
throw new BusinessException(
|
||||
ErrorCode.VALIDATION_FAILED,
|
||||
`页面模块配置无效:${(error as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private withDefaultTraceLayout<T extends { defaultTraceLayout: Prisma.JsonValue | null }>(template: T) {
|
||||
return {
|
||||
...template,
|
||||
defaultTraceLayout: templateTraceLayout(template.defaultTraceLayout),
|
||||
};
|
||||
}
|
||||
|
||||
private fieldsCreate(fields: TemplateFieldDto[]) {
|
||||
return fields.map((f, i) => ({
|
||||
fieldKey: f.fieldKey,
|
||||
@@ -22,14 +47,16 @@ export class TemplateService {
|
||||
}
|
||||
|
||||
async create(dto: CreateTemplateDto) {
|
||||
return this.prisma.template.create({
|
||||
const template = await this.prisma.template.create({
|
||||
data: {
|
||||
name: dto.name,
|
||||
remark: dto.remark,
|
||||
defaultTraceLayout: this.parseDefaultTraceLayout(dto.defaultTraceLayout) as unknown as Prisma.InputJsonValue,
|
||||
fields: { create: this.fieldsCreate(dto.fields) },
|
||||
},
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
});
|
||||
return this.withDefaultTraceLayout(template);
|
||||
}
|
||||
|
||||
async list(query: QueryTemplateDto) {
|
||||
@@ -47,16 +74,22 @@ export class TemplateService {
|
||||
}),
|
||||
this.prisma.template.count({ where }),
|
||||
]);
|
||||
return buildPage(list, total, query.page, query.pageSize);
|
||||
return buildPage(
|
||||
list.map((template) => this.withDefaultTraceLayout(template)),
|
||||
total,
|
||||
query.page,
|
||||
query.pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
// 供建档表单选择的启用模板(含字段)
|
||||
async options() {
|
||||
return this.prisma.template.findMany({
|
||||
const templates = await this.prisma.template.findMany({
|
||||
where: { deletedAt: null, status: TemplateStatus.ENABLED },
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
orderBy: { id: 'desc' },
|
||||
});
|
||||
return templates.map((template) => this.withDefaultTraceLayout(template));
|
||||
}
|
||||
|
||||
async get(id: number) {
|
||||
@@ -65,7 +98,7 @@ export class TemplateService {
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
});
|
||||
if (!tpl) throw new BusinessException(ErrorCode.TEMPLATE_NOT_FOUND, '模板不存在', 404);
|
||||
return tpl;
|
||||
return this.withDefaultTraceLayout(tpl);
|
||||
}
|
||||
|
||||
async update(id: number, dto: UpdateTemplateDto) {
|
||||
@@ -77,11 +110,20 @@ export class TemplateService {
|
||||
data: this.fieldsCreate(dto.fields).map((f) => ({ ...f, templateId: id })),
|
||||
});
|
||||
}
|
||||
return tx.template.update({
|
||||
const template = await tx.template.update({
|
||||
where: { id },
|
||||
data: { name: dto.name, remark: dto.remark, status: dto.status },
|
||||
data: {
|
||||
name: dto.name,
|
||||
remark: dto.remark,
|
||||
status: dto.status,
|
||||
defaultTraceLayout:
|
||||
dto.defaultTraceLayout === undefined
|
||||
? undefined
|
||||
: (this.parseDefaultTraceLayout(dto.defaultTraceLayout) as unknown as Prisma.InputJsonValue),
|
||||
},
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
});
|
||||
return this.withDefaultTraceLayout(template);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"lint": "echo \"(client) lint skipped\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@artveris/shared": "workspace:*",
|
||||
"axios": "^1.7.9",
|
||||
"dayjs": "^1.11.13",
|
||||
"photoswipe": "^5.4.4",
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<section class="anti">
|
||||
<div class="anti-badge">✓</div>
|
||||
<div class="anti-main">
|
||||
<div class="anti-section-title">{{ title }}</div>
|
||||
<div class="anti-title">{{ antiCounterfeit.firstQuery ? t('anti.firstTitle') : t('anti.repeatTitle') }}</div>
|
||||
<div class="anti-desc">{{ antiCounterfeit.firstQuery ? t('anti.firstDesc') : t('anti.repeatDesc') }}</div>
|
||||
<div class="anti-meta">
|
||||
<span>{{ t('anti.queryCount', { n: antiCounterfeit.queryCount }) }}</span>
|
||||
<span v-if="antiCounterfeit.firstActivatedAt">
|
||||
· {{ t('anti.firstActivatedAt', { t: formatTime(antiCounterfeit.firstActivatedAt) }) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="queriedAt" class="anti-meta">
|
||||
{{ t('anti.queriedAt', { t: formatTime(queriedAt) }) }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import dayjs from 'dayjs';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
defineProps<{
|
||||
title: string;
|
||||
antiCounterfeit: {
|
||||
firstQuery: boolean;
|
||||
queryCount: number;
|
||||
firstActivatedAt?: string | null;
|
||||
};
|
||||
queriedAt?: string | null;
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
|
||||
function formatTime(value?: string | null) {
|
||||
return value ? dayjs(value).format('YYYY-MM-DD HH:mm') : '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.anti {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
margin: 12px;
|
||||
padding: 16px;
|
||||
border-radius: 14px;
|
||||
background: var(--anti-bg);
|
||||
color: #fff;
|
||||
}
|
||||
.anti-badge {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 22px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.anti-main {
|
||||
min-width: 0;
|
||||
}
|
||||
.anti-section-title {
|
||||
margin-bottom: 3px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
opacity: 0.78;
|
||||
}
|
||||
.anti-title {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.anti-desc {
|
||||
font-size: 13px;
|
||||
opacity: 0.92;
|
||||
margin: 4px 0;
|
||||
}
|
||||
.anti-meta {
|
||||
font-size: 12px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<section class="card">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<div v-if="archiveNo" class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.archiveNo') }}</span>
|
||||
<span class="chain-v mono">{{ archiveNo }}</span>
|
||||
</div>
|
||||
<template v-if="blockchain">
|
||||
<div class="chain-row chain-status-row">
|
||||
<span class="chain-k">{{ t('chain.status') }}</span>
|
||||
<span class="chain-status" :class="`is-${status.toLowerCase()}`">
|
||||
{{ t(`chain.statuses.${status}`) }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="status !== 'ONCHAIN'" class="chain-status-note muted">
|
||||
{{ t(`chain.statusDescriptions.${status}`) }}
|
||||
</p>
|
||||
<p v-if="blockchain.failureReason" class="chain-failure-reason">
|
||||
<span class="muted">{{ t('chain.failureReason') }}</span>
|
||||
{{ blockchain.failureReason }}
|
||||
</p>
|
||||
<div v-if="blockchain.txHash" class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.hash') }}</span>
|
||||
<span class="chain-v mono">{{ ellipsis(blockchain.txHash) }}</span>
|
||||
<button
|
||||
class="icon-copy"
|
||||
:aria-label="t('chain.copy')"
|
||||
:title="t('chain.copy')"
|
||||
@click="$emit('copy', blockchain.txHash)"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true">
|
||||
<rect x="9" y="9" width="11" height="11" rx="2" fill="none" stroke="currentColor" stroke-width="1.7" />
|
||||
<path d="M5 15V5a2 2 0 0 1 2-2h8" fill="none" stroke="currentColor" stroke-width="1.7" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="blockchain.contractAddress" class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.contract') }}</span>
|
||||
<span class="chain-v mono">{{ ellipsis(blockchain.contractAddress) }}</span>
|
||||
<button
|
||||
class="icon-copy"
|
||||
:aria-label="t('chain.copy')"
|
||||
:title="t('chain.copy')"
|
||||
@click="$emit('copy', blockchain.contractAddress)"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true">
|
||||
<rect x="9" y="9" width="11" height="11" rx="2" fill="none" stroke="currentColor" stroke-width="1.7" />
|
||||
<path d="M5 15V5a2 2 0 0 1 2-2h8" fill="none" stroke="currentColor" stroke-width="1.7" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="blockchain.blockHeight != null" class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.blockHeight') }}</span>
|
||||
<span class="chain-v">{{ blockchain.blockHeight }}</span>
|
||||
</div>
|
||||
<div v-if="blockchain.onchainAt" class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.onchainAt') }}</span>
|
||||
<span class="chain-v">{{ formatTime(blockchain.onchainAt) }}</span>
|
||||
</div>
|
||||
<a
|
||||
v-if="explorerUrl"
|
||||
class="chain-link"
|
||||
:href="explorerUrl"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{{ t('chain.explorer') }} →
|
||||
</a>
|
||||
</template>
|
||||
<div v-else class="chain-empty muted">{{ t('chain.notOnchain') }}</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import dayjs from 'dayjs';
|
||||
import { safeTraceUrl } from './media';
|
||||
|
||||
type ProofStatus = 'PENDING' | 'SUBMITTING' | 'CONFIRMING' | 'ONCHAIN' | 'FAILED' | 'UNKNOWN';
|
||||
const STATUSES = new Set<ProofStatus>([
|
||||
'PENDING',
|
||||
'SUBMITTING',
|
||||
'CONFIRMING',
|
||||
'ONCHAIN',
|
||||
'FAILED',
|
||||
'UNKNOWN',
|
||||
]);
|
||||
|
||||
const props = defineProps<{
|
||||
title: string;
|
||||
archiveNo?: string | null;
|
||||
blockchain?: {
|
||||
status?: string;
|
||||
txHash?: string | null;
|
||||
contractAddress?: string | null;
|
||||
blockHeight?: string | number | null;
|
||||
onchainAt?: string | null;
|
||||
explorerUrl?: string | null;
|
||||
failureReason?: string | null;
|
||||
} | null;
|
||||
}>();
|
||||
defineEmits<{ (event: 'copy', value: string): void }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const status = computed<ProofStatus>(() => {
|
||||
const value = props.blockchain?.status as ProofStatus | undefined;
|
||||
return value && STATUSES.has(value) ? value : 'ONCHAIN';
|
||||
});
|
||||
const explorerUrl = computed(() => safeTraceUrl(props.blockchain?.explorerUrl || undefined));
|
||||
|
||||
function ellipsis(value?: string | null) {
|
||||
if (!value) return '-';
|
||||
return value.length > 16 ? `${value.slice(0, 8)}…${value.slice(-6)}` : value;
|
||||
}
|
||||
|
||||
function formatTime(value: string) {
|
||||
return dayjs(value).format('YYYY-MM-DD HH:mm');
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chain-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px dashed var(--trace-divider);
|
||||
}
|
||||
.chain-k {
|
||||
width: 78px;
|
||||
color: var(--muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.chain-v {
|
||||
flex: 1;
|
||||
word-break: break-all;
|
||||
}
|
||||
.chain-status-row {
|
||||
min-height: 45px;
|
||||
}
|
||||
.chain-status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.chain-status.is-pending {
|
||||
color: #596579;
|
||||
background: rgba(100, 116, 139, 0.14);
|
||||
}
|
||||
.chain-status.is-submitting {
|
||||
color: #2563a6;
|
||||
background: rgba(37, 99, 166, 0.13);
|
||||
}
|
||||
.chain-status.is-confirming {
|
||||
color: #a15c00;
|
||||
background: rgba(217, 119, 6, 0.14);
|
||||
}
|
||||
.chain-status.is-onchain {
|
||||
color: #087d5a;
|
||||
background: rgba(5, 150, 105, 0.14);
|
||||
}
|
||||
.chain-status.is-failed {
|
||||
color: #b42318;
|
||||
background: rgba(180, 35, 24, 0.12);
|
||||
}
|
||||
.chain-status.is-unknown {
|
||||
color: #9a4a00;
|
||||
background: rgba(194, 83, 0, 0.13);
|
||||
}
|
||||
.chain-status-note,
|
||||
.chain-failure-reason {
|
||||
margin: 8px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
.chain-failure-reason {
|
||||
color: var(--trace-desc);
|
||||
word-break: break-word;
|
||||
}
|
||||
.mono {
|
||||
font-family: 'SFMono-Regular', Consolas, monospace;
|
||||
}
|
||||
.icon-copy {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--card-bg);
|
||||
border-radius: 50%;
|
||||
color: var(--brand);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
.icon-copy:active {
|
||||
background: var(--soft-bg);
|
||||
}
|
||||
.chain-link {
|
||||
display: inline-block;
|
||||
margin-top: 10px;
|
||||
color: var(--brand-2);
|
||||
font-size: 14px;
|
||||
text-decoration: none;
|
||||
}
|
||||
.chain-empty {
|
||||
font-size: 13px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<section class="card">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<div class="cert-carousel">
|
||||
<button
|
||||
v-if="items.length > 1"
|
||||
type="button"
|
||||
class="cert-nav prev"
|
||||
:aria-label="t('viewer.prev')"
|
||||
@click="switchCert(-1)"
|
||||
>
|
||||
‹
|
||||
</button>
|
||||
<div v-if="current" class="cert">
|
||||
<img
|
||||
v-if="current.url"
|
||||
:src="traceMediaUrl(current)"
|
||||
loading="lazy"
|
||||
@click="openCurrent"
|
||||
/>
|
||||
<div v-else class="cert-placeholder">{{ current.name }}</div>
|
||||
<div class="cert-head">
|
||||
<span class="cert-name text-ellipsis">{{ current.name }}</span>
|
||||
</div>
|
||||
<div v-if="current.issuer" class="muted cert-issuer text-ellipsis">{{ current.issuer }}</div>
|
||||
<div v-if="current.issuedAt" class="muted cert-issuer">{{ formatDate(current.issuedAt) }}</div>
|
||||
</div>
|
||||
<button
|
||||
v-if="items.length > 1"
|
||||
type="button"
|
||||
class="cert-nav next"
|
||||
:aria-label="t('viewer.next')"
|
||||
@click="switchCert(1)"
|
||||
>
|
||||
›
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="items.length > 1" class="cert-dots">
|
||||
<button
|
||||
v-for="(_, index) in items"
|
||||
:key="index"
|
||||
type="button"
|
||||
class="dot"
|
||||
:class="{ active: index === certIndex }"
|
||||
:aria-label="String(index + 1)"
|
||||
@click="certIndex = index"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import dayjs from 'dayjs';
|
||||
import { openTraceViewer, traceMediaUrl } from './media';
|
||||
|
||||
interface Certificate {
|
||||
url?: string | null;
|
||||
name?: string;
|
||||
issuer?: string | null;
|
||||
issuedAt?: string | null;
|
||||
}
|
||||
|
||||
const props = defineProps<{ title: string; items: Certificate[] }>();
|
||||
const { t } = useI18n();
|
||||
const certIndex = ref(0);
|
||||
const current = computed(() => props.items[certIndex.value] || null);
|
||||
|
||||
function switchCert(step: number) {
|
||||
if (!props.items.length) return;
|
||||
certIndex.value = (certIndex.value + step + props.items.length) % props.items.length;
|
||||
}
|
||||
|
||||
function openCurrent() {
|
||||
openTraceViewer(
|
||||
props.items.map((item) => ({ url: traceMediaUrl(item), name: item.name, type: 'image' })),
|
||||
certIndex.value,
|
||||
);
|
||||
}
|
||||
|
||||
function formatDate(value: string) {
|
||||
return dayjs(value).format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.items,
|
||||
() => {
|
||||
certIndex.value = 0;
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.text-ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cert-carousel {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 190px;
|
||||
padding: 0 38px;
|
||||
}
|
||||
.cert {
|
||||
width: min(100%, 440px);
|
||||
text-align: center;
|
||||
}
|
||||
.cert img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-height: 420px;
|
||||
object-fit: contain;
|
||||
border-radius: 10px;
|
||||
background: var(--soft-bg);
|
||||
cursor: zoom-in;
|
||||
display: block;
|
||||
}
|
||||
.cert-placeholder {
|
||||
height: 170px;
|
||||
border-radius: 10px;
|
||||
background: var(--soft-bg);
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
.cert-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.cert-name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
max-width: 280px;
|
||||
}
|
||||
.cert-issuer {
|
||||
font-size: 12px;
|
||||
}
|
||||
.cert-nav {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 32px;
|
||||
height: 44px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--card-bg);
|
||||
color: var(--brand);
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.cert-nav.prev {
|
||||
left: 0;
|
||||
}
|
||||
.cert-nav.next {
|
||||
right: 0;
|
||||
}
|
||||
.cert-nav:active {
|
||||
background: var(--soft-bg);
|
||||
}
|
||||
.cert-dots {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: var(--trace-dot-bg);
|
||||
cursor: pointer;
|
||||
}
|
||||
.dot.active {
|
||||
width: 18px;
|
||||
border-radius: 4px;
|
||||
background: var(--brand-2);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,419 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="items.length"
|
||||
ref="carouselEl"
|
||||
class="carousel"
|
||||
:class="{ 'no-anim': noAnim }"
|
||||
@pointerdown="onDragStart"
|
||||
@pointermove="onDragMove"
|
||||
@pointerup="onDragEnd"
|
||||
@pointercancel="onDragEnd"
|
||||
@mouseenter="pauseAuto"
|
||||
@mouseleave="resumeAuto"
|
||||
>
|
||||
<div class="carousel-track" :style="trackStyle" @transitionend="onTransitionEnd">
|
||||
<div
|
||||
v-for="(slide, index) in loopSlides"
|
||||
:key="index"
|
||||
class="carousel-slide"
|
||||
:class="{ current: index === pos }"
|
||||
@click="onSlideClick(index, slide)"
|
||||
>
|
||||
<video
|
||||
v-if="isTraceVideo(slide.media)"
|
||||
:src="traceMediaUrl(slide.media)"
|
||||
class="carousel-media"
|
||||
muted
|
||||
playsinline
|
||||
preload="metadata"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
:src="traceMediaUrl(slide.media)"
|
||||
:alt="slide.media.name"
|
||||
class="carousel-media"
|
||||
loading="lazy"
|
||||
/>
|
||||
<div v-if="isTraceVideo(slide.media)" class="play-overlay">
|
||||
<svg viewBox="0 0 64 64" width="56" height="56" aria-hidden="true">
|
||||
<circle cx="32" cy="32" r="30" fill="rgba(0,0,0,0.42)" />
|
||||
<polygon points="26,21 46,32 26,43" fill="#fff" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
v-if="items.length > 1"
|
||||
type="button"
|
||||
class="carousel-nav prev"
|
||||
:aria-label="t('viewer.prev')"
|
||||
@pointerdown.stop
|
||||
@click.stop="go(pos - 1)"
|
||||
>
|
||||
‹
|
||||
</button>
|
||||
<button
|
||||
v-if="items.length > 1"
|
||||
type="button"
|
||||
class="carousel-nav next"
|
||||
:aria-label="t('viewer.next')"
|
||||
@pointerdown.stop
|
||||
@click.stop="go(pos + 1)"
|
||||
>
|
||||
›
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="items.length > 1" class="carousel-ind">
|
||||
<div class="carousel-dots">
|
||||
<button
|
||||
v-for="(_, index) in items"
|
||||
:key="index"
|
||||
type="button"
|
||||
class="dot"
|
||||
:class="{ active: index === carouselIndex }"
|
||||
:aria-label="String(index + 1)"
|
||||
@click="goToReal(index)"
|
||||
/>
|
||||
</div>
|
||||
<div class="carousel-count">
|
||||
<span v-if="isTraceVideo(items[carouselIndex])" class="carousel-count-ico">▶</span>
|
||||
{{ carouselIndex + 1 }} / {{ items.length }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onUnmounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
isTraceVideo,
|
||||
openTraceViewer,
|
||||
traceMediaUrl,
|
||||
type PublicMediaItem,
|
||||
} from './media';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ items: PublicMediaItem[]; interval?: number }>(),
|
||||
{ interval: 3 },
|
||||
);
|
||||
const { t } = useI18n();
|
||||
|
||||
const carouselEl = ref<HTMLElement | null>(null);
|
||||
const pos = ref(0);
|
||||
const viewW = ref(0);
|
||||
const slideW = ref(0);
|
||||
const stride = ref(0);
|
||||
const dragDelta = ref(0);
|
||||
const dragging = ref(false);
|
||||
const noAnim = ref(true);
|
||||
|
||||
let autoTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let resizeObserver: ResizeObserver | undefined;
|
||||
let startX = 0;
|
||||
let startY = 0;
|
||||
let axisLocked = false;
|
||||
let moved = false;
|
||||
|
||||
const items = computed(() => props.items || []);
|
||||
const loopSlides = computed<{ media: PublicMediaItem; real: number }[]>(() => {
|
||||
if (items.value.length <= 1) {
|
||||
return items.value.map((media, real) => ({ media, real }));
|
||||
}
|
||||
return [
|
||||
{ media: items.value[items.value.length - 1], real: items.value.length - 1 },
|
||||
...items.value.map((media, real) => ({ media, real })),
|
||||
{ media: items.value[0], real: 0 },
|
||||
];
|
||||
});
|
||||
const carouselIndex = computed(() => {
|
||||
if (items.value.length <= 1) return 0;
|
||||
return ((pos.value - 1) % items.value.length + items.value.length) % items.value.length;
|
||||
});
|
||||
const intervalMs = computed(() => Math.round(Math.max(0, props.interval) * 1000));
|
||||
const autoEnabled = computed(() => intervalMs.value > 0 && items.value.length > 1);
|
||||
const baseTrackX = computed(() => (viewW.value - slideW.value) / 2 - pos.value * stride.value);
|
||||
const trackStyle = computed(() => ({
|
||||
transform: `translateX(${baseTrackX.value + dragDelta.value}px)`,
|
||||
transitionDuration: noAnim.value || dragging.value ? '0ms' : '450ms',
|
||||
}));
|
||||
|
||||
function measureCarousel() {
|
||||
const element = carouselEl.value;
|
||||
if (!element) return;
|
||||
viewW.value = element.clientWidth;
|
||||
const slides = element.querySelector('.carousel-track')?.children;
|
||||
if (!slides?.length) return;
|
||||
const first = slides[0] as HTMLElement;
|
||||
slideW.value = first.offsetWidth;
|
||||
stride.value =
|
||||
slides.length > 1 ? (slides[1] as HTMLElement).offsetLeft - first.offsetLeft : first.offsetWidth;
|
||||
}
|
||||
|
||||
function clearAuto() {
|
||||
if (!autoTimer) return;
|
||||
clearTimeout(autoTimer);
|
||||
autoTimer = undefined;
|
||||
}
|
||||
|
||||
function scheduleAuto() {
|
||||
clearAuto();
|
||||
if (autoEnabled.value) autoTimer = setTimeout(() => go(pos.value + 1), intervalMs.value);
|
||||
}
|
||||
|
||||
function pauseAuto() {
|
||||
clearAuto();
|
||||
}
|
||||
|
||||
function resumeAuto() {
|
||||
scheduleAuto();
|
||||
}
|
||||
|
||||
function go(next: number) {
|
||||
pos.value = next;
|
||||
scheduleAuto();
|
||||
}
|
||||
|
||||
function goToReal(index: number) {
|
||||
go(index + 1);
|
||||
}
|
||||
|
||||
async function onTransitionEnd(event: TransitionEvent) {
|
||||
if (event.target !== event.currentTarget || event.propertyName !== 'transform') return;
|
||||
const count = items.value.length;
|
||||
if (count <= 1) return;
|
||||
let target = pos.value;
|
||||
if (pos.value > count) target = pos.value - count;
|
||||
else if (pos.value < 1) target = pos.value + count;
|
||||
if (target === pos.value) return;
|
||||
noAnim.value = true;
|
||||
pos.value = target;
|
||||
await nextTick();
|
||||
requestAnimationFrame(() =>
|
||||
requestAnimationFrame(() => {
|
||||
noAnim.value = false;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function onSlideClick(index: number, slide: { media: PublicMediaItem; real: number }) {
|
||||
if (moved) {
|
||||
moved = false;
|
||||
return;
|
||||
}
|
||||
if (index === pos.value) openTraceViewer(items.value, slide.real);
|
||||
else go(index);
|
||||
}
|
||||
|
||||
function onDragStart(event: PointerEvent) {
|
||||
if (items.value.length <= 1) return;
|
||||
dragging.value = true;
|
||||
moved = false;
|
||||
axisLocked = false;
|
||||
startX = event.clientX;
|
||||
startY = event.clientY;
|
||||
dragDelta.value = 0;
|
||||
pauseAuto();
|
||||
}
|
||||
|
||||
function onDragMove(event: PointerEvent) {
|
||||
if (!dragging.value) return;
|
||||
const deltaX = event.clientX - startX;
|
||||
const deltaY = event.clientY - startY;
|
||||
if (!axisLocked) {
|
||||
if (Math.abs(deltaX) < 6 && Math.abs(deltaY) < 6) return;
|
||||
axisLocked = true;
|
||||
if (Math.abs(deltaY) > Math.abs(deltaX)) {
|
||||
dragging.value = false;
|
||||
dragDelta.value = 0;
|
||||
return;
|
||||
}
|
||||
carouselEl.value?.setPointerCapture?.(event.pointerId);
|
||||
}
|
||||
moved = true;
|
||||
dragDelta.value = deltaX;
|
||||
}
|
||||
|
||||
function onDragEnd(event?: PointerEvent) {
|
||||
if (!dragging.value) return;
|
||||
dragging.value = false;
|
||||
const delta = dragDelta.value;
|
||||
dragDelta.value = 0;
|
||||
if (event && carouselEl.value?.hasPointerCapture?.(event.pointerId)) {
|
||||
carouselEl.value.releasePointerCapture(event.pointerId);
|
||||
}
|
||||
const threshold = Math.max(40, slideW.value * 0.18);
|
||||
if (delta <= -threshold) go(pos.value + 1);
|
||||
else if (delta >= threshold) go(pos.value - 1);
|
||||
else scheduleAuto();
|
||||
}
|
||||
|
||||
function onResize() {
|
||||
noAnim.value = true;
|
||||
measureCarousel();
|
||||
requestAnimationFrame(() =>
|
||||
requestAnimationFrame(() => {
|
||||
noAnim.value = false;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async function resetCarousel() {
|
||||
clearAuto();
|
||||
resizeObserver?.disconnect();
|
||||
pos.value = items.value.length > 1 ? 1 : 0;
|
||||
noAnim.value = true;
|
||||
dragDelta.value = 0;
|
||||
await nextTick();
|
||||
measureCarousel();
|
||||
if (carouselEl.value) {
|
||||
resizeObserver = new ResizeObserver(onResize);
|
||||
resizeObserver.observe(carouselEl.value);
|
||||
}
|
||||
requestAnimationFrame(() =>
|
||||
requestAnimationFrame(() => {
|
||||
noAnim.value = false;
|
||||
scheduleAuto();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
watch([items, () => props.interval], resetCarousel, { immediate: true });
|
||||
onUnmounted(() => {
|
||||
clearAuto();
|
||||
resizeObserver?.disconnect();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.carousel {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
touch-action: pan-y;
|
||||
user-select: none;
|
||||
}
|
||||
.carousel-track {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
transition-property: transform;
|
||||
transition-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
|
||||
will-change: transform;
|
||||
}
|
||||
.carousel.no-anim .carousel-track,
|
||||
.carousel.no-anim .carousel-slide {
|
||||
transition: none !important;
|
||||
}
|
||||
.carousel-slide {
|
||||
position: relative;
|
||||
flex: 0 0 80%;
|
||||
max-width: 420px;
|
||||
height: 240px;
|
||||
border-radius: 14px;
|
||||
background: var(--trace-thumb-bg);
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transform: scale(0.9);
|
||||
opacity: 0.55;
|
||||
transition:
|
||||
transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
|
||||
opacity 0.45s ease;
|
||||
}
|
||||
.carousel-slide.current {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
.carousel-nav {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 36px;
|
||||
height: 56px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
background: rgba(13, 148, 136, 0.5);
|
||||
color: #fff;
|
||||
font-size: 26px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
.carousel:hover .carousel-nav {
|
||||
opacity: 1;
|
||||
}
|
||||
.carousel-nav.prev {
|
||||
left: 14px;
|
||||
}
|
||||
.carousel-nav.next {
|
||||
right: 14px;
|
||||
}
|
||||
.carousel-nav:active {
|
||||
background: rgba(13, 148, 136, 0.78);
|
||||
}
|
||||
@media (hover: none) {
|
||||
.carousel-nav {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.carousel-ind {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.carousel-dots {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: var(--trace-dot-bg);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
width 0.25s ease,
|
||||
background 0.25s ease;
|
||||
}
|
||||
.dot.active {
|
||||
width: 18px;
|
||||
border-radius: 4px;
|
||||
background: #0f7b63;
|
||||
}
|
||||
.carousel-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.carousel-count-ico {
|
||||
font-size: 10px;
|
||||
color: #0f7b63;
|
||||
}
|
||||
.carousel-media {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
background: #000;
|
||||
}
|
||||
.play-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<section class="card horizontal-gallery-card">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<div class="horizontal-gallery">
|
||||
<article
|
||||
v-for="(item, index) in items"
|
||||
:key="item.url || item.key || index"
|
||||
class="horizontal-gallery-item"
|
||||
@click="openTraceViewer(items, index)"
|
||||
>
|
||||
<img
|
||||
:src="traceMediaUrl(item)"
|
||||
:alt="item.name || title"
|
||||
loading="lazy"
|
||||
/>
|
||||
<div v-if="item.name || item.description" class="horizontal-gallery-copy">
|
||||
<strong v-if="item.name">{{ item.name }}</strong>
|
||||
<p v-if="item.description">{{ item.description }}</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { openTraceViewer, traceMediaUrl, type PublicMediaItem } from './media';
|
||||
|
||||
defineProps<{ title: string; items: PublicMediaItem[] }>();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.horizontal-gallery-card {
|
||||
overflow: hidden;
|
||||
}
|
||||
.horizontal-gallery {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
overflow-x: auto;
|
||||
padding: 2px 2px 8px;
|
||||
scroll-snap-type: x mandatory;
|
||||
scrollbar-width: thin;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.horizontal-gallery-item {
|
||||
flex: 0 0 min(78%, 340px);
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--trace-divider);
|
||||
border-radius: 10px;
|
||||
background: var(--soft-bg);
|
||||
cursor: zoom-in;
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
.horizontal-gallery-item img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 4 / 3;
|
||||
object-fit: cover;
|
||||
}
|
||||
.horizontal-gallery-copy {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.horizontal-gallery-copy strong {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
}
|
||||
.horizontal-gallery-copy p {
|
||||
margin: 5px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<section class="card image-text-card">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<div class="image-text-layout" :class="`position-${position.toLowerCase()}`">
|
||||
<img
|
||||
v-if="config.image?.url || config.image?.key"
|
||||
class="image-text-image"
|
||||
:src="traceMediaUrl(config.image)"
|
||||
:alt="config.image.name || config.heading || title"
|
||||
loading="lazy"
|
||||
@click="openImage"
|
||||
/>
|
||||
<div v-if="config.heading || config.body" class="image-text-copy">
|
||||
<h3 v-if="config.heading">{{ config.heading }}</h3>
|
||||
<p v-if="config.body">{{ config.body }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { openTraceViewer, traceMediaUrl, type PublicMediaItem } from './media';
|
||||
|
||||
const props = defineProps<{
|
||||
title: string;
|
||||
config: {
|
||||
image?: PublicMediaItem;
|
||||
heading?: string;
|
||||
body?: string;
|
||||
imagePosition?: 'TOP' | 'BOTTOM' | 'LEFT' | 'RIGHT';
|
||||
};
|
||||
}>();
|
||||
const position = computed(() => props.config.imagePosition || 'TOP');
|
||||
|
||||
function openImage() {
|
||||
if (props.config.image) openTraceViewer([props.config.image], 0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.image-text-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
.image-text-image {
|
||||
order: 0;
|
||||
width: 100%;
|
||||
max-height: 480px;
|
||||
object-fit: contain;
|
||||
border-radius: 10px;
|
||||
background: var(--soft-bg);
|
||||
cursor: zoom-in;
|
||||
}
|
||||
.image-text-copy {
|
||||
order: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.image-text-copy h3 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 17px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.image-text-copy p {
|
||||
margin: 0;
|
||||
color: var(--trace-desc);
|
||||
font-size: 14px;
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
.position-bottom .image-text-image {
|
||||
order: 1;
|
||||
}
|
||||
.position-bottom .image-text-copy {
|
||||
order: 0;
|
||||
}
|
||||
@media (min-width: 521px) {
|
||||
.position-left,
|
||||
.position-right {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
align-items: center;
|
||||
}
|
||||
.position-right .image-text-image {
|
||||
order: 1;
|
||||
}
|
||||
.position-right .image-text-copy {
|
||||
order: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<template v-for="module in modules" :key="module.id">
|
||||
<trace-hero-module
|
||||
v-if="module.type === 'HERO_CAROUSEL' && hasContent(module)"
|
||||
:items="data.artwork.images"
|
||||
:interval="carouselInterval"
|
||||
/>
|
||||
<trace-authenticity-module
|
||||
v-else-if="module.type === 'AUTHENTICITY_STATUS' && hasContent(module)"
|
||||
:title="moduleTitle(module)"
|
||||
:anti-counterfeit="data.antiCounterfeit"
|
||||
:queried-at="data.queriedAt"
|
||||
/>
|
||||
<trace-product-intro-module
|
||||
v-else-if="module.type === 'PRODUCT_INTRO' && hasContent(module)"
|
||||
:title="moduleTitle(module)"
|
||||
:artwork="data.artwork"
|
||||
/>
|
||||
<trace-showcase-module
|
||||
v-else-if="module.type === 'SHOWCASE' && hasContent(module)"
|
||||
:title="moduleTitle(module)"
|
||||
:items="showcaseImages"
|
||||
/>
|
||||
<trace-certificates-module
|
||||
v-else-if="module.type === 'CERTIFICATES' && hasContent(module)"
|
||||
:title="moduleTitle(module)"
|
||||
:items="data.certificates"
|
||||
/>
|
||||
<trace-timeline-module
|
||||
v-else-if="module.type === 'TIMELINE' && hasContent(module)"
|
||||
:title="moduleTitle(module)"
|
||||
:items="timelineItems"
|
||||
:outbound-remark="outboundRemark"
|
||||
:outbound-images-total="outboundImagesTotal"
|
||||
:can-load-more="canLoadMoreOutboundImages"
|
||||
:loading-more="outboundImagesLoading"
|
||||
@load-more="$emit('load-more-outbound')"
|
||||
/>
|
||||
<trace-blockchain-module
|
||||
v-else-if="module.type === 'BLOCKCHAIN'"
|
||||
:title="moduleTitle(module)"
|
||||
:archive-no="data.artwork.archiveNo"
|
||||
:blockchain="data.blockchain"
|
||||
@copy="(value) => $emit('copy', value)"
|
||||
/>
|
||||
<trace-image-text-module
|
||||
v-else-if="module.type === 'IMAGE_TEXT' && hasContent(module)"
|
||||
:title="moduleTitle(module)"
|
||||
:config="moduleConfig(module)"
|
||||
/>
|
||||
<trace-horizontal-gallery-module
|
||||
v-else-if="module.type === 'HORIZONTAL_GALLERY' && hasContent(module)"
|
||||
:title="moduleTitle(module)"
|
||||
:items="moduleConfig(module).items"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
createDefaultTraceLayout,
|
||||
type TraceLayout,
|
||||
type TraceModule,
|
||||
type TraceModuleType,
|
||||
} from '@artveris/shared';
|
||||
import TraceHeroModule from './TraceHeroModule.vue';
|
||||
import TraceAuthenticityModule from './TraceAuthenticityModule.vue';
|
||||
import TraceProductIntroModule from './TraceProductIntroModule.vue';
|
||||
import TraceShowcaseModule from './TraceShowcaseModule.vue';
|
||||
import TraceCertificatesModule from './TraceCertificatesModule.vue';
|
||||
import TraceTimelineModule from './TraceTimelineModule.vue';
|
||||
import TraceBlockchainModule from './TraceBlockchainModule.vue';
|
||||
import TraceImageTextModule from './TraceImageTextModule.vue';
|
||||
import TraceHorizontalGalleryModule from './TraceHorizontalGalleryModule.vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
data: any;
|
||||
layout?: TraceLayout;
|
||||
timelineItems?: any[];
|
||||
carouselInterval?: number;
|
||||
outboundRemark?: string;
|
||||
outboundImagesTotal?: number;
|
||||
canLoadMoreOutboundImages?: boolean;
|
||||
outboundImagesLoading?: boolean;
|
||||
}>(),
|
||||
{
|
||||
timelineItems: () => [],
|
||||
carouselInterval: 3,
|
||||
outboundRemark: '',
|
||||
outboundImagesTotal: 0,
|
||||
canLoadMoreOutboundImages: false,
|
||||
outboundImagesLoading: false,
|
||||
},
|
||||
);
|
||||
defineEmits<{
|
||||
(event: 'load-more-outbound'): void;
|
||||
(event: 'copy', value: string): void;
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const modules = computed(() => {
|
||||
const value = props.layout as any;
|
||||
const source =
|
||||
value?.version === 1 && Array.isArray(value.modules)
|
||||
? value.modules
|
||||
: createDefaultTraceLayout().modules;
|
||||
return source.filter(
|
||||
(module: TraceModule) =>
|
||||
module?.visible !== false &&
|
||||
[
|
||||
'HERO_CAROUSEL',
|
||||
'AUTHENTICITY_STATUS',
|
||||
'PRODUCT_INTRO',
|
||||
'SHOWCASE',
|
||||
'CERTIFICATES',
|
||||
'TIMELINE',
|
||||
'BLOCKCHAIN',
|
||||
'IMAGE_TEXT',
|
||||
'HORIZONTAL_GALLERY',
|
||||
].includes(module.type),
|
||||
) as TraceModule[];
|
||||
});
|
||||
const showcaseImages = computed(() => {
|
||||
const items = props.data?.artwork?.showcaseImages;
|
||||
return Array.isArray(items) ? items.filter((item: any) => item?.url || item?.key) : [];
|
||||
});
|
||||
|
||||
const TITLE_KEYS: Record<Exclude<TraceModuleType, 'HERO_CAROUSEL'>, string> = {
|
||||
AUTHENTICITY_STATUS: 'section.authenticity',
|
||||
PRODUCT_INTRO: 'section.basic',
|
||||
SHOWCASE: 'section.showcase',
|
||||
CERTIFICATES: 'section.cert',
|
||||
TIMELINE: 'section.timeline',
|
||||
BLOCKCHAIN: 'section.chain',
|
||||
IMAGE_TEXT: 'section.imageText',
|
||||
HORIZONTAL_GALLERY: 'section.horizontalGallery',
|
||||
};
|
||||
|
||||
function moduleTitle(module: TraceModule) {
|
||||
if (module.title?.trim()) return module.title.trim();
|
||||
if (module.type === 'HERO_CAROUSEL') return '';
|
||||
return t(TITLE_KEYS[module.type]);
|
||||
}
|
||||
|
||||
function moduleConfig(module: TraceModule): any {
|
||||
return module.config || {};
|
||||
}
|
||||
|
||||
function hasContent(module: TraceModule) {
|
||||
switch (module.type) {
|
||||
case 'HERO_CAROUSEL':
|
||||
return Array.isArray(props.data?.artwork?.images) && props.data.artwork.images.length > 0;
|
||||
case 'AUTHENTICITY_STATUS':
|
||||
return Boolean(props.data?.antiCounterfeit);
|
||||
case 'PRODUCT_INTRO':
|
||||
return Boolean(props.data?.artwork);
|
||||
case 'SHOWCASE':
|
||||
return showcaseImages.value.length > 0;
|
||||
case 'CERTIFICATES':
|
||||
return Array.isArray(props.data?.certificates) && props.data.certificates.length > 0;
|
||||
case 'TIMELINE':
|
||||
return props.timelineItems.length > 0;
|
||||
case 'IMAGE_TEXT': {
|
||||
const config = moduleConfig(module);
|
||||
return Boolean(config.image?.url || config.image?.key || config.heading || config.body);
|
||||
}
|
||||
case 'HORIZONTAL_GALLERY':
|
||||
return Array.isArray(moduleConfig(module).items) && moduleConfig(module).items.length > 0;
|
||||
case 'BLOCKCHAIN':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<section class="card product-intro-card">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<h1 class="art-title">{{ artwork.title }}</h1>
|
||||
<div class="fields">
|
||||
<div v-if="artwork.artist" class="field">
|
||||
<span class="field-label">{{ t('artist') }}</span>
|
||||
<span class="field-value">{{ artwork.artist }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(field, index) in artwork.fields"
|
||||
:key="index"
|
||||
class="field"
|
||||
:class="{ 'field-media': field.type === 'IMAGE' && field.value }"
|
||||
>
|
||||
<span class="field-label">{{ field.label }}</span>
|
||||
<span class="field-value">
|
||||
<img
|
||||
v-if="field.type === 'IMAGE' && field.value"
|
||||
:src="traceMediaUrl(field.value)"
|
||||
class="field-img"
|
||||
loading="lazy"
|
||||
@click="openTraceViewer([{ url: traceMediaUrl(field.value), type: 'image', name: field.label }], 0)"
|
||||
/>
|
||||
<a
|
||||
v-else-if="(field.type === 'LINK' || field.type === 'FILE') && safeTraceUrl(field.value)"
|
||||
:href="safeTraceUrl(field.value)"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
class="field-link"
|
||||
>
|
||||
{{ field.type === 'FILE' ? t('field.viewFile') : field.value }}
|
||||
</a>
|
||||
<template v-else>{{ field.value }}</template>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { openTraceViewer, safeTraceUrl, traceMediaUrl } from './media';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
title: string;
|
||||
artwork: {
|
||||
title?: string;
|
||||
artist?: string | null;
|
||||
fields?: Array<{ label: string; type: string; value: any }>;
|
||||
};
|
||||
}>(),
|
||||
{ artwork: () => ({ fields: [] }) },
|
||||
);
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.art-title {
|
||||
font-size: 20px;
|
||||
margin: 0 0 14px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.product-intro-card .section-title {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.fields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.field {
|
||||
display: grid;
|
||||
grid-template-columns: 132px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
column-gap: 10px;
|
||||
font-size: 14px;
|
||||
border-bottom: 1px dashed var(--trace-divider);
|
||||
padding: 3px 0 9px;
|
||||
}
|
||||
.field-label {
|
||||
color: var(--muted);
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.field-value {
|
||||
min-width: 0;
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
word-break: break-word;
|
||||
}
|
||||
.field-img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
background: var(--trace-thumb-bg);
|
||||
display: block;
|
||||
}
|
||||
.field.field-media {
|
||||
display: block;
|
||||
padding: 8px 0 12px;
|
||||
}
|
||||
.field-media .field-label {
|
||||
display: block;
|
||||
margin-bottom: 9px;
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
white-space: normal;
|
||||
}
|
||||
.field-media .field-value {
|
||||
display: block;
|
||||
}
|
||||
.field-link {
|
||||
color: var(--brand-2);
|
||||
word-break: break-all;
|
||||
}
|
||||
@media (max-width: 420px) {
|
||||
.field {
|
||||
grid-template-columns: 118px minmax(0, 1fr);
|
||||
column-gap: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<section class="card showcase-card">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<div class="showcase-list">
|
||||
<article v-for="(item, index) in items" :key="item.url || item.key || index" class="showcase-item">
|
||||
<div v-if="item.name || item.description" class="showcase-copy">
|
||||
<h3 v-if="item.name" class="showcase-title">{{ item.name }}</h3>
|
||||
<p v-if="item.description" class="showcase-description">{{ item.description }}</p>
|
||||
</div>
|
||||
<img
|
||||
:src="traceMediaUrl(item)"
|
||||
:alt="item.name || title"
|
||||
class="showcase-image"
|
||||
loading="lazy"
|
||||
@click="openTraceViewer(items, index)"
|
||||
/>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { openTraceViewer, traceMediaUrl, type PublicMediaItem } from './media';
|
||||
|
||||
defineProps<{ title: string; items: PublicMediaItem[] }>();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.showcase-card {
|
||||
padding: 16px 0 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.showcase-card > .section-title {
|
||||
margin: 0 16px 14px;
|
||||
}
|
||||
.showcase-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.showcase-item {
|
||||
margin: 0;
|
||||
}
|
||||
.showcase-item + .showcase-item {
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid var(--trace-divider);
|
||||
}
|
||||
.showcase-copy {
|
||||
padding: 0 16px 12px;
|
||||
}
|
||||
.showcase-title {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
line-height: 1.45;
|
||||
color: var(--text);
|
||||
}
|
||||
.showcase-description {
|
||||
margin: 6px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.showcase-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
background: var(--soft-bg);
|
||||
cursor: zoom-in;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,273 @@
|
||||
<template>
|
||||
<section class="card">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<div class="timeline">
|
||||
<div
|
||||
v-for="(node, index) in items"
|
||||
:key="node.system || `${node.nodeType || 'node'}-${index}`"
|
||||
class="tl-item"
|
||||
>
|
||||
<div class="tl-dot" />
|
||||
<div class="tl-body">
|
||||
<div class="tl-title">{{ nodeTitle(node) }}</div>
|
||||
<div class="tl-meta muted">
|
||||
{{ [nodeOccurredAt(node), node.location].filter(Boolean).join(' · ') }}
|
||||
</div>
|
||||
<div v-if="nodeDescription(node)" class="tl-desc">{{ nodeDescription(node) }}</div>
|
||||
<div v-if="node.system === 'OUTBOUND_RECORD' && outboundRemark" class="tl-remark">
|
||||
<span class="muted">{{ t('timeline.remark') }}</span>
|
||||
{{ outboundRemark }}
|
||||
</div>
|
||||
<template v-if="node.media?.length">
|
||||
<button class="tl-toggle" @click="toggleNode(index)">
|
||||
<span class="tl-toggle-ico" :class="{ open: expanded.has(index) }">▸</span>
|
||||
{{ expanded.has(index) ? t('timeline.collapse') : t('timeline.expandMedia', { n: mediaCount(node) }) }}
|
||||
</button>
|
||||
<div v-if="expanded.has(index)" class="tl-media">
|
||||
<div
|
||||
v-for="(media, mediaIndex) in node.media"
|
||||
:key="media.id || media.url || media.key || mediaIndex"
|
||||
class="tl-media-item"
|
||||
@click="openTraceViewer(node.media, mediaIndex)"
|
||||
>
|
||||
<div class="tl-media-thumb">
|
||||
<video
|
||||
v-if="isTraceVideo(media)"
|
||||
:src="traceMediaUrl(media)"
|
||||
muted
|
||||
playsinline
|
||||
preload="metadata"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
:src="traceMediaUrl(media)"
|
||||
:alt="media.name || nodeTitle(node)"
|
||||
loading="lazy"
|
||||
/>
|
||||
<div v-if="isTraceVideo(media)" class="tl-play">▶</div>
|
||||
</div>
|
||||
<div v-if="media.name" class="tl-cap text-ellipsis">{{ media.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
v-if="node.system === 'OUTBOUND_RECORD' && expanded.has(index) && canLoadMore"
|
||||
type="button"
|
||||
class="tl-load-more"
|
||||
:disabled="loadingMore"
|
||||
@click="$emit('load-more')"
|
||||
>
|
||||
{{ loadingMore ? t('timeline.loadingMedia') : t('timeline.loadMoreMedia') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
isTraceVideo,
|
||||
openTraceViewer,
|
||||
traceMediaUrl,
|
||||
type PublicMediaItem,
|
||||
} from './media';
|
||||
|
||||
interface TimelineNode {
|
||||
nodeType?: string;
|
||||
system?: string | null;
|
||||
title?: string | null;
|
||||
occurredAt?: string | null;
|
||||
location?: string | null;
|
||||
description?: string | null;
|
||||
media?: Array<PublicMediaItem & { id?: string | number }>;
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
title: string;
|
||||
items: TimelineNode[];
|
||||
outboundRemark?: string;
|
||||
outboundImagesTotal?: number;
|
||||
canLoadMore?: boolean;
|
||||
loadingMore?: boolean;
|
||||
}>(),
|
||||
{
|
||||
outboundRemark: '',
|
||||
outboundImagesTotal: 0,
|
||||
canLoadMore: false,
|
||||
loadingMore: false,
|
||||
},
|
||||
);
|
||||
defineEmits<{ (event: 'load-more'): void }>();
|
||||
const { t } = useI18n();
|
||||
const expanded = ref<Set<number>>(new Set());
|
||||
|
||||
function toggleNode(index: number) {
|
||||
const next = new Set(expanded.value);
|
||||
next.has(index) ? next.delete(index) : next.add(index);
|
||||
expanded.value = next;
|
||||
}
|
||||
|
||||
function mediaCount(node: TimelineNode) {
|
||||
return node.system === 'OUTBOUND_RECORD' ? props.outboundImagesTotal : node.media?.length || 0;
|
||||
}
|
||||
|
||||
function nodeTitle(node: TimelineNode) {
|
||||
return node.system === 'OUTBOUND_RECORD' ? t('timeline.outboundTitle') : node.title || '';
|
||||
}
|
||||
|
||||
function nodeDescription(node: TimelineNode) {
|
||||
return node.system === 'OUTBOUND_RECORD' ? t('timeline.outboundDesc') : node.description || '';
|
||||
}
|
||||
|
||||
function nodeOccurredAt(node: TimelineNode) {
|
||||
if (!node.occurredAt) return '';
|
||||
return dayjs(node.occurredAt).format(
|
||||
node.system === 'OUTBOUND_RECORD' ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD',
|
||||
);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.items,
|
||||
() => {
|
||||
expanded.value = new Set();
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.text-ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.timeline {
|
||||
position: relative;
|
||||
}
|
||||
.tl-item {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
position: relative;
|
||||
}
|
||||
.tl-item:not(:last-child) .tl-body {
|
||||
border-left: 2px solid var(--trace-line);
|
||||
margin-left: 5px;
|
||||
padding-left: 18px;
|
||||
padding-bottom: 18px;
|
||||
}
|
||||
.tl-item:last-child .tl-body {
|
||||
margin-left: 5px;
|
||||
padding-left: 18px;
|
||||
}
|
||||
.tl-dot {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
background: var(--trace-accent);
|
||||
margin-top: 4px;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
.tl-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
.tl-meta {
|
||||
font-size: 12px;
|
||||
margin: 2px 0;
|
||||
}
|
||||
.tl-desc {
|
||||
font-size: 13px;
|
||||
color: var(--trace-desc);
|
||||
}
|
||||
.tl-remark {
|
||||
margin-top: 5px;
|
||||
font-size: 13px;
|
||||
color: var(--trace-desc);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
.tl-toggle {
|
||||
margin-top: 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--trace-control-bg);
|
||||
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: 10px;
|
||||
margin-top: 10px;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.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: var(--trace-thumb-bg);
|
||||
}
|
||||
.tl-media-thumb img,
|
||||
.tl-media-thumb video {
|
||||
width: 100%;
|
||||
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;
|
||||
}
|
||||
.tl-load-more {
|
||||
min-width: 124px;
|
||||
margin-top: 8px;
|
||||
padding: 7px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--card-bg);
|
||||
color: var(--brand-2);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.tl-load-more:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.65;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,31 @@
|
||||
import { openMediaViewer } from '@/composables/openMediaViewer';
|
||||
import { resolveMediaUrl } from '@/utils/mediaUrl';
|
||||
|
||||
export interface PublicMediaItem {
|
||||
url?: string | null;
|
||||
key?: string | null;
|
||||
name?: string;
|
||||
type?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export function traceMediaUrl(value?: string | PublicMediaItem | null): string {
|
||||
if (typeof value === 'string') return resolveMediaUrl(value);
|
||||
return resolveMediaUrl(value?.url || value?.key);
|
||||
}
|
||||
|
||||
export function isTraceVideo(media: PublicMediaItem): boolean {
|
||||
return media.type === 'video' || /\.(mp4|webm|mov|m4v|ogg)$/i.test(traceMediaUrl(media));
|
||||
}
|
||||
|
||||
export function openTraceViewer(items: PublicMediaItem[], index: number): void {
|
||||
const normalized = items
|
||||
.map((item) => ({ ...item, url: traceMediaUrl(item) }))
|
||||
.filter((item) => Boolean(item.url));
|
||||
void openMediaViewer(normalized, Math.max(0, Math.min(index, normalized.length - 1)));
|
||||
}
|
||||
|
||||
export function safeTraceUrl(value?: string): string {
|
||||
const url = traceMediaUrl(value);
|
||||
return /^(https?:\/\/|\/)/i.test(url) ? url : '';
|
||||
}
|
||||
@@ -11,11 +11,14 @@
|
||||
"queriedAt": "This query: {t}"
|
||||
},
|
||||
"section": {
|
||||
"authenticity": "Authenticity Status",
|
||||
"basic": "Product Introduction",
|
||||
"showcase": "Artwork Showcase",
|
||||
"timeline": "Provenance Timeline",
|
||||
"cert": "Copyright Certificates",
|
||||
"chain": "Digital Identity & Blockchain"
|
||||
"chain": "Digital Identity & Blockchain",
|
||||
"imageText": "Image & Text",
|
||||
"horizontalGallery": "Gallery"
|
||||
},
|
||||
"timeline": {
|
||||
"expandMedia": "View images ({n})",
|
||||
@@ -56,13 +59,6 @@
|
||||
"copied": "Copied",
|
||||
"notOnchain": "This artwork has not been recorded on-chain yet."
|
||||
},
|
||||
"cert": {
|
||||
"type": {
|
||||
"PHOTO": "Photo with Author",
|
||||
"CERT": "Copyright Certificate",
|
||||
"APPRAISAL": "Appraisal"
|
||||
}
|
||||
},
|
||||
"field": {
|
||||
"viewFile": "View file"
|
||||
},
|
||||
|
||||
@@ -11,11 +11,14 @@
|
||||
"queriedAt": "本次查询:{t}"
|
||||
},
|
||||
"section": {
|
||||
"authenticity": "防伪状态",
|
||||
"basic": "产品介绍",
|
||||
"showcase": "作品展示",
|
||||
"timeline": "溯源时间轴",
|
||||
"cert": "版权证书",
|
||||
"chain": "数字身份与区块链存证"
|
||||
"chain": "数字身份与区块链存证",
|
||||
"imageText": "图文内容",
|
||||
"horizontalGallery": "精彩图片"
|
||||
},
|
||||
"timeline": {
|
||||
"expandMedia": "查看图片({n})",
|
||||
@@ -56,13 +59,6 @@
|
||||
"copied": "已复制",
|
||||
"notOnchain": "该作品暂未上链存证。"
|
||||
},
|
||||
"cert": {
|
||||
"type": {
|
||||
"PHOTO": "作者合照",
|
||||
"CERT": "版权证书",
|
||||
"APPRAISAL": "鉴定意见"
|
||||
}
|
||||
},
|
||||
"field": {
|
||||
"viewFile": "查看文件"
|
||||
},
|
||||
|
||||
+26
-1156
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
'@artveris/shared': fileURLToPath(new URL('../../packages/shared/src/index.ts', import.meta.url)),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user