a594f54cd2
- 全站品牌替换:DAEL / Design AI & Ecology Lab → TeaLab / SI · 空间智能与自主设计 * 11 个 HTML 页面 title、navbar、页脚、版权统一更新 * Logo 字母 D → T,配色与版式不变 * js/common.js 注释 + localStorage 计数键更新 * backend/app.py /api/health 文案更新 - website.html 内容重写 * Hero 改为"空间智能 & 自主设计",加序言两行 + 英文 mission * 使命段改为研究主线(感知→理解→推理闭环) * 研究方向三卡:自主设计 / 深邃之形 / 人本智能(含工具栈) - research.html 拆分 * 原 research.html(研究管理后台)重命名为 research-manage.html * 新建公开 research.html:研究定位 + 完整段落 + 概念对比表 + 研究维度表 - 基础设施调整 * 后端端口 5000 → 5001(避开本机 zotero-proxy 占用) * start_backend.sh 加可执行位 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
157 lines
4.1 KiB
JavaScript
157 lines
4.1 KiB
JavaScript
// Common JavaScript Functions for TeaLab · 空间智能与自主设计
|
|
|
|
// Initialize Lucide Icons
|
|
function initIcons() {
|
|
if (window.lucide) {
|
|
lucide.createIcons();
|
|
} else {
|
|
console.warn("Lucide icons failed to load.");
|
|
}
|
|
}
|
|
|
|
// Mobile Menu Toggle
|
|
function initMobileMenu() {
|
|
const menuBtn = document.getElementById('mobile-menu-btn');
|
|
const mobileMenu = document.getElementById('mobile-menu');
|
|
|
|
if (menuBtn && mobileMenu) {
|
|
menuBtn.addEventListener('click', () => {
|
|
mobileMenu.classList.toggle('hidden');
|
|
});
|
|
}
|
|
}
|
|
|
|
// Navbar scroll effect
|
|
function initNavbarScroll() {
|
|
window.addEventListener('scroll', () => {
|
|
const nav = document.getElementById('navbar');
|
|
if (nav) {
|
|
if (window.scrollY > 50) {
|
|
nav.classList.add('shadow-sm');
|
|
if (nav.classList.contains('h-20')) {
|
|
nav.classList.replace('h-20', 'h-16');
|
|
}
|
|
} else {
|
|
nav.classList.remove('shadow-sm');
|
|
if (nav.classList.contains('h-16')) {
|
|
nav.classList.replace('h-16', 'h-20');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Canvas Animation: Organic Connection Nodes
|
|
function initCanvasAnimation() {
|
|
const canvas = document.getElementById('heroCanvas');
|
|
if (!canvas) return;
|
|
|
|
const ctx = canvas.getContext('2d');
|
|
let width, height;
|
|
let particles = [];
|
|
|
|
function resize() {
|
|
width = window.innerWidth;
|
|
height = window.innerHeight;
|
|
canvas.width = width;
|
|
canvas.height = height;
|
|
}
|
|
|
|
class Particle {
|
|
constructor() {
|
|
this.x = Math.random() * width;
|
|
this.y = Math.random() * height;
|
|
this.vx = (Math.random() - 0.5) * 0.5;
|
|
this.vy = (Math.random() - 0.5) * 0.5;
|
|
this.size = Math.random() * 2 + 1;
|
|
}
|
|
|
|
update() {
|
|
this.x += this.vx;
|
|
this.y += this.vy;
|
|
|
|
if (this.x < 0 || this.x > width) this.vx *= -1;
|
|
if (this.y < 0 || this.y > height) this.vy *= -1;
|
|
}
|
|
|
|
draw() {
|
|
ctx.beginPath();
|
|
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
|
ctx.fill();
|
|
}
|
|
}
|
|
|
|
function initParticles() {
|
|
particles = [];
|
|
const particleCount = Math.min(window.innerWidth / 10, 100);
|
|
for (let i = 0; i < particleCount; i++) {
|
|
particles.push(new Particle());
|
|
}
|
|
}
|
|
|
|
function animate() {
|
|
ctx.clearRect(0, 0, width, height);
|
|
|
|
for (let i = 0; i < particles.length; i++) {
|
|
particles[i].update();
|
|
particles[i].draw();
|
|
|
|
for (let j = i + 1; j < particles.length; j++) {
|
|
const dx = particles[i].x - particles[j].x;
|
|
const dy = particles[i].y - particles[j].y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
if (dist < 150) {
|
|
ctx.beginPath();
|
|
ctx.strokeStyle = `rgba(0, 0, 0, ${0.05 - dist/3000})`;
|
|
ctx.lineWidth = 0.5;
|
|
ctx.moveTo(particles[i].x, particles[i].y);
|
|
ctx.lineTo(particles[j].x, particles[j].y);
|
|
ctx.stroke();
|
|
}
|
|
}
|
|
}
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
window.addEventListener('resize', () => {
|
|
resize();
|
|
initParticles();
|
|
});
|
|
|
|
resize();
|
|
initParticles();
|
|
animate();
|
|
}
|
|
|
|
// Visit Counter
|
|
function initVisitCounter() {
|
|
const counterElement = document.getElementById('visit-counter');
|
|
if (!counterElement) return;
|
|
|
|
let count = parseInt(localStorage.getItem('tealab_visit_count') || '0');
|
|
count++;
|
|
localStorage.setItem('tealab_visit_count', count.toString());
|
|
counterElement.textContent = count.toLocaleString();
|
|
}
|
|
|
|
// Initialize all common functions
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
initIcons();
|
|
initMobileMenu();
|
|
initNavbarScroll();
|
|
initCanvasAnimation();
|
|
initVisitCounter();
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|