feat: 作品页支持模块化编排与自定义内容模块
This commit is contained in:
@@ -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