fix(admin): copy buttons dead on HTTP origin — execCommand fallback
navigator.clipboard 仅安全上下文(HTTPS/localhost)可用,测试服务器经 http://IP:32005 访问时为 undefined,四处复制按钮(公开令牌/分享链接/ 嵌入代码/重置密码)点击即抛 TypeError 且无提示。统一 utils/clipboard copyText:API 优先、失败降级隐藏 textarea + execCommand。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,7 @@
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { formatDateTime } from '@/utils/albums/format'
|
||||
import { copyText } from '@/utils/clipboard'
|
||||
|
||||
defineOptions({ name: 'AlbumSummaryHeader' })
|
||||
|
||||
@@ -163,8 +164,11 @@
|
||||
])
|
||||
|
||||
async function copyToken() {
|
||||
await navigator.clipboard.writeText(props.album.publicToken)
|
||||
ElMessage.success(t('albumsManage.list.copied'))
|
||||
if (await copyText(props.album.publicToken)) {
|
||||
ElMessage.success(t('albumsManage.list.copied'))
|
||||
} else {
|
||||
ElMessage.error(t('setting.actions.copyFailed'))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user