Files

36 lines
1.3 KiB
JavaScript

// OpsXShell 产品站 — 无依赖静态脚本
document.addEventListener('DOMContentLoaded', () => {
// 移动端导航
const toggle = document.querySelector('.nav-toggle')
const links = document.querySelector('.nav-links')
toggle?.addEventListener('click', () => links?.classList.toggle('open'))
links?.querySelectorAll('a').forEach((a) =>
a.addEventListener('click', () => links.classList.remove('open'))
)
// 复制 SHA-256
document.querySelectorAll('[data-copy]').forEach((button) => {
button.addEventListener('click', async () => {
const value = button.getAttribute('data-copy') || ''
try {
await navigator.clipboard.writeText(value)
const original = button.textContent
button.textContent = '已复制 ✓'
setTimeout(() => { button.textContent = original }, 1600)
} catch {
// 剪贴板不可用(如 file:// 非安全上下文)时退回选中文本提示
button.textContent = '请手动复制'
setTimeout(() => { button.textContent = original }, 1600)
}
})
})
// FAQ 单开(details 互斥)
const faqs = document.querySelectorAll('.faq-item')
faqs.forEach((item) =>
item.addEventListener('toggle', () => {
if (item.open) faqs.forEach((other) => { if (other !== item) other.open = false })
})
)
})