feat: 证书页底部补上天河链字段说明和下载按钮

This commit is contained in:
Nixevol
2026-11-15 13:44:54 +08:00
parent 697d7faebe
commit ab8f02d916
4 changed files with 68 additions and 11 deletions
+5 -1
View File
@@ -99,7 +99,11 @@
"certificateDigest": "Digest",
"certificateAuthor": "Author",
"certificateTime": "Created",
"certificateDownload": "Download certificate"
"certificateDownload": "Download certificate",
"certificateChainId": "TiChain block ID",
"certificateChainIdTip": "This is the block transaction ID generated when the evidence was recorded. It can be used to look up the file hash on TiChain.",
"certificateDigestTitle": "SHA256 digest",
"certificateDigestTip": "This is the SHA256 hash of the original evidence. It matches that file only, and has been written to TiChain so the file cannot be altered."
},
"field": {
"viewFile": "View file"
+5 -1
View File
@@ -99,7 +99,11 @@
"certificateDigest": "摘要",
"certificateAuthor": "作者",
"certificateTime": "生成时间",
"certificateDownload": "下载证书"
"certificateDownload": "下载存证证书",
"certificateChainId": "天河链-区块链ID",
"certificateChainIdTip": "该字符串是证据上链过程中生成的区块交易ID值,通过此ID可以在天河链上查询到文件hash的上链信息。",
"certificateDigestTitle": "电子证据SHA256值",
"certificateDigestTip": "该值是通过SHA256算法计算原始证据文件后得出的文件HASH值,与证据文件唯一对应。该HASH值已被实时写入天河链,确保文件的不可篡改。"
},
"field": {
"viewFile": "查看文件"
+57 -8
View File
@@ -3,9 +3,6 @@
<header class="subpage-bar">
<button type="button" class="subpage-back" @click="back">{{ t('chain.txBack') }}</button>
<h1>{{ t('chain.certificateView') }}</h1>
<button v-if="certificateRecord" type="button" class="subpage-action" @click="certificateSheet?.download()">
{{ t('chain.certificateDownload') }}
</button>
</header>
<div class="subpage-body">
<p v-if="preview" class="subpage-note">{{ t('chain.certificatePreview') }}</p>
@@ -14,11 +11,32 @@
<button v-if="certificateError && retryable" type="button" class="subpage-action" @click="load">
{{ t('chain.certificateCheckAgain') }}
</button>
<div v-else-if="certificateRecord" ref="stage" class="cert-stage" :style="{ height: `${720 * scale}px` }">
<div class="cert-fit" :style="{ transform: `scale(${scale})` }">
<trace-certificate-sheet ref="certificateSheet" :record="certificateRecord" />
<template v-else-if="certificateRecord">
<div ref="stage" class="cert-stage" :style="{ height: `${720 * scale}px` }">
<div class="cert-fit" :style="{ transform: `scale(${scale})` }">
<trace-certificate-sheet ref="certificateSheet" :record="certificateRecord" />
</div>
</div>
</div>
<section class="prove-des">
<h2 class="des-title">
{{ t('chain.certificateChainId') }}
<button type="button" class="des-tip" :aria-label="t('chain.certificateChainId')" @click.stop="toggleTip('tx')">
<TipIcon />
<span class="des-pop" :class="{ open: tip === 'tx' }" role="tooltip">{{ t('chain.certificateChainIdTip') }}</span>
</button>
</h2>
<p class="des-hash">{{ certificateRecord.txHash }}</p>
<h2 class="des-title">
{{ t('chain.certificateDigestTitle') }}
<button type="button" class="des-tip" :aria-label="t('chain.certificateDigestTitle')" @click.stop="toggleTip('digest')">
<TipIcon />
<span class="des-pop" :class="{ open: tip === 'digest' }" role="tooltip">{{ t('chain.certificateDigestTip') }}</span>
</button>
</h2>
<p class="des-digest">{{ certificateRecord.digest }}</p>
<button type="button" class="des-download" @click="certificateSheet?.download()">{{ t('chain.certificateDownload') }}</button>
</section>
</template>
<div v-else class="subpage-wait">
<div class="certificate-spinner" aria-hidden="true" />
<ol class="certificate-steps">
@@ -33,12 +51,21 @@
</template>
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
import { defineComponent, h, nextTick, onMounted, onUnmounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { fetchTraceCertificate, requestTraceCertificate, type TraceCertificateRecord, type TraceCertificateResult } from '@/api';
import TraceCertificateSheet from '@/components/trace/TraceCertificateSheet.vue';
const TipIcon = defineComponent({
name: 'TipIcon',
setup() {
return () => h('svg', { viewBox: '0 0 1024 1024', width: 14, height: 14, 'aria-hidden': 'true' }, [
h('path', { fill: 'currentColor', d: 'M512 64a448 448 0 1 0 0 896 448 448 0 0 0 0-896zm0 820.48A372.48 372.48 0 1 1 512 139.52a372.48 372.48 0 0 1 0 744.96zM480 304h64v320h-64zm0 384h64v64h-64z' }),
]);
},
});
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
@@ -52,6 +79,7 @@ const retryable = ref(true);
const certificateSteps = ['chain.certificateRetrieving', 'chain.certificateAcquiring', 'chain.certificatePreparing'];
const stage = ref<HTMLElement>();
const scale = ref(1);
const tip = ref('');
let certificateTimer: ReturnType<typeof setTimeout> | undefined;
let certificateRun = 0;
let certificatePolls = 0;
@@ -106,6 +134,10 @@ async function load() {
if (run === certificateRun) failCertificate('chain.certificateRequestFailed');
}
}
function toggleTip(name: string) {
if (window.matchMedia('(hover: hover) and (pointer: fine)').matches) return;
tip.value = tip.value === name ? '' : name;
}
function measure() {
const width = stage.value?.clientWidth || 0;
scale.value = width > 0 ? Math.min(1, width / 508) : 1;
@@ -129,6 +161,23 @@ onUnmounted(() => {
.subpage-bar { flex-wrap: wrap; }
.subpage-back, .subpage-action { border: 0; background: transparent; color: var(--brand-2); font: inherit; font-size: 14px; cursor: pointer; padding: 6px 0; }
.subpage-action { background: var(--brand); color: #fff; border-radius: 6px; padding: 8px 12px; }
.prove-des { margin-top: 20px; text-align: left; color: #333; }
.des-title { display: flex; align-items: center; margin: 20px 0 12px; padding: 0 8px; border-left: 3px solid #2977f0; font-family: PingFang-SC-Bold, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 14px; font-weight: 700; line-height: 20px; color: #333; letter-spacing: 0.14px; }
.des-title:first-child { margin-top: 0; }
.des-tip { position: relative; display: inline-flex; margin-left: 4px; padding: 0; border: 0; background: transparent; color: #333; cursor: pointer; }
.des-pop { display: none; position: absolute; left: calc(100% + 8px); top: 50%; z-index: 6; width: 200px; transform: translateY(-50%); box-sizing: border-box; padding: 12px; border: 1px solid #ebeef5; border-radius: 4px; background: #fff; color: #606266; font-family: PingFangSC-Regular, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 14px; font-weight: 400; line-height: 1.4; letter-spacing: 0; text-align: left; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); }
.des-pop.open { display: block; }
@media (hover: hover) and (pointer: fine) {
.des-tip:hover .des-pop, .des-tip:focus-visible .des-pop { display: block; }
}
.des-hash, .des-digest { margin: 0 0 20px; font-family: PingFangSC-Regular, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 14px; font-weight: 400; line-height: normal; letter-spacing: 0.14px; text-align: left; word-break: break-all; }
.des-hash { margin-bottom: 0; color: #2977f0; }
.des-digest { color: #666; word-break: break-word; }
.des-download { min-width: 112px; height: 36px; padding: 6px 16px; border: 1px solid #2977f0; border-radius: 4px; background: #fff; color: #2977f0; font-family: PingFangSC-Regular, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 14px; font-weight: 500; line-height: 14px; cursor: pointer; }
.des-download:hover { background: rgba(41, 119, 240, 0.06); }
@media (max-width: 420px) {
.des-pop { left: 0; top: calc(100% + 6px); transform: none; }
}
.subpage-body { padding: 12px 12px 28px; }
.subpage-note { margin: 12px 0; font-size: 14px; line-height: 1.6; }
.cert-stage { position: relative; width: 100%; margin: 0 auto; }
+1 -1
View File
@@ -8,7 +8,7 @@
扫码页区块链模块底部左侧为“查看存证”、右侧靠右为“查看证书”,均不显示箭头。仅明确 ONCHAIN 且有交易哈希的天河链实物显示证书按钮,未上链或处理中均不显示。仅已激活、正常、已审核通过的实物可申请。普通页面打开、刷新与证书状态 GET 都不会提交存证;后台预览模式按钮禁用,不产生付费副作用。
「查看存证」和「查看证书」都进入本平台独立页面,不使用弹窗,手机上按屏幕宽度缩放,证书内部排版不改。证书页文案依次为“正在调取存证数据”“获取存证证书”“正在整理存证证书”。先读取已保存的证书字段,没有时才 POST 申请并轮询状态;证书按天河链证书页的版式在浏览器中绘制,下载也由浏览器生成 PNG。之后只读本地。交易详情里的 Gas、发送方和日志在第一次查到前留空,查全后写入本地,之后不再请求天河链。离开页面只停止当前等待,后台已提交任务继续完成。再次进入直接读取数据库已有记录,不重复生成。公开接口不返回天河链网址,客户页面也不能跳转到天河链。
「查看存证」和「查看证书」都进入本平台独立页面,不使用弹窗,手机上按屏幕宽度缩放,证书内部排版不改。证书页底部按天河链说明区展示区块链 ID、SHA256 和下载按钮,说明用悬停提示;哈希只显示文字,不跳转到天河链。证书页文案依次为“正在调取存证数据”“获取存证证书”“正在整理存证证书”。先读取已保存的证书字段,没有时才 POST 申请并轮询状态;证书按天河链证书页的版式在浏览器中绘制,下载也由浏览器生成 PNG。之后只读本地。交易详情里的 Gas、发送方和日志在第一次查到前留空,查全后写入本地,之后不再请求天河链。离开页面只停止当前等待,后台已提交任务继续完成。再次进入直接读取数据库已有记录,不重复生成。公开接口不返回天河链网址,客户页面也不能跳转到天河链。
新证书首次点击时按系统设置 `certificateTextTemplate` 渲染并冻结正文,默认 `{{作品名称}} {{版本}}`,例如“十二生肖莲花手工杯 一个装”。设置入口为“系统设置 → 区块链 → 证书文本模板”,帮助按钮点击后才弹出字段说明。支持 `{{作品名称}}`、`{{版本}}`、`{{追溯码}}`、`{{档案编号}}`、`{{作者}}`,可自由排序、重复使用并插入普通文本或换行。版本按作品模板中显示名为“版本”的字段取值,当前数据键为 `size`,不能硬编码成 `version`。