Skip to content

fix(frontend): use copyTextToClipboard util for API key copy (#1151) - #1155

Merged
xerrors merged 1 commit into
xerrors:mainfrom
xxiaoxiong:fix/apikey-copy-non-secure-context
Nov 10, 2026
Merged

xerrors merged 1 commit into
xerrors:mainfrom
xxiaoxiong:fix/apikey-copy-non-secure-context

Conversation

@xxiaoxiong

Copy link
Copy Markdown
Contributor

背景 / Context

Closes #1151.

在非安全上下文(如 HTTP LAN IP 部署)下,navigator.clipboard.writeText 会被浏览器拒绝,导致「创建 API Key 点击复制」始终提示「复制失败」。

改动 / Changes

  • frontend/src/modules/settings/ui/ApiKeyManagementComponent.vue:
    • 引入已有的 copyTextToClipboard 工具(@/shared/lib/clipboard),它会优先使用 Clipboard API,在非安全上下文下降级为 document.execCommand(copy)。
    • copySecret 改为调用该工具而非直接调用 navigator.clipboard.writeText。

验证 / Verification

  • 复用项目现有工具,无新增依赖。
  • copyTextToClipboard 已在项目其他位置使用,逻辑成熟。

…#1151)

_replace direct navigator.clipboard.writeText with copyTextToClipboard
util that falls back to execCommand in non-secure contexts (HTTP/LAN IP)._

Fixes xerrors#1151
@xerrors
xerrors merged commit 162f7c0 into xerrors:main Nov 10, 2026
12 checks passed
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.

Error: 创建apikey点击复制 提示复制失败

2 participants