nofx icon indicating copy to clipboard operation
nofx copied to clipboard

fix(web): improve copy functionality for Google Authenticator secret (#616)

Open the-dev-z opened this issue 1 year ago • 6 comments

Pull Request - Frontend | 前端 PR

📝 Description | 描述

English: Fixed the issue where the copy button for Google Authenticator secret key had no feedback, leaving users unsure if the copy succeeded.

中文: 修复了 Google 验证器密钥复制按钮无反馈的问题,导致用户不确定复制是否成功。


🎯 Type of Change | 变更类型

  • [x] 🐛 Bug fix | 修复 Bug

🔗 Related Issues | 相关 Issue

  • Closes #616 | 关闭 #616

📋 Changes Made | 具体变更

English:

  • Added copySuccess state to track copy status
  • Enhanced copyToClipboard function with:
    • async/await for proper asynchronous handling
    • Visual feedback (button turns green, shows ✓ Copied! for 2 seconds)
    • Error handling with fallback to document.execCommand for older browsers
    • Error message display if copy fails
  • Updated copy button UI:
    • Added transition-all animation
    • Background changes to green (#0ECB81) on success
    • Text changes from 'Copy' to '✓ Copied!'

中文:

  • 添加 copySuccess state 追踪复制状态
  • 增强 copyToClipboard 函数:
    • 使用 async/await 正确处理异步操作
    • 添加视觉反馈(按钮变绿色,显示 ✓ Copied! 2秒)
    • 添加错误处理,降级到 document.execCommand 支持旧浏览器
    • 复制失败时显示错误提示
  • 更新复制按钮 UI:
    • 添加 transition-all 动画效果
    • 复制成功时背景变为绿色 (#0ECB81)
    • 文字从 'Copy' 变为 '✓ Copied!'

🧪 Testing | 测试

Test Environment | 测试环境

  • OS | 操作系统: macOS
  • Node Version | Node 版本: Latest
  • Browser(s) | 浏览器: Chrome, Safari

Manual Testing | 手动测试

  • [x] Tested in development mode | 开发模式测试通过
  • [x] Tested production build | 生产构建测试通过
  • [x] Tested on multiple browsers | 多浏览器测试通过
  • [x] Verified no existing functionality broke | 确认没有破坏现有功能

Test Results | 测试结果:

  • ✅ Button turns green and shows ✓ Copied! on success
  • ✅ Automatically reverts to original state after 2 seconds
  • ✅ Fallback works in older browsers
  • ✅ Compatible with upstream changes (betaMode, password toggle)

✅ Checklist | 检查清单

Code Quality | 代码质量

  • [x] Code follows project style | 代码遵循项目风格
  • [x] Self-review completed | 已完成代码自查
  • [x] Comments added for complex logic | 已添加必要注释

By submitting this PR, I confirm | 提交此 PR,我确认:

  • [x] I have read the Contributing Guidelines | 已阅读贡献指南
  • [x] I agree to the Code of Conduct | 同意行为准则
  • [x] My contribution is licensed under AGPL-3.0 | 贡献遵循 AGPL-3.0 许可证

the-dev-z avatar Nov 10 '25 15:11 the-dev-z

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits PR Size: 🟢 Small (36 lines: +30 -6)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
api/server.go
manager/trader_manager.go

Go Vet: ✅ Good Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? Feel free to ask in the comments! 🙏


These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.

github-actions[bot] avatar Nov 10 '25 15:11 github-actions[bot]

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits PR Size: 🟢 Small (39 lines: +32 -7)

🔧 Backend Checks

Go Formatting: ✅ Good Go Vet: ✅ Good Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? Feel free to ask in the comments! 🙏


These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.

github-actions[bot] avatar Nov 10 '25 16:11 github-actions[bot]

Could you provide a snapshot for this?

hzb1115 avatar Nov 11 '25 01:11 hzb1115

Havet got what this used for can put some business scenario and test screenshot ? Thanks.

@the-dev-z

xqliu avatar Nov 11 '25 06:11 xqliu

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits PR Size: 🟢 Small (17 lines: +11 -6)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
decision/prompt_manager_test.go
market/data_test.go
trader/hyperliquid_trader_race_test.go

Go Vet: ✅ Good Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? Feel free to ask in the comments! 🙏


These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.

github-actions[bot] avatar Nov 11 '25 07:11 github-actions[bot]

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 14 committers have signed the CLA.

:white_check_mark: tinkle-community
:x: xqliu
:x: tangmengqiu
:x: the-dev-z
:x: tinkle
:x: hzb1115
:x: Icyoung
:x: deloz
:x: CoderMageFox
:x: wquguru
:x: 0xEmberZz
:x: ljh740
:x: Im-Sue
:x: zpng


tinkle seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

cla-assistant[bot] avatar Dec 22 '25 16:12 cla-assistant[bot]