From 2955efb27839dd066210e4685648a00e51adcbd8 Mon Sep 17 00:00:00 2001 From: Nixevol Date: Sun, 15 Nov 2026 12:15:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=A2=E6=88=B7=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=AB=99=E5=86=85=E6=9F=A5=E7=9C=8B=E5=AD=98?= =?UTF-8?q?=E8=AF=81=E5=92=8C=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../deposit-certificate.service.spec.ts | 11 +- .../blockchain/deposit-certificate.service.ts | 11 +- .../src/blockchain/deposit.provider.spec.ts | 12 +- apps/api/src/blockchain/deposit.provider.ts | 20 +++ .../public-trace/public-trace.service.spec.ts | 3 +- .../src/public-trace/public-trace.service.ts | 25 +--- apps/client/src/api.ts | 9 +- .../trace/TraceBlockchainModule.vue | 116 ++++++++++++++---- apps/client/src/components/trace/media.ts | 9 +- apps/client/src/locales/en-US.json | 11 +- apps/client/src/locales/zh-CN.json | 11 +- apps/client/src/utils/certificateImage.ts | 73 +++++++++++ docs/天河链集成说明.md | 2 +- docs/消费者按需存证证书.md | 8 +- docs/项目交接文档.md | 2 +- 15 files changed, 253 insertions(+), 70 deletions(-) create mode 100644 apps/client/src/utils/certificateImage.ts diff --git a/apps/api/src/blockchain/deposit-certificate.service.spec.ts b/apps/api/src/blockchain/deposit-certificate.service.spec.ts index c02acea..09a59a9 100644 --- a/apps/api/src/blockchain/deposit-certificate.service.spec.ts +++ b/apps/api/src/blockchain/deposit-certificate.service.spec.ts @@ -26,15 +26,20 @@ describe('Consumer certificate lifecycle', () => { afterEach(() => jest.restoreAllMocks()); it('GET only reads persisted state and never starts a job or calls Tianhe', async () => { const { service, prisma, config } = fixture('NONE'); - expect(await service.status('123456000001')).toMatchObject({ status: 'NONE', url: null }); + expect(await service.status('123456000001')).toMatchObject({ status: 'NONE', certificate: null }); expect(prisma.blockchainProof.updateMany).not.toHaveBeenCalled(); expect(prisma.$transaction).not.toHaveBeenCalled(); expect(config.getAllRaw).not.toHaveBeenCalled(); }); it('returns an existing shared certificate without consulting credentials or submitting', async () => { const { service, row, config } = fixture('READY'); - row.certificateUrl = 'https://test.tichain.tianhecloud.com/#/certificate?address=' + settings.tianheWalletAddress + '&txHash=0x' + 'a'.repeat(64) + '&digest=' + 'b'.repeat(64); - expect(await service.request('123456000001')).toMatchObject({ status: 'READY', url: row.certificateUrl }); + row.certificateUrl = 'https://test.tichain.tianhecloud.com/#/certificate?address=' + settings.tianheWalletAddress + '&txHash=0x' + 'a'.repeat(64) + '&digest=' + 'b'.repeat(64) + '&createTime=1789844077000'; + const result = await service.request('123456000001'); + expect(result).toMatchObject({ + status: 'READY', + certificate: { text: 'frozen-evidence', digest: 'b'.repeat(64), txHash: '0x' + 'a'.repeat(64), author: settings.tianheWalletAddress, createdAt: '2026-09-19T18:54:37.000Z' }, + }); + expect(JSON.stringify(result)).not.toContain('tianhecloud'); expect(config.getAllRaw).not.toHaveBeenCalled(); }); it('does not send when another worker owns the lease', async () => { diff --git a/apps/api/src/blockchain/deposit-certificate.service.ts b/apps/api/src/blockchain/deposit-certificate.service.ts index 9262609..019b56b 100644 --- a/apps/api/src/blockchain/deposit-certificate.service.ts +++ b/apps/api/src/blockchain/deposit-certificate.service.ts @@ -6,7 +6,7 @@ import { DEFAULT_CERTIFICATE_TEXT_TEMPLATE, ErrorCode, renderCertificateText, TR import { BusinessException } from '../common/exceptions/business.exception'; import { PrismaService } from '../prisma/prisma.service'; import { SettingsService } from '../settings/settings.service'; -import { certificateAuthorUrl, DepositEnvironment, DepositProvider, DepositRejected, safeCertificateUrl } from './deposit.provider'; +import { DepositEnvironment, DepositProvider, DepositRejected, presentStoredCertificate } from './deposit.provider'; interface CertificateRequest { version: 1; @@ -43,12 +43,13 @@ export class DepositCertificateService { private async view(proof: BlockchainProof, artist?: string | null) { const request = proof.certificateRequest as unknown as CertificateRequest | null; - const url = request && proof.certificateState === 'READY' - ? safeCertificateUrl(proof.certificateUrl, request.environment, request.address) : null; + const certificate = request && proof.certificateState === 'READY' + ? presentStoredCertificate(proof.certificateUrl, request.environment, request.address, request.text, await this.settings.get('certificateAuthorMode'), artist) + : null; return { - status: proof.certificateState === 'READY' && !url ? 'FAILED' : proof.certificateState, - url: url ? certificateAuthorUrl(url, await this.settings.get('certificateAuthorMode'), artist) : null, + status: proof.certificateState === 'READY' && !certificate ? 'FAILED' : proof.certificateState, generatedAt: proof.certificateGeneratedAt, + certificate, }; } diff --git a/apps/api/src/blockchain/deposit.provider.spec.ts b/apps/api/src/blockchain/deposit.provider.spec.ts index e1159c9..86080aa 100644 --- a/apps/api/src/blockchain/deposit.provider.spec.ts +++ b/apps/api/src/blockchain/deposit.provider.spec.ts @@ -1,4 +1,4 @@ -import { certificateAuthorUrl, depositSignature, DepositProvider, DepositRejected, safeCertificateUrl } from './deposit.provider'; +import { certificateAuthorUrl, depositSignature, DepositProvider, DepositRejected, presentStoredCertificate, safeCertificateUrl } from './deposit.provider'; import { createHash } from 'crypto'; describe('V3 deposit protocol', () => { @@ -28,6 +28,16 @@ describe('V3 deposit protocol', () => { } expect(safeCertificateUrl('https://test.tichain.tianhecloud.com/' + suffix, 'test', 'wrong')).toBeNull(); }); + it('presents stored certificate fields without the Tianhe page address', () => { + const address = '0x' + 'a'.repeat(40); + const txHash = '0x' + 'c'.repeat(64); + const digest = 'd'.repeat(64); + const stored = `https://tichain.tianhecloud.com/#/certificate?address=${address}&txHash=${txHash}&digest=${digest}&createTime=1789867663000`; + const view = presentStoredCertificate(stored, 'production', address, '十二生肖莲花手工杯', 'ARTWORK_ARTIST', '黄志伟'); + expect(view).toEqual({ text: '十二生肖莲花手工杯', digest, txHash, author: '黄志伟', createdAt: '2026-09-20T01:27:43.000Z' }); + expect(JSON.stringify(view)).not.toContain('tianhecloud'); + expect(presentStoredCertificate(stored, 'production', address, '十二生肖莲花手工杯', 'WALLET', '黄志伟')?.author).toBe(address); + }); it('uses signed headers, does not expose keys in URL/body and rejects ambiguous acceptance', async () => { const fetcher = jest.spyOn(global, 'fetch').mockResolvedValue({ ok: true, json: async () => ({ code: 200, success: true, data: 'different-id' }) } as any); await expect(new DepositProvider('test', 'app', 'secret').submit('address', 'op', '证据')) diff --git a/apps/api/src/blockchain/deposit.provider.ts b/apps/api/src/blockchain/deposit.provider.ts index 05d5a0d..543abea 100644 --- a/apps/api/src/blockchain/deposit.provider.ts +++ b/apps/api/src/blockchain/deposit.provider.ts @@ -14,6 +14,26 @@ export function depositSignature(path: string, query: Record, b return createHash('sha256').update(json + timestamp + key, 'utf8').digest('hex'); } +export interface StoredCertificateView { + text: string; + digest: string; + txHash: string; + author: string; + createdAt: string | null; +} + +/** 公开页面只接收存证字段。天河链证书网址留在服务端,不进入浏览器。 */ +export function presentStoredCertificate(value: unknown, environment: DepositEnvironment, address: string, text: string, mode: string | null, artist?: string | null): StoredCertificateView | null { + if (!safeCertificateUrl(value, environment, address) || !text.trim()) return null; + const params = new URLSearchParams(new URL(String(value)).hash.slice('#/certificate?'.length)); + const digest = params.get('digest') || ''; + const txHash = params.get('txHash') || ''; + const rawTime = params.get('createTime'); + const created = rawTime && /^\d+$/.test(rawTime) ? new Date(Number(rawTime)) : null; + const author = mode === 'ARTWORK_ARTIST' && artist?.trim() ? artist.trim() : address; + return { text, digest, txHash, author, createdAt: created && !Number.isNaN(created.getTime()) ? created.toISOString() : null }; +} + export function safeCertificateUrl(value: unknown, environment: DepositEnvironment, address?: string): string | null { if (typeof value !== 'string') return null; try { diff --git a/apps/api/src/public-trace/public-trace.service.spec.ts b/apps/api/src/public-trace/public-trace.service.spec.ts index 0c17749..008b67a 100644 --- a/apps/api/src/public-trace/public-trace.service.spec.ts +++ b/apps/api/src/public-trace/public-trace.service.spec.ts @@ -96,8 +96,7 @@ function createHarness(options: { set: jest.fn().mockResolvedValue('OK'), }; const storage = { getUrl: jest.fn((key: string) => `/uploads/${key}`) }; - const settings = { getAllRaw: jest.fn().mockResolvedValue({}) }; - const service = new PublicTraceService(prisma as any, storage as any, settings as any, redis as any); + const service = new PublicTraceService(prisma as any, storage as any, redis as any); return { service, prisma }; } diff --git a/apps/api/src/public-trace/public-trace.service.ts b/apps/api/src/public-trace/public-trace.service.ts index 66454d5..83886c4 100644 --- a/apps/api/src/public-trace/public-trace.service.ts +++ b/apps/api/src/public-trace/public-trace.service.ts @@ -15,10 +15,8 @@ import { } from '@artveris/shared'; import { PrismaService } from '../prisma/prisma.service'; import { StorageService } from '../storage/storage.service'; -import { SettingsService } from '../settings/settings.service'; import { REDIS_CLIENT } from '../redis/redis.module'; import { parseUserAgent } from '../common/utils/ua.util'; -import { buildTianheExplorerTxUrl } from '../blockchain/tianhe.provider'; type TraceCodeWithRel = Prisma.TraceCodeGetPayload<{ include: { batch: true; artwork: true } }>; type ArtworkWithRel = Prisma.ArtworkGetPayload<{ @@ -45,7 +43,6 @@ export class PublicTraceService { constructor( private readonly prisma: PrismaService, private readonly storage: StorageService, - private readonly settings: SettingsService, @Inject(REDIS_CLIENT) private readonly redis: Redis, ) {} @@ -271,8 +268,6 @@ export class PublicTraceService { const result = firstActivate ? QueryResult.FIRST_ACTIVATE : QueryResult.REPEAT; await this.writeLog(id, artwork.id, shortCode, result, ctx, { ...code, ...updated }); - const explorerUrl = await this.resolveExplorerUrl(proof); - return { status: 'OK' as const, queriedAt: now, @@ -281,7 +276,7 @@ export class PublicTraceService { queryCount: updated.queryCount, firstActivatedAt: updated.firstActivatedAt, }, - ...this.buildArtworkPayload(artwork, code, proof, explorerUrl), + ...this.buildArtworkPayload(artwork, code, proof), }; } @@ -329,7 +324,6 @@ export class PublicTraceService { const now = new Date(); const firstQuery = state === 'inactive'; - const explorerUrl = await this.resolveExplorerUrl(proof); return { status: 'OK' as const, preview: true, @@ -341,7 +335,7 @@ export class PublicTraceService { queryCount: code.queryCount > 0 ? code.queryCount : 2, firstActivatedAt: code.firstActivatedAt ?? now, }, - ...this.buildArtworkPayload(artwork, code, proof, explorerUrl), + ...this.buildArtworkPayload(artwork, code, proof), }; } @@ -362,13 +356,11 @@ export class PublicTraceService { blockHeight: bigint | null; chainName: string | null; onchainAt: Date | null; - explorerUrl: string | null; contractAddress: string | null; status: string; failureReason: string | null; submittedAt: Date | null; } | null, - explorerUrl: string | null, ) { return { artwork: { @@ -414,7 +406,6 @@ export class PublicTraceService { blockHeight: proof.blockHeight, chainName: proof.chainName, onchainAt: proof.onchainAt, - explorerUrl, contractAddress: proof.contractAddress, submittedAt: proof.submittedAt, failureReason: this.publicFailureReason(proof.status, proof.failureReason), @@ -471,18 +462,6 @@ export class PublicTraceService { }; } - private async resolveExplorerUrl( - proof: { txHash: string | null; chainName: string | null; explorerUrl: string | null } | null, - ): Promise { - const tianheProof = - proof?.chainName === '天河链' || - /tianhe|tichain/i.test(proof?.chainName || '') || - /tianhecloud\.com/i.test(proof?.explorerUrl || ''); - if (!proof?.txHash || !tianheProof) return proof?.explorerUrl ?? null; - const settings = await this.settings.getAllRaw(); - return buildTianheExplorerTxUrl(settings.tianheBaseUrl || '', proof.txHash, settings.tianheEnv); - } - private buildFields( fields: Array<{ fieldKey: string; label: string; type: string }>, dynamic: unknown, diff --git a/apps/client/src/api.ts b/apps/client/src/api.ts index 1c4ed2c..ce171e2 100644 --- a/apps/client/src/api.ts +++ b/apps/client/src/api.ts @@ -44,10 +44,17 @@ export function fetchAppInfo(): Promise { return instance.get('/settings/public') as unknown as Promise; } +export interface TraceCertificateRecord { + text: string; + digest: string; + txHash: string; + author: string; + createdAt: string | null; +} export interface TraceCertificateResult { status: 'NONE' | 'PENDING' | 'SUBMITTING' | 'CHECKING' | 'WAITING' | 'READY' | 'UNKNOWN' | 'FAILED'; - url: string | null; generatedAt: string | null; + certificate: TraceCertificateRecord | null; } export function requestTraceCertificate(shortCode: string): Promise { return instance.post(`/public/trace/${encodeURIComponent(shortCode)}/certificate`, {}) as unknown as Promise; diff --git a/apps/client/src/components/trace/TraceBlockchainModule.vue b/apps/client/src/components/trace/TraceBlockchainModule.vue index 2c2c5b3..4a56d6c 100644 --- a/apps/client/src/components/trace/TraceBlockchainModule.vue +++ b/apps/client/src/components/trace/TraceBlockchainModule.vue @@ -58,15 +58,7 @@ {{ formatTime(blockchain.onchainAt) }}
- - {{ t('chain.explorer') }} - + @@ -76,29 +68,54 @@
{{ t('chain.notOnchain') }}
+ + +

{{ t('chain.proofTitle') }}

+
+
+ {{ row.label }} + {{ row.value }} + +
+
+

{{ t('chain.certificateView') }}

-
@@ -301,9 +358,14 @@ function formatTime(value: string) { .chain-link { display: inline-block; margin-top: 10px; + padding: 0; + border: 0; + background: none; color: var(--brand-2); + font: inherit; font-size: 14px; text-decoration: none; + cursor: pointer; } .chain-empty { font-size: 13px; @@ -312,7 +374,13 @@ function formatTime(value: string) { .chain-actions { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; } .certificate-link { margin-left: auto; padding: 0; border: 0; background: none; cursor: pointer; font-family: inherit; } .certificate-link:disabled { opacity: .55; cursor: default; } -.certificate-dialog { width: min(360px, calc(100vw - 40px)); box-sizing: border-box; padding: 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--card-bg); color: var(--text); box-shadow: 0 16px 60px #0003; } +.certificate-dialog { width: min(420px, calc(100vw - 40px)); max-height: min(640px, calc(100vh - 48px)); box-sizing: border-box; padding: 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--card-bg); color: var(--text); box-shadow: 0 16px 60px #0003; } +.certificate-dialog[open] { display: flex; flex-direction: column; } +.sheet-body { overflow: auto; min-height: 0; } +.sheet-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--trace-divider); font-size: 13px; } +.sheet-row span { color: var(--muted); } +.sheet-row strong { font-weight: 500; word-break: break-all; white-space: pre-wrap; } +.dialog-actions { padding-top: 16px; } .certificate-dialog::backdrop { background: #0007; } .certificate-dialog h3 { margin: 0 0 22px; font-size: 18px; } .certificate-close { position: absolute; top: 9px; right: 12px; border: 0; background: transparent; color: var(--muted); font-size: 25px; cursor: pointer; } diff --git a/apps/client/src/components/trace/media.ts b/apps/client/src/components/trace/media.ts index 14d21e9..3a8664e 100644 --- a/apps/client/src/components/trace/media.ts +++ b/apps/client/src/components/trace/media.ts @@ -27,5 +27,12 @@ export function openTraceViewer(items: PublicMediaItem[], index: number): void { export function safeTraceUrl(value?: string): string { const url = traceMediaUrl(value); - return /^(https?:\/\/|\/)/i.test(url) ? url : ''; + if (!/^(https?:\/\/|\/)/i.test(url)) return ''; + if (url.startsWith('/')) return url; + try { + if (/(^|\.)tianhecloud\.com$/i.test(new URL(url).hostname)) return ''; + } catch { + return ''; + } + return url; } diff --git a/apps/client/src/locales/en-US.json b/apps/client/src/locales/en-US.json index 3eae35a..81989d3 100644 --- a/apps/client/src/locales/en-US.json +++ b/apps/client/src/locales/en-US.json @@ -59,6 +59,8 @@ "contract": "Contract", "blockHeight": "Block Height", "onchainAt": "On-chain Time", + "blockHash": "Block Hash", + "proofTitle": "Attestation", "explorer": "View Proof", "copy": "Copy", "copied": "Copied", @@ -71,8 +73,13 @@ "certificateUnavailable": "Unable to check the certificate. Please try again later.", "certificateRetrieving": "Retrieving attestation details", "certificateAcquiring": "Preparing your certificate", - "certificateRedirecting": "Opening your certificate", - "certificateDelayed": "Your certificate is not ready yet. Please try again later." + "certificatePreparing": "Assembling your certificate", + "certificateDelayed": "Your certificate is not ready yet. Please try again later.", + "certificateContent": "Attestation text", + "certificateDigest": "Digest", + "certificateAuthor": "Author", + "certificateTime": "Created", + "certificateDownload": "Download certificate" }, "field": { "viewFile": "View file" diff --git a/apps/client/src/locales/zh-CN.json b/apps/client/src/locales/zh-CN.json index 87cfc1e..ab9ef41 100644 --- a/apps/client/src/locales/zh-CN.json +++ b/apps/client/src/locales/zh-CN.json @@ -59,6 +59,8 @@ "contract": "合约地址", "blockHeight": "区块高度", "onchainAt": "上链时间", + "blockHash": "区块哈希", + "proofTitle": "存证详情", "explorer": "查看存证", "copy": "复制", "copied": "已复制", @@ -71,8 +73,13 @@ "certificateUnavailable": "暂时无法查询证书,请稍后重试。", "certificateRetrieving": "正在调取存证数据", "certificateAcquiring": "获取存证证书", - "certificateRedirecting": "正在打开存证证书", - "certificateDelayed": "证书暂未就绪,请稍后再试。" + "certificatePreparing": "正在整理存证证书", + "certificateDelayed": "证书暂未就绪,请稍后再试。", + "certificateContent": "存证内容", + "certificateDigest": "摘要", + "certificateAuthor": "作者", + "certificateTime": "生成时间", + "certificateDownload": "下载证书" }, "field": { "viewFile": "查看文件" diff --git a/apps/client/src/utils/certificateImage.ts b/apps/client/src/utils/certificateImage.ts new file mode 100644 index 0000000..56d7c52 --- /dev/null +++ b/apps/client/src/utils/certificateImage.ts @@ -0,0 +1,73 @@ +export interface CertificateImageInput { + title: string; + rows: Array<{ label: string; value: string }>; + filename: string; +} + +const FONT = '"Microsoft YaHei", "PingFang SC", sans-serif'; + +function wrap(ctx: CanvasRenderingContext2D, value: string, maxWidth: number): string[] { + const lines: string[] = []; + let line = ''; + for (const char of Array.from(value || '-')) { + const next = line + char; + if (line && ctx.measureText(next).width > maxWidth) { + lines.push(line); + line = char; + } else { + line = next; + } + } + lines.push(line || '-'); + return lines; +} + +export function downloadCertificatePng(input: CertificateImageInput): void { + const width = 750; + const pad = 48; + const maxWidth = width - pad * 2; + const measure = document.createElement('canvas').getContext('2d'); + if (!measure) return; + const lines: Array<{ text: string; font: string; gap: number; color: string }> = []; + measure.font = `bold 28px ${FONT}`; + for (const text of wrap(measure, input.title, maxWidth)) { + lines.push({ text, font: measure.font, gap: 36, color: '#143028' }); + } + for (const row of input.rows) { + measure.font = `bold 14px ${FONT}`; + lines.push({ text: row.label, font: measure.font, gap: 22, color: '#5c6b66' }); + measure.font = `16px ${FONT}`; + const wrapped = wrap(measure, row.value, maxWidth); + wrapped.forEach((text, index) => { + lines.push({ text, font: measure.font, gap: index === wrapped.length - 1 ? 28 : 22, color: '#1c1c1c' }); + }); + } + const height = pad * 2 + lines.reduce((sum, line) => sum + line.gap, 0); + const canvas = document.createElement('canvas'); + canvas.width = width * 2; + canvas.height = height * 2; + const ctx = canvas.getContext('2d'); + if (!ctx) return; + ctx.scale(2, 2); + ctx.fillStyle = '#f7f3ea'; + ctx.fillRect(0, 0, width, height); + ctx.strokeStyle = '#0f766e'; + ctx.lineWidth = 3; + ctx.strokeRect(18, 18, width - 36, height - 36); + let y = pad + 8; + for (const line of lines) { + ctx.font = line.font; + ctx.fillStyle = line.color; + ctx.fillText(line.text, pad, y); + y += line.gap; + } + canvas.toBlob((blob) => { + if (!blob) return; + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.download = input.filename; + link.click(); + URL.revokeObjectURL(url); + }, 'image/png'); +} diff --git a/docs/天河链集成说明.md b/docs/天河链集成说明.md index 8309f92..a499876 100644 --- a/docs/天河链集成说明.md +++ b/docs/天河链集成说明.md @@ -213,7 +213,7 @@ flowchart LR ## 九、C 端与查验 - C 端溯源页区块链卡展示:链名、交易哈希、合约地址、区块高度、上链时间;tokenId 仍由后端保存,当前不对消费者展示; -- 「查看存证」按当前天河环境动态跳转 DApp 浏览器**交易详情页**(`transDetail?hash=`):测试环境使用 `test.explorer.tianhecloud.com`,正式环境使用 `explorer.tianhecloud.com`;链接不沿用数据库中的历史接口 URL; +- 「查看存证」打开站内存证详情,展示已保存的交易哈希、合约地址、区块高度、区块哈希和上链时间。公开溯源接口不返回天河链区块浏览器地址。 - 数据哈希为平台内部计算并保留的结构化内容摘要,不随当前 publish 请求上链,也不是链上交易标识或消费者追溯码,不在 C 端展示。 ## 十、生产上线检查单 diff --git a/docs/消费者按需存证证书.md b/docs/消费者按需存证证书.md index db360dd..8574c95 100644 --- a/docs/消费者按需存证证书.md +++ b/docs/消费者按需存证证书.md @@ -8,15 +8,15 @@ 扫码页区块链模块底部左侧为“查看存证”、右侧靠右为“查看证书”,均不显示箭头。仅明确 ONCHAIN 且有交易哈希的天河链实物显示证书按钮,未上链或处理中均不显示。仅已激活、正常、已审核通过的实物可申请。普通页面打开、刷新与证书状态 GET 都不会提交存证;后台预览模式按钮禁用,不产生付费副作用。 -点击后在当前页面弹出进度窗口,文案依次为“正在调取存证数据”“获取存证证书”“正在打开存证证书”。先读取已保存链接,没有时才 POST 申请并轮询状态;完成后当前页面跳转到官方证书网页,避免新窗口被拦截。弹窗可关闭,关闭只停止当前页面等待,后台已提交任务继续完成。再次点击直接读取数据库已有链接,不重复生成。官方网页提供证书展示及下载,不保存图片到本平台。旧的独立等待页已移除。 +点击后在当前页面弹出进度窗口,文案依次为“正在调取存证数据”“获取存证证书”“正在整理存证证书”。先读取已保存的证书字段,没有时才 POST 申请并轮询状态;完成后在弹窗内展示存证内容、摘要、交易哈希、作者和生成时间,并可下载本平台生成的证书图片。弹窗可关闭,关闭只停止当前页面等待,后台已提交任务继续完成。再次点击直接读取数据库已有记录,不重复生成。公开接口不返回天河链网址,客户页面也不再跳转到天河链。旧的独立等待页已移除。 新证书首次点击时按系统设置 `certificateTextTemplate` 渲染并冻结正文,默认 `{{作品名称}} {{版本}}`,例如“十二生肖莲花手工杯 一个装”。设置入口为“系统设置 → 区块链 → 证书文本模板”,帮助按钮点击后才弹出字段说明。支持 `{{作品名称}}`、`{{版本}}`、`{{追溯码}}`、`{{档案编号}}`、`{{作者}}`,可自由排序、重复使用并插入普通文本或换行。版本按作品模板中显示名为“版本”的字段取值,当前数据键为 `size`,不能硬编码成 `version`。 -模板最多500字符,拒绝未知占位符、错误花括号及表达式;只做纯文本替换,不执行代码、不解析Markdown。缺失字段替换为空,最终文本不能为空或超过2000字符。模板缺省时自动使用默认值,无需迁移数据库。更改模板只影响之后的首次申请,已经排队、提交或完成的证据与链接保持不变,不重新生成。即使同款同版本渲染出相同文本,仍按每件实物分别保存operateId与状态。 +模板最多500字符,拒绝未知占位符、错误花括号及表达式;只做纯文本替换,不执行代码、不解析Markdown。缺失字段替换为空,最终文本不能为空或超过2000字符。模板缺省时自动使用默认值,无需迁移数据库。更改模板只影响之后的首次申请,已经排队、提交或完成的证据保持不变,不重新生成。即使同款同版本渲染出相同文本,仍按每件实物分别保存operateId与状态。 -模板允许真实换行,链接编码为 `%0A`;官方网页样式可能把换行合并为空格,用户已接受该显示限制。证书证明的是本次提交的文本快照,作品后续编辑不自动重生成。证书 V3 哈希和生成时间独立于原 NFT 发行哈希/时间。 +模板允许真实换行。证书证明的是本次提交的文本快照,作品后续编辑不自动重生成。证书 V3 哈希和生成时间独立于原 NFT 发行哈希/时间。 -“证书作者显示”使用单选项:默认 `WALLET`(存证钱包地址),可选 `ARTWORK_ARTIST`(作品作者名称)。官方网页已实测支持独立的 `author` 显示参数;平台保留原始证书链接和 `address`,在返回链接时仅按设置添加或移除 `author`。名称取该实物作品档案的艺术家字段,空值回退钱包地址。此显示设置在已有证书下次打开时也生效,不修改原证据、存证主体、哈希或生成时间,不重新调用天河链接口。它是显示名称,不表示将存证交易签名身份改成艺术家本人。说明集中在帮助按钮弹窗中。 +“证书作者显示”使用单选项:默认 `WALLET`(存证钱包地址),可选 `ARTWORK_ARTIST`(作品作者名称)。名称取该实物作品档案的艺术家字段,空值回退钱包地址。公开接口只返回作者显示名和存证字段,不返回天河链网址。此显示设置在已有证书下次打开时也生效,不修改原证据、存证主体、哈希或生成时间,不重新调用天河链接口。它是显示名称,不表示将存证交易签名身份改成艺术家本人。说明集中在帮助按钮弹窗中。 ## 服务端状态与恢复 diff --git a/docs/项目交接文档.md b/docs/项目交接文档.md index 20ee763..23bd4ea 100644 --- a/docs/项目交接文档.md +++ b/docs/项目交接文档.md @@ -55,7 +55,7 @@ | 计费口径 | 按**每次调用上链接口**计费(非按容量)。"是否每件都上链/只上重点件"是纯运营成本决策,与代码无关 | | 钱包粒度 | **单平台托管钱包**(公证者身份),UserID 固定 `artveris-platform`;每件实物的链上凭据(txHash/tokenId)互相独立,钱包地址不标识物品、不在 C 端展示 | | 已售出标记 | **不需要**在链上做交易账单/已售出标记(甲方原话"不需要") | -| C 端查验入口 | 「查看存证」跳天河区块浏览器**交易详情页** `#/tiChain/transDetail?hash=`(不选藏品详情页,因不传媒体会显示"未获取到媒体内容") | +| C 端查验入口 | 「查看存证」打开站内存证详情;「查看证书」在站内展示并下载。公开接口不返回天河链网址,客户页面不能跳转到天河链。 | ### 3.2 链上身份与密钥安全