[GH-ISSUE #1408] 拷贝访问令牌出错,无法拷贝 #990

Closed
opened 2026-05-07 00:29:23 +02:00 by BreizhHardware · 2 comments

Originally created by @xxl6097 on GitHub (Jul 31, 2025).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1408

Image
Originally created by @xxl6097 on GitHub (Jul 31, 2025). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1408 <img width="1456" height="836" alt="Image" src="https://github.com/user-attachments/assets/797aa79d-6b9c-4b67-8c93-86094789ec12" />
BreizhHardware 2026-05-07 00:29:23 +02:00
  • closed this issue
  • added the
    🪲 bug
    label
Author
Owner

@binwiederhier commented on GitHub (Jul 31, 2025):

The clipboard API only works with HTTPS, not HTTP (https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API).

<!-- gh-comment-id:3138961532 --> @binwiederhier commented on GitHub (Jul 31, 2025): The clipboard API only works with HTTPS, not HTTP (https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API).
Author
Owner

@xxl6097 commented on GitHub (Jul 31, 2025):

export function copyToClipboard(text: string) {
  const textArea = document.createElement('textarea')
  textArea.value = text
  document.body.appendChild(textArea)
  textArea.focus()
  textArea.select()
  let ok = false
  try {
    ok = document.execCommand('copy')
    if (ok) {
      //showSucessTips('复制成功')
    } else {
      //showErrorTips('复制失败')
    }
  } catch (err) {
    console.error('Unable to copy to clipboard', err)
    ok = false
  }
  document.body.removeChild(textArea)
  return ok
}

可以使用这种方式啊,不区分http和https

<!-- gh-comment-id:3139159269 --> @xxl6097 commented on GitHub (Jul 31, 2025): ``` export function copyToClipboard(text: string) { const textArea = document.createElement('textarea') textArea.value = text document.body.appendChild(textArea) textArea.focus() textArea.select() let ok = false try { ok = document.execCommand('copy') if (ok) { //showSucessTips('复制成功') } else { //showErrorTips('复制失败') } } catch (err) { console.error('Unable to copy to clipboard', err) ok = false } document.body.removeChild(textArea) return ok } ``` 可以使用这种方式啊,不区分http和https
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#990
No description provided.