mirror of
https://github.com/samber/awesome-prometheus-alerts.git
synced 2026-06-26 03:17:07 +08:00
Update site/src/components/CopyButton.astro
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
e056652504
commit
96731e7ee2
1 changed files with 39 additions and 36 deletions
|
|
@ -43,8 +43,12 @@ const btnId = `copy-btn-${targetId}`;
|
|||
</button>
|
||||
)}
|
||||
|
||||
<script>
|
||||
document.querySelectorAll<HTMLButtonElement>('.copy-btn').forEach((btn) => {
|
||||
<script define:vars={{ btnId }}>
|
||||
const btn = document.getElementById(btnId);
|
||||
if (!(btn instanceof HTMLButtonElement)) return;
|
||||
if (btn.dataset.copyBound === 'true') return;
|
||||
|
||||
btn.dataset.copyBound = 'true';
|
||||
btn.addEventListener('click', async () => {
|
||||
const targetId = btn.dataset.copyTarget;
|
||||
if (!targetId) return;
|
||||
|
|
@ -83,5 +87,4 @@ const btnId = `copy-btn-${targetId}`;
|
|||
copiedLabel?.classList.add('hidden');
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue