style: 出库上链弹窗打磨(出库时间红星必填/修复关闭按钮翻译/上链信息标签不换行居中+复制按钮)

This commit is contained in:
Nixevol
2026-07-10 18:03:46 +08:00
parent e1e1cf7308
commit 3ad50edd57
4 changed files with 60 additions and 11 deletions
+1
View File
@@ -250,6 +250,7 @@
- 出库/上链防重复(2026-07-10):按「一物一码只能出库一次、已上链不可再上」补齐幂等校验。① 出库:`outbound.service.updateSingle`(单件)、`import-preview.processor`(导入预览)、`import.processor`(导入提交,防预览→提交竞态)三处均对 `code.outTime` 已存在拒绝「该追溯码已登记出库,不可重复出库」。② 上链:`attestation.service.trigger` 新增查重——存在 ONCHAIN/CONFIRMING/PENDING 的 proof 即拒绝(已上链→「不可重复上链」,处理中→「请稍候」);仅 FAILED 可通过独立 `retry` 接口重试(retry 原地更新既有 proof、不走 trigger,不受影响)。实测重复上链/重复出库均返回 400 拒绝。
- 天河链确认节奏调整(2026-07-10):`onchain.processor` 确认查询改为「提交完立即查 1 次 → 未到 10s → 再 30s」共 3 次自动尝试,之后停等手动重新确认(原为 30s/60s 两次)。用延迟数组 `AUTO_CONFIRM_DELAYS_MS=[0,10_000,30_000]`、`MAX_AUTO_CONFIRM_ATTEMPTS=数组长度`,第 attempt 次延迟取 `[attempt-1]`。实测:提交同秒即查到 mint 已进块(status 0x0、blockHeight、tokenId),直接 ONCHAIN。
- 天河链方案 B 落地(存证+发行+轮换,2026-07-10,dev/refine):按甲方决策「其余全做、媒体待定」实现。① 数据模型:`blockchain_proof` 加 `token_id`/`contract_address`(迁移 `20260710110000_add_proof_token_fields`);schema 补 `@db.VarChar` 注解消除历史 drift(operation_log.path 512 / outbound_import_session.file_key 512 / backup_record.file_path 1024)。② `TianheProvider` 新增 `publish`(接口2,operateId≤20,name≤42,author≤120,feature≤500)与 `updateUserKey`(接口7)。③ `BlockchainService.attestWithTianhe`:upload 存证→publish 铸 1 NFT(productId=追溯码、feature=存证链接)→ 主 txHash 切为 mint 交易、confirmationRequired=true 走接口9确认→ONCHAIN;合约地址存 `tianheContractAddress`、已发行最大 tokenId 存 `tianheMaxTokenId`(指定合约时作 baseTokenId,队列串行无争用);缺 product 时退化纯存证。`confirmTransaction` 确认成功回填 tokenId、更新 maxTokenId。④ `rotateTianheUserKey`:生成新随机 key→接口7链上改→持久化→接口8校验地址,`/settings/tianhe/identity/rotate` + 设置页「轮换密钥」(二次确认+回显强提示)。⑤ C 端:public-trace + Trace.vue 区块链卡增 tokenId/合约地址展示(i18n chain.tokenId/chain.contract)。⑥ 实测(测试环境):追溯码 412680781069 走通 upload→publish(合约 0xc96ae8a4... tokenId=0)→确认(区块高度 5820347)→ONCHAIN,C 端展示数字藏品编号 0/合约地址/区块高度;轮换 UserKey 成功(钱包地址不变),新 key 回填测试文档。验证:4 包构建 + 27 单测通过。**唯一待定:媒体上链层级 L1/L2/L3 待甲方确认「链上放什么」,当前维持 JSON 存证。**
- 出库/上链弹窗 UI 打磨(2026-07-10,分支 `dev/tianhe-no-metadata-upload`):① 出库时间加红星必填标识(`n-form-item-gi :required="!outboundReadonly"`);② 修复「关闭」按钮显示字面量——`common.action` 原缺 `close` 键,已补中英;③「区块链存证」详情用 `n-descriptions` 的 `label-style` 设 `whiteSpace:nowrap + verticalAlign:middle`,标题不再折行、垂直居中;④ 除「上链状态」外每项(数据哈希/交易哈希/tokenId/合约/区块高度/上链时间/存证查询)加复制按钮(`CopyOutline` + `navigator.clipboard`,`copyValue` 提示 `common.msg.copied/copyFailed`)。浏览器实测通过。
- 出库/上链一致性强化(2026-07-10,分支 `dev/tianhe-no-metadata-upload`):按甲方口径补三条不变量。① 确认中即已上链:前端 `rowIsOnchain` 由仅认 ONCHAIN 改为认 `ONCHAIN/CONFIRMING/PENDING`(这些状态菜单均显示「上链信息」、不给再触发;仅 FAILED 显示「上链」可重试),与后端 `attestation.trigger` 早有的防重复拦截对齐(天河 publish 一返回 mint 哈希即已广播上链、必进块,除非明确失败,故确认中不可重复上链);`targetProof` 回退用 `latestAnyProof` 使确认中也能展示上链信息。② 出库时间必填默认此刻:弹窗未出库时默认 `dayjs()` 此刻、前端空值拦截、后端 `outbound.updateSingle` 强制 `outTime` 非空。③ 上链必先出库:后端 `attestation.trigger` 增 `isOutbound(code)` 校验,未出库拒绝「请先登记出库再上链」,杜绝「已上链未登记」不一致(防直连 API 绕过)。注:这些为通用改进,暂随本分支;方案二合并时一并进 dev/refine,若方案二被否再单独回植。
- 天河链去掉元数据上链存证、改为仅发行(2026-07-10,分支 `dev/tianhe-no-metadata-upload`,待甲方展示确认后再合并):甲方定「不上传元数据、作品详情/媒体存我方 OSS」。上链链路由「upload 存证 + publish 发行」精简为「仅 publish 发行」,每件省一次上链调用(按次计费更省)。改动:① `AttestPayload.product` 增 `feature`;② `attestation.service` 注入 `StorageService`,`product.feature=作品主图公开URL`(天河 feature 语义=作品媒体地址,正是甲方放 OSS 的图,藏品/交易详情页可展示);③ `onchain.processor.productInfo` 透传 feature;④ `blockchain.service.attestWithTianhe` 删除 `provider.attest(upload)` 调用,直接 publish(feature),raw 去掉 upload 痕迹。`TianheProvider.attest`(upload) 方法保留(AttestationProvider 接口所需 + 便于甲方后续加回,仅需在 attestWithTianhe 恢复两步调用)。dataHash 仍本地计算并展示(作品数据指纹,非天河链上存证)。构建+11 单测通过。分支未合并。
- C端「查看存证」改跳天河区块浏览器交易详情页(2026-07-10):原 `explorerUrl` 存的是 upload 返回的 UDFS 裸 JSON 链接(打开只有文本,不规范)。实测天河浏览器 URL 规则后改为跳交易详情页 `https://{test.}explorer.tianhecloud.com/#/tiChain/transDetail?hash=<mintTxHash>`(显示状态/区块高度/发行动作/合约/productId=追溯码/feature=存证链接,规范完整)。实现:`TianheProvider.explorerTxUrl()` 按 API base 是否含 `test.` 自动切测试/生产浏览器域名;`blockchain.service.attestWithTianhe` 的 `explorerUrl` 改用它,UDFS 链接保留在 `raw.attestUrl`(浏览器 feature 字段也含)。确认流程不覆盖 explorerUrl。C 端/后台经 `public-trace`、trace-code 列表自动跟随。仅对新上链记录生效,旧记录重上链即更新。藏品详情页 `nfrDetail?nfrId=&contractAddress=` 因不传媒体会显示「未获取到媒体内容」故不选它。API 构建+11 单测通过。
+55 -11
View File
@@ -147,7 +147,7 @@
<n-modal v-model:show="outboundModal" preset="card" :title="outboundModalTitle" style="width: 620px">
<n-form :model="outboundForm" label-placement="top">
<n-grid :cols="2" :x-gap="16">
<n-form-item-gi :label="t('pages.outbound.outTime')">
<n-form-item-gi :label="t('pages.outbound.outTime')" :required="!outboundReadonly">
<n-date-picker v-if="!outboundReadonly" v-model:formatted-value="outboundForm.outTime" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
<n-text v-else>{{ outboundForm.outTime || '-' }}</n-text>
</n-form-item-gi>
@@ -163,30 +163,51 @@
<template v-if="targetOnchain && targetProof">
<n-divider style="margin: 4px 0 12px">{{ t('pages.blockchain.title') }}</n-divider>
<n-descriptions :column="1" label-placement="left" size="small" bordered>
<n-descriptions
:column="1"
label-placement="left"
size="small"
bordered
:label-style="{ whiteSpace: 'nowrap', verticalAlign: 'middle' }"
:content-style="{ verticalAlign: 'middle' }"
>
<n-descriptions-item :label="t('pages.blockchain.status')">
<n-tag size="small" :type="proofStatusType(targetProof)">{{ proofStatusText(targetProof) }}</n-tag>
</n-descriptions-item>
<n-descriptions-item v-if="targetProof.dataHash" :label="t('pages.blockchain.dataHash')">
<span class="onchain-mono">{{ targetProof.dataHash }}</span>
<span class="onchain-val"><span class="onchain-mono">{{ targetProof.dataHash }}</span>
<n-button quaternary circle size="tiny" :title="t('common.action.copy')" @click="copyValue(targetProof.dataHash)"><template #icon><n-icon :component="CopyOutline" /></template></n-button>
</span>
</n-descriptions-item>
<n-descriptions-item v-if="targetProof.txHash" :label="t('pages.blockchain.txHash')">
<span class="onchain-mono">{{ targetProof.txHash }}</span>
<span class="onchain-val"><span class="onchain-mono">{{ targetProof.txHash }}</span>
<n-button quaternary circle size="tiny" :title="t('common.action.copy')" @click="copyValue(targetProof.txHash)"><template #icon><n-icon :component="CopyOutline" /></template></n-button>
</span>
</n-descriptions-item>
<n-descriptions-item v-if="targetProof.tokenId" :label="t('pages.blockchain.tokenId')">
<span class="onchain-mono">{{ targetProof.tokenId }}</span>
<n-descriptions-item v-if="targetProof.tokenId !== null && targetProof.tokenId !== undefined" :label="t('pages.blockchain.tokenId')">
<span class="onchain-val"><span class="onchain-mono">{{ targetProof.tokenId }}</span>
<n-button quaternary circle size="tiny" :title="t('common.action.copy')" @click="copyValue(targetProof.tokenId)"><template #icon><n-icon :component="CopyOutline" /></template></n-button>
</span>
</n-descriptions-item>
<n-descriptions-item v-if="targetProof.contractAddress" :label="t('pages.blockchain.contract')">
<span class="onchain-mono">{{ targetProof.contractAddress }}</span>
<span class="onchain-val"><span class="onchain-mono">{{ targetProof.contractAddress }}</span>
<n-button quaternary circle size="tiny" :title="t('common.action.copy')" @click="copyValue(targetProof.contractAddress)"><template #icon><n-icon :component="CopyOutline" /></template></n-button>
</span>
</n-descriptions-item>
<n-descriptions-item v-if="targetProof.blockHeight" :label="t('pages.blockchain.blockHeight')">
{{ targetProof.blockHeight }}
<span class="onchain-val"><span>{{ targetProof.blockHeight }}</span>
<n-button quaternary circle size="tiny" :title="t('common.action.copy')" @click="copyValue(targetProof.blockHeight)"><template #icon><n-icon :component="CopyOutline" /></template></n-button>
</span>
</n-descriptions-item>
<n-descriptions-item v-if="targetProof.onchainAt" :label="t('pages.blockchain.onchainAt')">
{{ fmt(targetProof.onchainAt) }}
<span class="onchain-val"><span>{{ fmt(targetProof.onchainAt) }}</span>
<n-button quaternary circle size="tiny" :title="t('common.action.copy')" @click="copyValue(fmt(targetProof.onchainAt))"><template #icon><n-icon :component="CopyOutline" /></template></n-button>
</span>
</n-descriptions-item>
<n-descriptions-item v-if="targetProof.explorerUrl" :label="t('pages.blockchain.explorer')">
<a :href="targetProof.explorerUrl" target="_blank" rel="noopener" style="color: var(--brand)">{{ targetProof.explorerUrl }}</a>
<span class="onchain-val"><a :href="targetProof.explorerUrl" target="_blank" rel="noopener" class="onchain-mono" style="color: var(--brand)">{{ targetProof.explorerUrl }}</a>
<n-button quaternary circle size="tiny" :title="t('common.action.copy')" @click="copyValue(targetProof.explorerUrl)"><template #icon><n-icon :component="CopyOutline" /></template></n-button>
</span>
</n-descriptions-item>
</n-descriptions>
</template>
@@ -217,7 +238,7 @@ import { computed, h, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { NButton, NDropdown, NIcon, NTag, NText, type DataTableColumns, type DropdownOption } from 'naive-ui';
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline, EllipsisHorizontalOutline, FilterOutline } from '@vicons/ionicons5';
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline, EllipsisHorizontalOutline, FilterOutline, CopyOutline } from '@vicons/ionicons5';
import dayjs from 'dayjs';
import { TraceCodeStatus } from '@artveris/shared';
import { traceCodeApi, jobApi, artworkApi, outboundApi } from '@/api';
@@ -819,6 +840,17 @@ function getOutImages(row: any) {
);
}
async function copyValue(value: unknown) {
const text = value === null || value === undefined ? '' : String(value);
if (!text) return;
try {
await navigator.clipboard.writeText(text);
message.success(t('common.msg.copied'));
} catch {
message.error(t('common.msg.copyFailed'));
}
}
function openOutboundModal(row: any) {
outboundTarget.value = row;
// 出库时间必填:未出库时默认此刻;已出库时回显既有时间(只读)
@@ -1018,6 +1050,18 @@ onUnmounted(() => {
font-size: 12px;
word-break: break-all;
}
.onchain-val {
display: flex;
align-items: center;
gap: 6px;
}
.onchain-val > :first-child {
flex: 1;
min-width: 0;
}
.onchain-val .n-button {
flex: 0 0 auto;
}
@media (max-width: 720px) {
.toolbar-control,
.toolbar-control.wide,
+2
View File
@@ -23,6 +23,7 @@
"unbind": "Unbind",
"retry": "Retry",
"copy": "Copy",
"close": "Close",
"onchain": "On-chain",
"qrcode": "QR Code",
"manage": "Manage",
@@ -116,6 +117,7 @@
"created": "Created",
"updated": "Updated",
"copied": "Copied",
"copyFailed": "Copy failed",
"operationSuccess": "Success",
"loginExpired": "Session expired, please log in again",
"networkError": "Network error, please try again",
+2
View File
@@ -23,6 +23,7 @@
"unbind": "解绑",
"retry": "重试",
"copy": "复制",
"close": "关闭",
"onchain": "上链存证",
"qrcode": "二维码",
"manage": "管理",
@@ -116,6 +117,7 @@
"created": "创建成功",
"updated": "更新成功",
"copied": "已复制",
"copyFailed": "复制失败",
"operationSuccess": "操作成功",
"loginExpired": "登录已过期,请重新登录",
"networkError": "网络异常,请稍后再试",