Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a fix for a non-working copy button by adding client-side JavaScript functionality to copy request body content to the clipboard. The implementation includes both modern clipboard API support and fallback mechanisms for older browsers.
Key changes:
- Replaced
toLocaleString()with a customformatTime()function for consistent timestamp formatting - Added comprehensive copy button functionality with visual feedback and error handling
- Implemented clipboard API with fallback support for non-HTTPS contexts
| <svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /> | ||
| </svg> | ||
| <span>失败</span> |
There was a problem hiding this comment.
The error message is hardcoded in Chinese ('失败' means 'failed'). This should use the translation system like the success message does, e.g., ${translations[currentLang]['failed']} to maintain consistency with the internationalization approach used elsewhere.
| <span>失败</span> | |
| <span data-i18n="failed">${translations[currentLang]['failed']}</span> |
| document.execCommand('copy'); | ||
| document.body.removeChild(textArea); |
There was a problem hiding this comment.
The document.execCommand('copy') method is deprecated. While it's used as a fallback here, consider adding error handling since this method can fail and returns a boolean indicating success/failure.
| document.execCommand('copy'); | |
| document.body.removeChild(textArea); | |
| const successful = document.execCommand('copy'); | |
| document.body.removeChild(textArea); | |
| if (!successful) { | |
| throw new Error('Fallback copy method failed.'); | |
| } |
No description provided.