| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- // 填入 apkUrl 即可开放下载;版本信息等字段按需提供。channel 为渠道标注(如「测试版」),可空。
- const FMODE_SITE = { apkUrl: 'https://ai.fmode.cn/download/fmode-app-v1.0.apk', version: '1.0', fileSize: '9.9 MB', updatedAt: '2026-11-23', channel: '测试版' };
- const header = document.getElementById('header');
- const menuToggle = document.getElementById('menuToggle');
- const navLinks = document.getElementById('navLinks');
- const downloadDialog = document.getElementById('downloadDialog');
- const downloadStatus = document.getElementById('downloadStatus');
- const releaseMeta = document.getElementById('releaseMeta');
- const apkButton = document.getElementById('apkButton');
- const setMenuOpen = (open) => {
- menuToggle.setAttribute('aria-expanded', String(open));
- menuToggle.setAttribute('aria-label', open ? '收起导航' : '展开导航');
- menuToggle.innerHTML = '<svg class="icon"><use href="#' + (open ? 'i-close' : 'i-menu') + '"/></svg>';
- navLinks.classList.toggle('open', open);
- };
- menuToggle.addEventListener('click', () => setMenuOpen(menuToggle.getAttribute('aria-expanded') !== 'true'));
- navLinks.querySelectorAll('a').forEach((link) => link.addEventListener('click', () => setMenuOpen(false)));
- document.addEventListener('keydown', (event) => {
- if (event.key === 'Escape' && navLinks.classList.contains('open')) { setMenuOpen(false); menuToggle.focus(); }
- });
- let scrollQueued = false;
- window.addEventListener('scroll', () => {
- if (scrollQueued) return;
- scrollQueued = true;
- requestAnimationFrame(() => { header.classList.toggle('scrolled', window.scrollY > 8); scrollQueued = false; });
- }, { passive: true });
- const tabButtons = [...document.querySelectorAll('[role="tab"][data-scene]')];
- const scenes = [...document.querySelectorAll('[role="tabpanel"]')];
- const railItems = [...document.querySelectorAll('[data-rail]')];
- function activateScene(name, focusButton = false) {
- tabButtons.forEach((tab) => {
- const active = tab.dataset.scene === name;
- tab.setAttribute('aria-selected', String(active));
- tab.tabIndex = active ? 0 : -1;
- if (active && focusButton) tab.focus();
- });
- scenes.forEach((scene) => { scene.hidden = scene.id !== 'scene-' + name; });
- railItems.forEach((item) => item.classList.toggle('active', item.dataset.rail === name));
- }
- tabButtons.forEach((tab, index) => {
- tab.addEventListener('click', () => activateScene(tab.dataset.scene));
- tab.addEventListener('keydown', (event) => {
- if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
- event.preventDefault();
- let next = index;
- if (event.key === 'ArrowRight') next = (index + 1) % tabButtons.length;
- if (event.key === 'ArrowLeft') next = (index - 1 + tabButtons.length) % tabButtons.length;
- if (event.key === 'Home') next = 0;
- if (event.key === 'End') next = tabButtons.length - 1;
- activateScene(tabButtons[next].dataset.scene, true);
- });
- });
- const closeButton = document.getElementById('dialogClose');
- const confirmButton = document.getElementById('dialogConfirm');
- function closeDownloadDialog() { if (downloadDialog.open) downloadDialog.close(); apkButton.focus(); }
- closeButton.addEventListener('click', closeDownloadDialog);
- confirmButton.addEventListener('click', closeDownloadDialog);
- downloadDialog.addEventListener('click', (event) => { if (event.target === downloadDialog) closeDownloadDialog(); });
- function safeDownloadUrl(value) {
- if (!value) return null;
- try {
- const url = new URL(value, window.location.href);
- if (url.protocol === 'https:' || (url.protocol === 'file:' && value.startsWith('./'))) return url.href;
- } catch { return null; }
- return null;
- }
- const downloadUrl = safeDownloadUrl(FMODE_SITE.apkUrl);
- if (downloadUrl) {
- apkButton.href = downloadUrl;
- apkButton.removeAttribute('aria-describedby');
- apkButton.setAttribute('download', 'Fmode.apk');
- document.getElementById('downloadLabel').textContent = '下载 Android 安装包';
- downloadStatus.classList.add('ready');
- downloadStatus.innerHTML = '<i></i>官方 Android 安装包' + (FMODE_SITE.channel ? '(' + FMODE_SITE.channel + ')' : '') + ' · 下载已开放';
- const metadata = [FMODE_SITE.version && '版本 ' + FMODE_SITE.version, FMODE_SITE.fileSize, FMODE_SITE.updatedAt && '更新于 ' + FMODE_SITE.updatedAt].filter(Boolean);
- if (metadata.length) { releaseMeta.hidden = false; releaseMeta.textContent = metadata.join(' · '); }
- const heroBadge = document.querySelector('.hero-badge');
- heroBadge.replaceChildren(Object.assign(document.createElement('span'), { className: 'tiny-dot' }), document.createTextNode('Android 客户端现已开放下载'));
- document.querySelector('.nav-platform').setAttribute('aria-label', 'Android 版现已开放下载');
- document.getElementById('faqDownloadAnswer').textContent = 'Android 客户端现已开放下载。使用手机访问本页,点击下载按钮即可获取安装包;如在电脑访问,可将下载后的 APK 传至 Android 设备安装。';
- } else {
- apkButton.addEventListener('click', (event) => { event.preventDefault(); downloadDialog.showModal(); closeButton.focus(); });
- }
- const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
- if ('IntersectionObserver' in window && !reduceMotion.matches) {
- const observer = new IntersectionObserver((entries) => {
- entries.forEach((entry) => { if (!entry.isIntersecting) return; entry.target.classList.add('is-visible'); observer.unobserve(entry.target); });
- }, { threshold: 0.12, rootMargin: '0px 0px -35px 0px' });
- document.querySelectorAll('.feature-card, .start-grid article, .download-card, .faq-intro').forEach((item) => { item.classList.add('reveal'); observer.observe(item); });
- }
- const canvas = document.getElementById('atmosphere');
- const context = canvas.getContext('2d', { alpha: true });
- let particles = [];
- let animationFrame = 0;
- let canvasWidth = 0;
- let canvasHeight = 0;
- function resizeCanvas() {
- if (!context) return;
- const bounds = canvas.getBoundingClientRect();
- const ratio = Math.min(window.devicePixelRatio || 1, 1.5);
- canvasWidth = bounds.width;
- canvasHeight = bounds.height;
- canvas.width = Math.round(bounds.width * ratio);
- canvas.height = Math.round(bounds.height * ratio);
- context.setTransform(ratio, 0, 0, ratio, 0, 0);
- const count = Math.min(66, Math.max(28, Math.round(bounds.width * bounds.height / 18000)));
- particles = Array.from({ length: count }, () => ({ x: Math.random() * canvasWidth, y: Math.random() * canvasHeight, radius: Math.random() * 1.05 + .28, opacity: Math.random() * .38 + .09, speed: Math.random() * .13 + .035, phase: Math.random() * Math.PI * 2 }));
- }
- function drawAtmosphere() {
- if (!context || document.hidden || reduceMotion.matches) { animationFrame = 0; return; }
- context.clearRect(0, 0, canvasWidth, canvasHeight);
- const time = performance.now() * .00045;
- particles.forEach((particle) => {
- const twinkle = (Math.sin(time + particle.phase) + 1) * .5;
- context.beginPath();
- context.fillStyle = 'rgba(199, 255, 211, ' + particle.opacity * (.55 + twinkle * .45) + ')';
- context.arc(particle.x, particle.y, particle.radius, 0, Math.PI * 2);
- context.fill();
- particle.y -= particle.speed;
- if (particle.y < -2) { particle.y = canvasHeight + 2; particle.x = Math.random() * canvasWidth; }
- });
- animationFrame = window.requestAnimationFrame(drawAtmosphere);
- }
- function startAtmosphere() { if (!context || reduceMotion.matches || document.hidden || animationFrame) return; animationFrame = window.requestAnimationFrame(drawAtmosphere); }
- function stopAtmosphere() { if (animationFrame) window.cancelAnimationFrame(animationFrame); animationFrame = 0; }
- resizeCanvas();
- startAtmosphere();
- window.addEventListener('resize', () => { resizeCanvas(); startAtmosphere(); }, { passive: true });
- document.addEventListener('visibilitychange', () => document.hidden ? stopAtmosphere() : startAtmosphere());
- reduceMotion.addEventListener?.('change', () => reduceMotion.matches ? stopAtmosphere() : startAtmosphere());
|