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