跳到正文
简体中文

用法

import { ResultPage } from './ResultPage.jsx'

// After the action has finished on the server, show its result on its own page:
<ResultPage
  locale="en"
  variant={payment.ok ? 'success' : 'failure'}
  title={payment.ok ? 'Invoice INV-2041 paid' : 'Payment for INV-2041 failed'}
  details={[{ label: 'Amount', value: '$4,800.00' }, { label: 'Reference', value: 'INV-2041', copy: true }]}
  continueIn={payment.ok ? 8 : 0}              // seconds; 0 turns the countdown off
  onContinue={() => router.push('/invoices/2041')}
  onAction={async (which, variant) => {
    if (which === 'primary' && variant === 'failure') return await payment.retry()
    if (which === 'secondary') router.push('/invoices')
  }}
/>

属性

属性类型默认值作用
locale'en' | 'zh-CN' | 'es' | 'ja''en'内置文字的语言。
variant'success' | 'failure''success'显示哪种结果。只有成功才会自动跳转。
loadingbooleanfalse操作还在进行:显示加载动画和一句说明,并告知读屏软件。
title / text / detailsstring / string / Array<{ label, value, copy? }>—替换当前结果的标题、说明和信息列表。标题按“对象 + 动作 + 结果”来写。
continueInnumber8成功后自动继续前的秒数,0 表示关闭。指针或焦点停在操作区时暂停,点“留在本页”则停止。
onAction(which: 'primary' | 'secondary', variant) => Promise<any> | void—点击下一步操作时调用;Promise 进行中按钮显示等待。
onContinue() => void—倒计时结束时调用。不传时执行主操作。
labelsobject—替换任意内置文字(键名见 copy.js)。

装进你的项目

把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。

ResultPage.jsxresult-page.csscopy.jskit.jsxkit.cssui/base-button/ui/copy-button/ui/success-check/ui/spinner/tokens.cssREADME.md

区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。