Skip to content

Bugfix copy button not working#5

Merged
knktc merged 2 commits intomainfrom
bugfix-copy-button-not-working
Jul 31, 2025
Merged

Bugfix copy button not working#5
knktc merged 2 commits intomainfrom
bugfix-copy-button-not-working

Conversation

@knktc
Copy link
Copy Markdown
Owner

@knktc knktc commented Jul 31, 2025

No description provided.

Copilot AI review requested due to automatic review settings July 31, 2025 05:25
@knktc knktc merged commit 13ba7c8 into main Jul 31, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 custom formatTime() 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

Comment thread templates/main.tmpl
<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>
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
<span>失败</span>
<span data-i18n="failed">${translations[currentLang]['failed']}</span>

Copilot uses AI. Check for mistakes.
Comment thread templates/main.tmpl
Comment on lines +572 to +573
document.execCommand('copy');
document.body.removeChild(textArea);
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.');
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants