diff --git a/.gitignore b/.gitignore index 8d2a31a..1c40312 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ AGENT.md # AI 项目记忆已迁移至 MemRelay,本地导出目录不入库 aidocs/ + +# 临时分析文件 +/Temp/ diff --git a/apps/admin/src/components/OnchainProofModal.vue b/apps/admin/src/components/OnchainProofModal.vue index 93e2d68..2433725 100644 --- a/apps/admin/src/components/OnchainProofModal.vue +++ b/apps/admin/src/components/OnchainProofModal.vue @@ -31,12 +31,6 @@ {{ fmt(proof.onchainAt) }} - - - {{ t('pages.blockchain.openExplorer') }} - - - {{ failureReason }} @@ -96,7 +90,7 @@ import { computed, defineComponent, h, ref, watch } from 'vue'; import { useI18n } from 'vue-i18n'; import { NButton, NIcon } from 'naive-ui'; -import { CopyOutline, OpenOutline } from '@vicons/ionicons5'; +import { CopyOutline } from '@vicons/ionicons5'; import { onchainApi, traceCodeApi } from '@/api'; import { useAuthStore } from '@/stores/auth'; import { fmt, statusType } from '@/utils/format'; diff --git a/apps/api/src/blockchain/deposit-certificate.service.spec.ts b/apps/api/src/blockchain/deposit-certificate.service.spec.ts index 09a59a9..6518ba3 100644 --- a/apps/api/src/blockchain/deposit-certificate.service.spec.ts +++ b/apps/api/src/blockchain/deposit-certificate.service.spec.ts @@ -14,6 +14,7 @@ function fixture(state = 'PENDING') { const prisma = { blockchainProof: { updateMany: jest.fn().mockResolvedValue({ count: 1 }), + update: jest.fn().mockResolvedValue(row), findUniqueOrThrow: jest.fn().mockResolvedValue(row), }, traceCode: { findUnique: jest.fn().mockResolvedValue({ shortCode: '123456000001', status: 'ACTIVE', artwork: { title: '测试作品', archiveNo: 'ARTVERIS-000001', status: 'ACTIVE', auditStatus: 'APPROVED' }, proofs: [row] }) }, diff --git a/apps/api/src/blockchain/deposit-certificate.service.ts b/apps/api/src/blockchain/deposit-certificate.service.ts index 019b56b..2509350 100644 --- a/apps/api/src/blockchain/deposit-certificate.service.ts +++ b/apps/api/src/blockchain/deposit-certificate.service.ts @@ -49,7 +49,7 @@ export class DepositCertificateService { return { status: proof.certificateState === 'READY' && !certificate ? 'FAILED' : proof.certificateState, generatedAt: proof.certificateGeneratedAt, - certificate, + certificate: certificate && request ? { ...certificate, environment: request.environment } : certificate, }; } diff --git a/apps/api/src/blockchain/deposit.provider.ts b/apps/api/src/blockchain/deposit.provider.ts index 543abea..1387c82 100644 --- a/apps/api/src/blockchain/deposit.provider.ts +++ b/apps/api/src/blockchain/deposit.provider.ts @@ -20,6 +20,7 @@ export interface StoredCertificateView { txHash: string; author: string; createdAt: string | null; + imageUrl?: string | null; } /** 公开页面只接收存证字段。天河链证书网址留在服务端,不进入浏览器。 */ diff --git a/apps/api/src/public-trace/chain-detail.spec.ts b/apps/api/src/public-trace/chain-detail.spec.ts new file mode 100644 index 0000000..741fa69 --- /dev/null +++ b/apps/api/src/public-trace/chain-detail.spec.ts @@ -0,0 +1,34 @@ +import { parseChainDetail } from './chain-detail'; + +const info = { + data: { + gasTxUsed: '3388899', + fromAddress: '0x85aa7cdeba55cb08427018d066a26719b956ceff', + toAddress: '0x8c7df15858ee7c2f51ce74899a6d097ed163443f', + timeStamp: 1786261526886, + blockHeight: 39944998, + inputDataBin: '0xsecret', + inputDataDetail: { method: 'mint(address to, string author, string productId, string feature, string initPrice)', methodId: '0xa40d1b10' }, + inputInfo: [{ name: 'author', type: 'string', data: '黄志伟' }], + transactionDetail: [{ fromAddress: '0x0000000000000000000000000000000000000000', toAddress: '0xae3ecbac36b5874b0372686e5b88894c22be4296', contractAddress: '0x8c7df15858ee7c2f51ce74899a6d097ed163443f', tokenId: '3051' }], + }, +}; +const receipt = { + data: [{ logInfo: { address: '0x8c7df15858ee7c2f51ce74899a6d097ed163443f', name: 'Transfer(address from, address to, uint256 tokenId)', data: '0x', topics: ['0xabc'] } }], +}; + +describe('parseChainDetail', () => { + it('keeps gas, sender and logs and drops the raw input binary', () => { + const detail = parseChainDetail(info, receipt); + expect(detail?.gasUsed).toBe('3388899'); + expect(detail?.fromAddress).toBe('0x85aa7cdeba55cb08427018d066a26719b956ceff'); + expect(detail?.logs).toHaveLength(1); + expect(detail?.action?.tokenId).toBe('3051'); + expect(JSON.stringify(detail)).not.toContain('secret'); + }); + + it('stays empty when gas, sender or logs are missing', () => { + expect(parseChainDetail({ data: { gasTxUsed: '', fromAddress: info.data.fromAddress } }, receipt)).toBeNull(); + expect(parseChainDetail(info, { data: [] })).toBeNull(); + }); +}); diff --git a/apps/api/src/public-trace/chain-detail.ts b/apps/api/src/public-trace/chain-detail.ts new file mode 100644 index 0000000..aef3c3b --- /dev/null +++ b/apps/api/src/public-trace/chain-detail.ts @@ -0,0 +1,109 @@ +export interface ChainInputField { + name: string; + type: string; + data: string; +} + +export interface ChainLogView { + address: string; + name: string; + data: string; + topics: string[]; +} + +export interface ChainDetail { + gasUsed: string; + fromAddress: string; + toAddress: string; + timeStamp: string | null; + blockHeight: string | null; + method: string; + methodId: string; + inputs: ChainInputField[]; + logs: ChainLogView[]; + action: { fromAddress: string; toAddress: string; contractAddress: string; tokenId: string } | null; +} + +const ADDRESS = /^0x[0-9a-fA-F]{40}$/; + +function text(value: unknown): string { + return typeof value === 'string' ? value.trim() : ''; +} + +export function readStoredChainDetail(raw: unknown): ChainDetail | null { + if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null; + const detail = (raw as { chainDetail?: unknown }).chainDetail; + if (!detail || typeof detail !== 'object' || Array.isArray(detail)) return null; + const row = detail as ChainDetail; + if (!row.gasUsed || !ADDRESS.test(row.fromAddress || '') || !Array.isArray(row.logs) || !row.logs.length) return null; + return row; +} + +export function parseChainDetail(info: unknown, receipt: unknown): ChainDetail | null { + const data = info && typeof info === 'object' ? (info as { data?: unknown }).data : null; + if (!data || typeof data !== 'object') return null; + const row = data as Record; + const gasUsed = text(row.gasTxUsed); + const fromAddress = text(row.fromAddress); + const logs = Array.isArray(receipt && typeof receipt === 'object' ? (receipt as { data?: unknown }).data : null) + ? ((receipt as { data: unknown[] }).data) + .map((item) => (item && typeof item === 'object' ? (item as { logInfo?: unknown }).logInfo : null)) + .filter((item): item is Record => Boolean(item && typeof item === 'object')) + .map((item) => ({ + address: text(item.address), + name: text(item.name), + data: text(item.data) || '0x', + topics: Array.isArray(item.topics) ? item.topics.filter((topic): topic is string => typeof topic === 'string') : [], + })) + .filter((item) => item.address && item.name && item.topics.length) + : []; + if (!gasUsed || !ADDRESS.test(fromAddress) || !logs.length) return null; + const method = row.inputDataDetail && typeof row.inputDataDetail === 'object' + ? row.inputDataDetail as { method?: unknown; methodId?: unknown } + : {}; + const action = Array.isArray(row.transactionDetail) ? row.transactionDetail[0] as Record | undefined : undefined; + return { + gasUsed, + fromAddress, + toAddress: text(row.toAddress), + timeStamp: row.timeStamp == null ? null : String(row.timeStamp), + blockHeight: row.blockHeight == null ? null : String(row.blockHeight), + method: text(method.method), + methodId: text(method.methodId), + inputs: Array.isArray(row.inputInfo) + ? row.inputInfo.filter((item): item is Record => Boolean(item && typeof item === 'object')).map((item) => ({ + name: text(item.name), + type: text(item.type), + data: text(item.data), + })) + : [], + logs, + action: action ? { + fromAddress: text(action.fromAddress), + toAddress: text(action.toAddress), + contractAddress: text(action.contractAddress), + tokenId: text(action.tokenId), + } : null, + }; +} + +export function explorerApiBase(environment: string): string { + const host = environment === 'production' ? 'https://explorer.tianhecloud.com' : 'https://test.explorer.tianhecloud.com'; + return `${host}/api/tichain-browser-new`; +} + +export async function loadChainDetail(environment: string, txHash: string, blockHeight: string | null, getter: (url: string) => Promise = defaultGet): Promise { + const base = explorerApiBase(environment); + const info = await getter(`${base}/transaction/info?txHash=${encodeURIComponent(txHash)}`); + const infoData = info && typeof info === 'object' ? (info as { data?: { blockHeight?: unknown } }).data : null; + const height = blockHeight || (infoData?.blockHeight == null ? '' : String(infoData.blockHeight)); + if (!height) return null; + const receipt = await getter(`${base}/receipt/info?hash=${encodeURIComponent(txHash)}&height=${encodeURIComponent(height)}`); + return parseChainDetail(info, receipt); +} + +async function defaultGet(url: string): Promise { + const response = await fetch(url, { redirect: 'error', signal: AbortSignal.timeout(15_000) }); + if (!response.ok) return null; + return response.json(); +} diff --git a/apps/api/src/public-trace/public-trace.controller.ts b/apps/api/src/public-trace/public-trace.controller.ts index 849a87e..54683bf 100644 --- a/apps/api/src/public-trace/public-trace.controller.ts +++ b/apps/api/src/public-trace/public-trace.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Param, Query, Req, Res } from '@nestjs/common'; +import { Controller, Get, Param, Post, Query, Req, Res } from '@nestjs/common'; import { Request, Response } from 'express'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { Throttle } from '@nestjs/throttler'; @@ -39,6 +39,14 @@ export class PublicTraceController { private readonly config: ConfigService, ) {} + @Public() + @Post('public/trace/:shortCode/chain-detail') + @Throttle({ default: { limit: 10, ttl: 60_000 } }) + @ApiOperation({ summary: '首次补存交易详情;已存档后只读本地' }) + chainDetail(@Param('shortCode') shortCode: string) { + return this.service.captureChainDetail(shortCode); + } + @Public() @Get('public/trace/:shortCode') // 公开溯源软限流:每 IP 每分钟 60 次,抑制脚本刷量污染防伪统计与日志 diff --git a/apps/api/src/public-trace/public-trace.service.ts b/apps/api/src/public-trace/public-trace.service.ts index 1d49773..129f00f 100644 --- a/apps/api/src/public-trace/public-trace.service.ts +++ b/apps/api/src/public-trace/public-trace.service.ts @@ -19,6 +19,7 @@ import { SettingsService } from '../settings/settings.service'; import { REDIS_CLIENT } from '../redis/redis.module'; import { parseUserAgent } from '../common/utils/ua.util'; import { readMintView } from './public-mint-view'; +import { loadChainDetail, readStoredChainDetail } from './chain-detail'; type TraceCodeWithRel = Prisma.TraceCodeGetPayload<{ include: { batch: true; artwork: true } }>; type ArtworkWithRel = Prisma.ArtworkGetPayload<{ @@ -422,6 +423,7 @@ export class PublicTraceService { productId: mint?.productId ?? code.shortCode, feature: mint?.feature ?? null, mintTo: mint?.mintTo ?? null, + chainDetail: readStoredChainDetail(proof.rawResponse), submittedAt: proof.submittedAt, failureReason: this.publicFailureReason(proof.status, proof.failureReason), } @@ -429,6 +431,37 @@ export class PublicTraceService { }; } + private readonly chainDetailJobs = new Map>(); + + async captureChainDetail(shortCode: string) { + const current = this.chainDetailJobs.get(shortCode); + if (current) return current; + const job = this.captureChainDetailOnce(shortCode).finally(() => this.chainDetailJobs.delete(shortCode)); + this.chainDetailJobs.set(shortCode, job); + return job; + } + + private async captureChainDetailOnce(shortCode: string) { + if (!TRACE_CODE_PATTERN.test(shortCode)) return { complete: false, detail: null }; + const code = await this.prisma.traceCode.findUnique({ where: { shortCode }, select: { id: true } }); + if (!code) return { complete: false, detail: null }; + const proof = await this.prisma.blockchainProof.findUnique({ where: { traceCodeId: code.id } }); + const stored = readStoredChainDetail(proof?.rawResponse); + if (stored) return { complete: true, detail: stored }; + if (!proof?.txHash || proof.chainName !== '天河链') return { complete: false, detail: null }; + const environment = await this.settings.get('tianheEnv'); + const detail = await loadChainDetail(environment || 'test', proof.txHash, proof.blockHeight == null ? null : proof.blockHeight.toString()); + if (!detail) return { complete: false, detail: null }; + const current = proof.rawResponse && typeof proof.rawResponse === 'object' && !Array.isArray(proof.rawResponse) + ? proof.rawResponse as Record + : {}; + await this.prisma.blockchainProof.update({ + where: { id: proof.id }, + data: { rawResponse: { ...current, chainDetail: detail } as unknown as Prisma.InputJsonValue }, + }); + return { complete: true, detail }; + } + private async mintRecipient(proof: { chainName: string | null } | null): Promise { if (proof?.chainName !== '天河链') return null; const value = await this.settings.get('tianheWalletAddress'); diff --git a/apps/client/package.json b/apps/client/package.json index 4f7ea92..7877be4 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -14,7 +14,9 @@ "@artveris/shared": "workspace:*", "axios": "^1.7.9", "dayjs": "^1.11.13", + "html2canvas": "^1.4.1", "photoswipe": "^5.4.4", + "qrcode": "^1.5.4", "vue": "^3.5.13", "vue-i18n": "^9.14.2", "vue-router": "^4.5.0" diff --git a/apps/client/src/api.ts b/apps/client/src/api.ts index ce171e2..d4b92f1 100644 --- a/apps/client/src/api.ts +++ b/apps/client/src/api.ts @@ -50,6 +50,28 @@ export interface TraceCertificateRecord { txHash: string; author: string; createdAt: string | null; + environment?: 'test' | 'production'; +} +export interface ChainDetailLog { + address: string; + name: string; + data: string; + topics: string[]; +} +export interface ChainDetail { + gasUsed: string; + fromAddress: string; + toAddress: string; + timeStamp: string | null; + blockHeight: string | null; + method: string; + methodId: string; + inputs: Array<{ name: string; type: string; data: string }>; + logs: ChainDetailLog[]; + action: { fromAddress: string; toAddress: string; contractAddress: string; tokenId: string } | null; +} +export function fetchChainDetail(shortCode: string): Promise<{ complete: boolean; detail: ChainDetail | null }> { + return instance.post(`/public/trace/${encodeURIComponent(shortCode)}/chain-detail`, {}, { timeout: 30_000 }) as unknown as Promise<{ complete: boolean; detail: ChainDetail | null }>; } export interface TraceCertificateResult { status: 'NONE' | 'PENDING' | 'SUBMITTING' | 'CHECKING' | 'WAITING' | 'READY' | 'UNKNOWN' | 'FAILED'; @@ -57,7 +79,7 @@ export interface TraceCertificateResult { certificate: TraceCertificateRecord | null; } export function requestTraceCertificate(shortCode: string): Promise { - return instance.post(`/public/trace/${encodeURIComponent(shortCode)}/certificate`, {}) as unknown as Promise; + return instance.post(`/public/trace/${encodeURIComponent(shortCode)}/certificate`, {}, { timeout: 90_000 }) as unknown as Promise; } export function fetchTraceCertificate(shortCode: string): Promise { return instance.get(`/public/trace/${encodeURIComponent(shortCode)}/certificate`) as unknown as Promise; diff --git a/apps/client/src/assets/certificate/check.png b/apps/client/src/assets/certificate/check.png new file mode 100644 index 0000000..9a232ee Binary files /dev/null and b/apps/client/src/assets/certificate/check.png differ diff --git a/apps/client/src/assets/certificate/logo.png b/apps/client/src/assets/certificate/logo.png new file mode 100644 index 0000000..5e99e57 Binary files /dev/null and b/apps/client/src/assets/certificate/logo.png differ diff --git a/apps/client/src/assets/certificate/prove-bg.png b/apps/client/src/assets/certificate/prove-bg.png new file mode 100644 index 0000000..0ee9790 Binary files /dev/null and b/apps/client/src/assets/certificate/prove-bg.png differ diff --git a/apps/client/src/assets/certificate/qr-logo.png b/apps/client/src/assets/certificate/qr-logo.png new file mode 100644 index 0000000..b208434 Binary files /dev/null and b/apps/client/src/assets/certificate/qr-logo.png differ diff --git a/apps/client/src/components/trace/TraceBlockchainModule.vue b/apps/client/src/components/trace/TraceBlockchainModule.vue index b164393..53af371 100644 --- a/apps/client/src/components/trace/TraceBlockchainModule.vue +++ b/apps/client/src/components/trace/TraceBlockchainModule.vue @@ -58,8 +58,8 @@ {{ formatTime(blockchain.onchainAt) }} - {{ t('chain.explorer') }} - + {{ t('chain.explorer') }} + {{ t('chain.certificateView') }} @@ -67,56 +67,12 @@ {{ t('chain.notOnchain') }} - - - {{ t('chain.proofTitle') }} - $emit('copy', value)" - @close="closeProof" - /> - - - × - {{ t('chain.certificateView') }} - - - {{ certificateError }} - - - {{ row.label }} - {{ row.value }} - - - - - {{ certificatePhase > index ? '✓' : index + 1 }}{{ t(key) }} - - - - - {{ t('chain.certificateDownload') }} - {{ t('chain.certificateCheckAgain') }} - - - diff --git a/apps/client/src/components/trace/TraceTxDetail.vue b/apps/client/src/components/trace/TraceTxDetail.vue index b815db9..fbcca3e 100644 --- a/apps/client/src/components/trace/TraceTxDetail.vue +++ b/apps/client/src/components/trace/TraceTxDetail.vue @@ -1,7 +1,7 @@ - {{ t('chain.txTitle') }} + {{ t('chain.txTitle') }} {{ txHash || '-' }} @@ -27,11 +27,24 @@ {{ statusText }} - + {{ t('chain.blockHeight') }} - {{ blockHeight }} - + {{ shownBlock }} + + + + + + + {{ t('chain.txGas') }} + {{ detail?.gasUsed || '' }} + + + {{ t('chain.txSender') }} + + {{ detail?.fromAddress || '' }} + @@ -39,12 +52,14 @@ {{ t('chain.txAction') }} - {{ t('chain.txIssue') }} {{ tokenId || '-' }} - {{ t('chain.txFromNull') }} - {{ zeroAddress }} - + {{ t('chain.txIssue') }} {{ actionToken || '' }} + + {{ t('chain.txFromNull') }} + {{ actionFrom }} + + {{ t('chain.txToward') }} - {{ mintTo }} + {{ actionTo }} @@ -57,11 +72,11 @@ - + {{ t('chain.txReceiver') }} - {{ contractAddress }} - + {{ receiver }} + @@ -73,8 +88,8 @@ {{ t('chain.txInput') }} - Method{{ mintMethod }} - MethodId{{ mintMethodId }} + Method{{ detail?.method || '' }} + MethodId{{ detail?.methodId || '' }} @@ -103,31 +118,35 @@ - - Address - {{ contractAddress || '-' }} - - - Name - Transfer(address from, address to, uint256 tokenId) - - - Topics - - - [{{ index }}] - Dec - {{ topic }} + {{ t('chain.txLogsEmpty') }} + + + + Address + {{ log.address }} - - - - Data - 0x - + + Name + {{ log.name }} + + + Topics + + + [{{ index }}] + {{ topic }} + + + + + Data + {{ log.data || '0x' }} + + + - {{ t('chain.txBack') }} + {{ t('chain.txBack') }} @@ -136,6 +155,7 @@ import { computed, defineComponent, h, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import dayjs from 'dayjs'; +import type { ChainDetail } from '@/api'; const CopyIcon = defineComponent({ name: 'CopyIcon', @@ -147,12 +167,7 @@ const CopyIcon = defineComponent({ }, }); -const ZERO_ADDRESS = '0x' + '0'.repeat(40); -const TRANSFER_TOPIC = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'; -const MINT_METHOD = 'mint(address to, string author, string productId, string feature, string initPrice)'; -const MINT_METHOD_ID = '0xa40d1b10'; - -const props = defineProps<{ +const props = withDefaults(defineProps<{ txHash?: string | null; succeeded: boolean; statusText: string; @@ -164,36 +179,34 @@ const props = defineProps<{ productId?: string | null; feature?: string | null; mintTo?: string | null; -}>(); + detail?: ChainDetail | null; + showHeading?: boolean; + showClose?: boolean; +}>(), { showHeading: true, showClose: true }); defineEmits<{ (event: 'copy', value: string): void; (event: 'close'): void }>(); const { t } = useI18n(); const tab = ref<'info' | 'logs'>('info'); -const zeroAddress = ZERO_ADDRESS; -const mintMethod = MINT_METHOD; -const mintMethodId = MINT_METHOD_ID; - +const shownBlock = computed(() => props.detail?.blockHeight || props.blockHeight); +const receiver = computed(() => props.detail?.toAddress || props.contractAddress || ''); +const actionToken = computed(() => props.detail?.action?.tokenId || (props.tokenId == null ? '' : String(props.tokenId))); +const actionFrom = computed(() => props.detail?.action?.fromAddress || ''); +const actionTo = computed(() => props.detail?.action?.toAddress || props.mintTo || ''); const timeText = computed(() => { - if (!props.onchainAt) return '-'; - const parsed = dayjs(props.onchainAt); - return parsed.isValid() ? parsed.format('YYYY-MM-DD HH:mm:ss') : '-'; -}); -const inputs = computed(() => [ - { name: 'to', type: 'address', value: props.mintTo || '-', copy: props.mintTo || '' }, - { name: 'author', type: 'string', value: props.author || '-', copy: props.author || '' }, - { name: 'productId', type: 'string', value: props.productId || '-', copy: props.productId || '' }, - { name: 'feature', type: 'string', value: props.feature || '-', copy: props.feature || '' }, - { name: 'initPrice', type: 'string', value: '-', copy: '' }, -]); - -const topics = computed(() => { - const token = props.tokenId == null || props.tokenId === '' ? null : String(props.tokenId); - return [ - TRANSFER_TOPIC, - ZERO_ADDRESS, - props.mintTo || '-', - token && /^\d+$/.test(token) ? token : '-', - ]; + const value = props.detail?.timeStamp || props.onchainAt; + if (!value) return ''; + const numeric = /^\d+$/.test(String(value)) ? Number(value) : value; + const parsed = dayjs(numeric); + return parsed.isValid() ? parsed.format('YYYY-MM-DD HH:mm:ss') : ''; }); +const inputs = computed(() => props.detail?.inputs?.length + ? props.detail.inputs.map((row) => ({ ...row, value: row.data, copy: row.data })) + : [ + { name: 'to', type: 'address', value: props.mintTo || '', copy: props.mintTo || '' }, + { name: 'author', type: 'string', value: props.author || '', copy: props.author || '' }, + { name: 'productId', type: 'string', value: props.productId || '', copy: props.productId || '' }, + { name: 'feature', type: 'string', value: props.feature || '', copy: props.feature || '' }, + { name: 'initPrice', type: 'string', value: '', copy: '' }, + ]); diff --git a/apps/client/src/views/TraceProof.vue b/apps/client/src/views/TraceProof.vue new file mode 100644 index 0000000..53b306d --- /dev/null +++ b/apps/client/src/views/TraceProof.vue @@ -0,0 +1,138 @@ + + + + {{ t('chain.txBack') }} + {{ t('chain.txTitle') }} + + + + {{ t('state.loading') }} + + + {{ t('chain.notOnchain') }} + + + + {{ toast }} + + + + + + + diff --git a/docs/消费者按需存证证书.md b/docs/消费者按需存证证书.md index 8574c95..7ea7ffd 100644 --- a/docs/消费者按需存证证书.md +++ b/docs/消费者按需存证证书.md @@ -8,7 +8,7 @@ 扫码页区块链模块底部左侧为“查看存证”、右侧靠右为“查看证书”,均不显示箭头。仅明确 ONCHAIN 且有交易哈希的天河链实物显示证书按钮,未上链或处理中均不显示。仅已激活、正常、已审核通过的实物可申请。普通页面打开、刷新与证书状态 GET 都不会提交存证;后台预览模式按钮禁用,不产生付费副作用。 -点击后在当前页面弹出进度窗口,文案依次为“正在调取存证数据”“获取存证证书”“正在整理存证证书”。先读取已保存的证书字段,没有时才 POST 申请并轮询状态;完成后在弹窗内展示存证内容、摘要、交易哈希、作者和生成时间,并可下载本平台生成的证书图片。弹窗可关闭,关闭只停止当前页面等待,后台已提交任务继续完成。再次点击直接读取数据库已有记录,不重复生成。公开接口不返回天河链网址,客户页面也不再跳转到天河链。旧的独立等待页已移除。 +「查看存证」和「查看证书」都进入本平台独立页面,不使用弹窗,手机上按屏幕宽度缩放,证书内部排版不改。证书页文案依次为“正在调取存证数据”“获取存证证书”“正在整理存证证书”。先读取已保存的证书字段,没有时才 POST 申请并轮询状态;证书按天河链证书页的版式在浏览器中绘制,下载也由浏览器生成 PNG。之后只读本地。交易详情里的 Gas、发送方和日志在第一次查到前留空,查全后写入本地,之后不再请求天河链。离开页面只停止当前等待,后台已提交任务继续完成。再次进入直接读取数据库已有记录,不重复生成。公开接口不返回天河链网址,客户页面也不能跳转到天河链。 新证书首次点击时按系统设置 `certificateTextTemplate` 渲染并冻结正文,默认 `{{作品名称}} {{版本}}`,例如“十二生肖莲花手工杯 一个装”。设置入口为“系统设置 → 区块链 → 证书文本模板”,帮助按钮点击后才弹出字段说明。支持 `{{作品名称}}`、`{{版本}}`、`{{追溯码}}`、`{{档案编号}}`、`{{作者}}`,可自由排序、重复使用并插入普通文本或换行。版本按作品模板中显示名为“版本”的字段取值,当前数据键为 `size`,不能硬编码成 `version`。 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 40359a2..0ed8bd4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -218,9 +218,15 @@ importers: dayjs: specifier: ^1.11.13 version: 1.11.21 + html2canvas: + specifier: ^1.4.1 + version: 1.4.1 photoswipe: specifier: ^5.4.4 version: 5.4.4 + qrcode: + specifier: ^1.5.4 + version: 1.5.4 vue: specifier: ^3.5.13 version: 3.5.39(typescript@5.9.3) @@ -1862,6 +1868,10 @@ packages: resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} engines: {node: 18 || 20 || >=22} + base64-arraybuffer@1.0.2: + resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==} + engines: {node: '>= 0.6.0'} + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -2167,6 +2177,9 @@ packages: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} + css-line-break@2.1.0: + resolution: {integrity: sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==} + css-render@0.15.14: resolution: {integrity: sha512-9nF4PdUle+5ta4W5SyZdLCCmFd37uVimSjg1evcTqKJCyvCEEj12WKzOSBNak6r4im4J4iYXKH1OWpUV5LBYFg==} @@ -2568,6 +2581,10 @@ packages: html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} + html2canvas@1.4.1: + resolution: {integrity: sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==} + engines: {node: '>=8.0.0'} + http-errors@2.0.1: resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==} engines: {node: '>= 0.8'} @@ -3649,6 +3666,9 @@ packages: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} + text-segmentation@1.0.3: + resolution: {integrity: sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==} + tinyglobby@0.2.17: resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} engines: {node: '>=12.0.0'} @@ -3800,6 +3820,9 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + utrie@1.0.2: + resolution: {integrity: sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==} + uuid@11.1.1: resolution: {integrity: sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==} hasBin: true @@ -5884,6 +5907,8 @@ snapshots: balanced-match@4.0.4: {} + base64-arraybuffer@1.0.2: {} + base64-js@1.5.1: {} baseline-browser-mapping@2.10.40: {} @@ -6188,6 +6213,10 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 + css-line-break@2.1.0: + dependencies: + utrie: 1.0.2 + css-render@0.15.14: dependencies: '@emotion/hash': 0.8.0 @@ -6615,6 +6644,11 @@ snapshots: html-escaper@2.0.2: {} + html2canvas@1.4.1: + dependencies: + css-line-break: 2.1.0 + text-segmentation: 1.0.3 + http-errors@2.0.1: dependencies: depd: 2.0.0 @@ -7881,6 +7915,10 @@ snapshots: glob: 7.2.3 minimatch: 3.1.5 + text-segmentation@1.0.3: + dependencies: + utrie: 1.0.2 + tinyglobby@0.2.17: dependencies: fdir: 6.5.0(picomatch@4.0.4) @@ -8022,6 +8060,10 @@ snapshots: util-deprecate@1.0.2: {} + utrie@1.0.2: + dependencies: + base64-arraybuffer: 1.0.2 + uuid@11.1.1: {} v8-compile-cache-lib@3.0.1: {}
{{ certificateError }}
{{ t('chain.txLogsEmpty') }}
{{ t('state.loading') }}
{{ t('chain.notOnchain') }}