From 6f895acf6337bf0b80b354e4b56888355445396f Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Sun, 16 Aug 2026 09:04:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF:=20API=20Keys=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E5=8D=A1=E7=89=87=E5=B8=83=E5=B1=80=20+=20?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移动端(md 以下)以卡片列表替代横向滚动表格, 展示配额/过期/最近使用 - 桌面表格补充配额/过期列, 移除创建时间列 - copyText 支持 Clipboard API + execCommand 回退(HTTP 环境可用) - 删除文案由"吊销"改为"删除(不可恢复)" Co-Authored-By: Claude --- web/src/lib/clipboard.ts | 30 +++++++ web/src/views/console/KeysView.vue | 127 +++++++++++++++++++++-------- 2 files changed, 123 insertions(+), 34 deletions(-) create mode 100644 web/src/lib/clipboard.ts diff --git a/web/src/lib/clipboard.ts b/web/src/lib/clipboard.ts new file mode 100644 index 0000000..20d9ebf --- /dev/null +++ b/web/src/lib/clipboard.ts @@ -0,0 +1,30 @@ +// copyText 复制文本到剪贴板。 +// 优先用 Clipboard API(安全上下文 HTTPS/localhost);HTTP 环境回退到 execCommand('copy')。 +export async function copyText(text: string): Promise { + // 1. Clipboard API + if (navigator.clipboard?.writeText) { + try { + await navigator.clipboard.writeText(text) + return true + } catch { + /* 权限/焦点问题,回退 */ + } + } + // 2. execCommand 兜底(非安全上下文可用) + try { + const ta = document.createElement('textarea') + ta.value = text + ta.style.position = 'fixed' + ta.style.opacity = '0' + ta.style.pointerEvents = 'none' + document.body.appendChild(ta) + ta.focus() + ta.select() + ta.setSelectionRange(0, text.length) + const ok = document.execCommand('copy') + document.body.removeChild(ta) + return ok + } catch { + return false + } +} diff --git a/web/src/views/console/KeysView.vue b/web/src/views/console/KeysView.vue index f0230f3..57fef49 100644 --- a/web/src/views/console/KeysView.vue +++ b/web/src/views/console/KeysView.vue @@ -1,9 +1,10 @@