Skip to content

修复在HTTP/非安全上下文环境下,复制rss link失效的问题 - #1091

Open
afraidjpg wants to merge 2 commits into
EstrellaXD:3.3-devfrom
afraidjpg:fix/http-copy
Open

修复在HTTP/非安全上下文环境下,复制rss link失效的问题#1091
afraidjpg wants to merge 2 commits into
EstrellaXD:3.3-devfrom
afraidjpg:fix/http-copy

Conversation

@afraidjpg

Copy link
Copy Markdown

非 HTTPS / 安全上下文 环境下,chrome等浏览器会禁用 navigator.clipboard.writeText 且无法在网站设置中更改此设置,导致在家庭局域网的无https的环境下无法使用复制功能

[错误报告]非HTTPS下无法使用rss链接复制功能 #1090

Copilot AI review requested due to automatic review settings July 23, 2026 07:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

该 PR 针对在非 HTTPS / 非安全上下文(例如家庭局域网通过 IP:端口访问)下浏览器禁用 navigator.clipboard.writeText 导致 RSS 链接无法复制的问题,引入带回退方案的复制实现以恢复 WebUI 的复制功能(对应 Issue #1090)。

Changes:

  • 将 RSS 链接复制从直接调用 navigator.clipboard.writeText 改为使用带 fallback 的复制方法。
  • 新增 copyTextWithFallback:优先使用 Clipboard API(安全上下文),失败时回退到 document.execCommand('copy')

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 58 to 62
if (!link) return;
await navigator.clipboard.writeText(link);
await copyTextWithFallback(link);
copied.value = true;
clearTimeout(copyTimer);
copyTimer = setTimeout(() => {
Comment on lines +84 to +88
await navigator.clipboard.writeText(text);
return true;
}
} catch {
}
Comment thread webui/src/hooks/useBangumiRuleForm.ts Outdated
Comment on lines +90 to +107
// fallback 方案:创建一个不可见的 textarea 元素,选中内容并执行复制命令
const textarea = document.createElement("textarea");
textarea.value = text;
textarea.style.position = "fixed";
textarea.style.left = "-9999px";
textarea.style.top = "-9999px";
textarea.setAttribute("readonly", "");

document.body.appendChild(textarea);

textarea.select();
textarea.setSelectionRange(0, textarea.value.length);

const success = document.execCommand("copy");

document.body.removeChild(textarea);

return success;
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@afraidjpg is attempting to deploy a commit to the estrellaxd's projects Team on Vercel.

A member of the Team first needs to authorize it.

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