// 初始化背景粒子 if (window.particlesJS) { particlesJS('particles-js', { "particles": { "number": { "value": 80, "density": { "enable": true, "value_area": 800 } }, "color": { "value": "#ff0055" }, "shape": { "type": "circle" }, "opacity": { "value": 0.2, "random": false }, "size": { "value": 3, "random": true }, "line_linked": { "enable": true, "distance": 150, "color": "#ff0055", "opacity": 0.1, "width": 1 }, "move": { "enable": true, "speed": 2, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false } }, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": true, "mode": "grab" }, "onclick": { "enable": true, "mode": "push" }, "resize": true }, "modes": { "grab": { "distance": 140, "line_linked": { "opacity": 1 } }, "push": { "particles_nb": 4 } } }, "retina_detect": true }); } // 简单的平滑滚动增强 (可选,因为 CSS 已带 scroll-behavior) document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); // 动态获取版本信息 (示例:如果你有公开接口可以调用) async function fetchVersion() { try { const response = await fetch('/challenge'); // 这里只是示例调用一个已有接口测试连通性 if (response.ok) { console.log("Server Connection: OK"); } } catch (e) { console.log("Server Connection: OFFLINE"); } } window.onload = () => { console.log("GBL System Center Initialized"); fetchVersion(); initTrialClaim(); }; function initTrialClaim() { const claimBtn = document.getElementById('claim-btn'); const trialResult = document.getElementById('trial-result'); const trialPreClaim = document.getElementById('trial-pre-claim'); const codeDisplay = document.getElementById('card-code-display'); if (claimBtn) { claimBtn.onclick = async () => { claimBtn.disabled = true; claimBtn.style.opacity = '0.6'; claimBtn.querySelector('.dl-main').innerText = '正在领取...'; try { const response = await fetch('/get_trial_card', { method: 'POST', headers: { 'Content-Type': 'application/json' } }); const data = await response.json(); if (data.status === 1) { codeDisplay.innerText = data.code; trialPreClaim.style.display = 'none'; trialResult.style.display = 'block'; } else { alert(data.msg || '领取失败,请稍后再试。'); claimBtn.disabled = false; claimBtn.style.opacity = '1'; claimBtn.querySelector('.dl-main').innerText = '立即领取体验卡'; } } catch (error) { alert('系统繁忙,请稍后再试。'); claimBtn.disabled = false; claimBtn.style.opacity = '1'; claimBtn.querySelector('.dl-main').innerText = '立即领取体验卡'; } }; } if (codeDisplay) { codeDisplay.onclick = () => { const code = codeDisplay.innerText.trim(); if (!code || code === '---') return; navigator.clipboard.writeText(code).then(() => { // 1. 显示右上角 Toast 弹窗 (不改动卡号文字) let container = document.getElementById('toast-container'); if (!container) { container = document.createElement('div'); container.id = 'toast-container'; container.style.cssText = 'position: fixed; top: 20px; right: 20px; z-index: 10000; pointer-events: none;'; document.body.appendChild(container); } const toast = document.createElement('div'); toast.className = 'toast-msg'; toast.innerText = '✅ 卡密已复制到剪贴板'; container.appendChild(toast); // 2.5秒后自动移除弹窗 setTimeout(() => toast.remove(), 2500); // 2. 边框闪烁视觉反馈 (不改动文字内容) codeDisplay.style.borderColor = '#fff'; codeDisplay.style.boxShadow = '0 0 20px rgba(0, 242, 254, 0.4)'; setTimeout(() => { codeDisplay.style.borderColor = 'rgba(0, 242, 254, 0.4)'; codeDisplay.style.boxShadow = 'none'; }, 400); }).catch(err => { console.error('复制失败:', err); }); }; } }