feat: 完成全站UI优化 - 科技感/未来风设计
- 前台页面全面升级为Tailwind CSS框架 - 引入Google Fonts (Space Grotesk, Noto Sans) - 主色调更新为#25c0f4 (cyan blue) - 实现玻璃态效果和渐变背景 - 优化首页网格卡片布局和悬停动画 - 优化详情页双栏布局和渐变Logo光晕 - 优化管理员登录页,添加科技网格背景 - Flask-Admin后台完整深色主题 - 统一Material Symbols图标系统 - 网站自动抓取功能界面优化 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
121
static/js/main.js
Normal file
121
static/js/main.js
Normal file
@@ -0,0 +1,121 @@
|
||||
// 主要JavaScript功能
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// 初始化所有功能
|
||||
initCardAnimations();
|
||||
initExternalLinks();
|
||||
initTooltips();
|
||||
});
|
||||
|
||||
/**
|
||||
* 卡片动画效果
|
||||
*/
|
||||
function initCardAnimations() {
|
||||
const cards = document.querySelectorAll('.site-card');
|
||||
|
||||
cards.forEach((card, index) => {
|
||||
// 添加延迟动画效果
|
||||
card.style.animationDelay = `${index * 0.05}s`;
|
||||
|
||||
// 点击卡片查看详情
|
||||
card.addEventListener('click', function(e) {
|
||||
// 如果点击的是按钮,不触发卡片点击
|
||||
if (e.target.tagName === 'A' || e.target.closest('a')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 找到"查看详情"按钮并触发点击
|
||||
const detailBtn = card.querySelector('a[href*="site_detail"]');
|
||||
if (detailBtn) {
|
||||
window.location.href = detailBtn.href;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部链接处理
|
||||
*/
|
||||
function initExternalLinks() {
|
||||
const externalLinks = document.querySelectorAll('a[target="_blank"]');
|
||||
|
||||
externalLinks.forEach(link => {
|
||||
// 添加安全属性
|
||||
link.setAttribute('rel', 'noopener noreferrer');
|
||||
|
||||
// 添加点击统计(可选)
|
||||
link.addEventListener('click', function() {
|
||||
console.log('External link clicked:', this.href);
|
||||
// 这里可以添加统计代码
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化Bootstrap提示框
|
||||
*/
|
||||
function initTooltips() {
|
||||
const tooltipTriggerList = [].slice.call(
|
||||
document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
||||
);
|
||||
tooltipTriggerList.map(function(tooltipTriggerEl) {
|
||||
return new bootstrap.Tooltip(tooltipTriggerEl);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 平滑滚动到顶部
|
||||
*/
|
||||
function scrollToTop() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示加载动画
|
||||
*/
|
||||
function showLoading() {
|
||||
const loader = document.createElement('div');
|
||||
loader.id = 'loading';
|
||||
loader.className = 'loading-overlay';
|
||||
loader.innerHTML = '<div class="spinner-border text-primary" role="status"></div>';
|
||||
document.body.appendChild(loader);
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏加载动画
|
||||
*/
|
||||
function hideLoading() {
|
||||
const loader = document.getElementById('loading');
|
||||
if (loader) {
|
||||
loader.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示通知消息
|
||||
*/
|
||||
function showNotification(message, type = 'info') {
|
||||
const alert = document.createElement('div');
|
||||
alert.className = `alert alert-${type} alert-dismissible fade show position-fixed top-0 start-50 translate-middle-x mt-3`;
|
||||
alert.style.zIndex = '9999';
|
||||
alert.innerHTML = `
|
||||
${message}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
`;
|
||||
|
||||
document.body.appendChild(alert);
|
||||
|
||||
// 3秒后自动关闭
|
||||
setTimeout(() => {
|
||||
alert.remove();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 导出函数供全局使用
|
||||
window.scrollToTop = scrollToTop;
|
||||
window.showLoading = showLoading;
|
||||
window.hideLoading = hideLoading;
|
||||
window.showNotification = showNotification;
|
||||
Reference in New Issue
Block a user