feat: 完成后台联调与通用列表组件

This commit is contained in:
2026-08-01 12:17:33 +08:00
parent b53fe81999
commit 29dbae573f
50 changed files with 3394 additions and 580 deletions
+35
View File
@@ -0,0 +1,35 @@
export async function copyText(value: string) {
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
try {
await navigator.clipboard.writeText(value)
return
} catch {
// In insecure development contexts the Clipboard API may exist but reject.
}
}
if (typeof document === 'undefined' || !document.body) {
throw new Error('Clipboard is unavailable')
}
const textarea = document.createElement('textarea')
textarea.value = value
textarea.readOnly = true
textarea.setAttribute('aria-hidden', 'true')
Object.assign(textarea.style, {
position: 'fixed',
inset: '0 auto auto -9999px',
opacity: '0',
pointerEvents: 'none',
})
document.body.appendChild(textarea)
textarea.select()
try {
if (typeof document.execCommand !== 'function' || !document.execCommand('copy')) {
throw new Error('Clipboard copy failed')
}
} finally {
textarea.remove()
}
}