Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions web/src/components/RegisterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function RegisterPage() {
const [passwordValid, setPasswordValid] = useState(false)
const [showPassword, setShowPassword] = useState(false)
const [showConfirmPassword, setShowConfirmPassword] = useState(false)
const [copySuccess, setCopySuccess] = useState(false)

useEffect(() => {
// 获取系统配置,检查是否开启内测模式
Expand Down Expand Up @@ -98,8 +99,12 @@ export function RegisterPage() {
setLoading(false)
}

const copyToClipboard = (text: string) => {
copyWithToast(text)
const copyToClipboard = async (text: string) => {
const success = await copyWithToast(text)
if (success) {
setCopySuccess(true)
setTimeout(() => setCopySuccess(false), 2000)
}
}

return (
Expand Down Expand Up @@ -427,13 +432,13 @@ export function RegisterPage() {
</code>
<button
onClick={() => copyToClipboard(otpSecret)}
className="px-2 py-1 text-xs rounded"
className="px-2 py-1 text-xs rounded transition-all"
style={{
background: 'var(--brand-yellow)',
color: 'var(--brand-black)',
background: copySuccess ? '#0ECB81' : 'var(--brand-yellow)',
color: copySuccess ? '#FFF' : 'var(--brand-black)',
}}
>
{t('copy', language)}
{copySuccess ? '✓ ' + (t('copied', language) || 'Copied!') : t('copy', language)}
</button>
</div>
</div>
Expand Down
Loading