前端: API Keys 移动端卡片布局 + 复制兼容

- 移动端(md 以下)以卡片列表替代横向滚动表格, 展示配额/过期/最近使用
- 桌面表格补充配额/过期列, 移除创建时间列
- copyText 支持 Clipboard API + execCommand 回退(HTTP 环境可用)
- 删除文案由"吊销"改为"删除(不可恢复)"

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
SakurasanandClaude committed 2026-08-16 09:04:26 +08:00
1 parent fb7db00817
commit 6f895acf63
2 files changed
+123 -34

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
// copyText 复制文本到剪贴板。
// 优先用 Clipboard API(安全上下文 HTTPS/localhost);HTTP 环境回退到 execCommand('copy')。
export async function copyText(text: string): Promise<boolean> {
// 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
}
}