ai_v/templates/base.html
24024 825f4fb4a9 feat(ocr): 新增验光单助手功能页面
- 在主应用路由中添加 /ocr 页面路由渲染 ocr.html
- 菜单中新增“验光单助手”入口,图标为 scan-eye,便于访问
- 在生成文本接口中支持聊天模型,处理 messages 内图片链接为 Base64
- 兼容 messages 为空场景,重构 payload 结构支持图片 Base64 传输
- 解析验光单请求不保存生成记录,避免污染历史数据
- 获取历史记录时过滤掉“解读验光单”的操作记录
- AI 接口配置新增 CHAT_API 地址,支持聊天模型调用

style(frontend): 优化首页图片展示与交互样式

- 缩小加载动画高度,调整提示文字为“AI 构思中...”
- 图片展示容器增加阴影和悬停放大效果,提升视觉体验
- 结果区域改为flex布局,支持滚动区域和固定底部操作栏
- 按钮圆角加大,阴影色调调整,增强交互反馈
- 引入 Tailwind typography 插件,提升排版一致性
- 静态资源由 CDN 改为本地引用避免外部依赖

docs(ui): 补充首页联系方式提示,优化用户导航

- 在用户个人信息区域新增客服 QQ 联系方式悬浮提示
- 调整首页初始占位状态布局,提升视觉层次感
- 细化按钮标签与图标增强可用性提示
2026-01-14 00:00:23 +08:00

169 lines
9.0 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}AI 视界{% endblock %}</title>
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
<script src="{{ url_for('static', filename='js/lucide.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/Sortable.min.js') }}"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
{% block head %}{% endblock %}
</head>
<body class="text-slate-700 antialiased bg-slate-50 overflow-hidden">
<div class="bg-mesh"></div>
<div id="toastContainer" class="toast-container"></div>
<div class="flex h-screen w-screen overflow-hidden">
<!-- 全局系统菜单栏 (默认隐藏,仅在 initGlobalNav 成功后显示) -->
<nav id="globalNav" class="hidden w-20 flex-shrink-0 bg-slate-900 flex flex-col items-center py-8 z-40 shadow-2xl transition-all duration-500">
<div class="w-12 h-12 btn-primary logo-box rounded-2xl flex items-center justify-center mb-12 rotate-3">
<i data-lucide="scan-eye" class="w-7 h-7"></i>
</div>
<div id="dynamicMenuList" class="flex-1 w-full px-2 space-y-4"></div>
<div id="globalUserProfile" class="flex flex-col items-center gap-4 mb-4">
<!-- 联系方式 -->
<div class="relative group flex justify-center mb-2">
<div class="w-10 h-10 bg-slate-800 rounded-xl flex items-center justify-center text-slate-400 border border-slate-700 hover:text-indigo-400 transition-colors cursor-help">
<i data-lucide="message-circle" class="w-5 h-5"></i>
</div>
<div class="absolute left-full ml-4 px-3 py-2 bg-slate-800 text-white text-[10px] font-black rounded-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all whitespace-nowrap z-50 shadow-xl border border-slate-700">
联系客服 QQ: 240241002
<div class="absolute right-full top-1/2 -translate-y-1/2 border-8 border-transparent border-r-slate-800"></div>
</div>
</div>
<div class="w-10 h-10 bg-slate-800 rounded-xl flex items-center justify-center text-slate-400 border border-slate-700">
<i data-lucide="user" class="w-5 h-5"></i>
</div>
<button id="globalLogoutBtn" class="text-slate-500 hover:text-rose-400 transition-colors">
<i data-lucide="log-out" class="w-5 h-5"></i>
</button>
</div>
</nav>
<!-- 主内容区域 (全屏) -->
<main class="flex-1 flex overflow-hidden relative w-full h-full">
{% block content %}{% endblock %}
</main>
</div>
<!-- 全局通知弹窗 -->
<div id="notifModal" class="fixed inset-0 bg-slate-900/60 backdrop-blur-md z-[60] flex items-center justify-center hidden opacity-0 transition-opacity duration-500">
<div class="bg-white w-full max-w-2xl rounded-[2.5rem] shadow-2xl p-10 space-y-6 transform scale-90 transition-transform duration-500">
<div class="w-16 h-16 bg-indigo-50 text-indigo-600 rounded-2xl flex items-center justify-center mx-auto mb-2">
<i data-lucide="bell-ring" class="w-8 h-8 animate-tada"></i>
</div>
<div class="text-center space-y-2">
<h2 id="notifTitle" class="text-2xl font-black text-slate-900">系统通知</h2>
<div id="notifContent" class="text-slate-500 text-sm font-bold leading-relaxed whitespace-pre-wrap"></div>
</div>
<button id="closeNotifBtn" class="w-full py-4 rounded-2xl bg-slate-900 text-white font-black text-sm hover:bg-slate-800 transition-all shadow-xl shadow-slate-200">
我已收到
</button>
</div>
</div>
<script>
lucide.createIcons();
// 自动加载菜单
async function initGlobalNav() {
try {
const r = await fetch('/api/auth/menu');
const d = await r.json();
if(d.menu && d.menu.length > 0) {
document.getElementById('globalNav').classList.remove('hidden');
const list = document.getElementById('dynamicMenuList');
list.innerHTML = d.menu.map(item => {
const isActive = window.location.pathname === item.url;
return `
<div class="relative group flex justify-center">
<a href="${item.url}"
class="w-12 h-12 flex items-center justify-center rounded-2xl transition-all duration-300 ${
isActive
? 'bg-indigo-600 text-white shadow-lg shadow-indigo-500/40'
: 'text-slate-500 hover:bg-slate-800 hover:text-white'
}">
<i data-lucide="${item.icon}" class="w-5 h-5"></i>
</a>
<div class="absolute left-full ml-4 px-3 py-2 bg-slate-800 text-white text-[10px] font-black rounded-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all whitespace-nowrap z-50 shadow-xl">
${item.name}
<div class="absolute right-full top-1/2 -translate-y-1/2 border-8 border-transparent border-r-slate-800"></div>
</div>
</div>
`;
}).join('');
lucide.createIcons();
}
} catch(e) { console.error('菜单加载失败', e); }
}
document.getElementById('globalLogoutBtn').onclick = async () => {
await fetch('/api/auth/logout', { method: 'POST' });
window.location.href = '/login';
};
// 全局通知检查
let currentNotifId = null;
async function checkNotifications() {
try {
const r = await fetch('/api/notifications/latest');
const d = await r.json();
if (d.id) {
currentNotifId = d.id;
document.getElementById('notifTitle').innerText = d.title;
document.getElementById('notifContent').innerText = d.content;
const modal = document.getElementById('notifModal');
modal.classList.remove('hidden');
setTimeout(() => {
modal.classList.add('opacity-100');
modal.querySelector('div').classList.remove('scale-90');
}, 10);
}
} catch (e) { console.error('通知检查失败', e); }
}
document.getElementById('closeNotifBtn').onclick = async () => {
if (!currentNotifId) return;
// 立即隐藏
const modal = document.getElementById('notifModal');
modal.classList.remove('opacity-100');
modal.querySelector('div').classList.add('scale-90');
setTimeout(() => {
modal.classList.add('hidden');
// 递归检查是否有下一条通知
checkNotifications();
}, 500);
// 后端同步已读
await fetch('/api/notifications/read', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id: currentNotifId })
});
};
initGlobalNav();
checkNotifications();
function showToast(message, type = 'info') {
const container = document.getElementById('toastContainer');
const toast = document.createElement('div');
toast.className = `toast ${type}`;
const colors = { success: 'text-emerald-500', error: 'text-rose-500', warning: 'text-amber-500', info: 'text-indigo-500' };
const icons = { success: 'check-circle', error: 'x-circle', warning: 'alert-triangle', info: 'info' };
toast.innerHTML = `<i data-lucide="${icons[type]}" class="w-5 h-5 ${colors[type]} flex-shrink-0"></i><span class="text-sm font-medium text-slate-700">${message}</span>`;
container.appendChild(toast);
lucide.createIcons();
setTimeout(() => { toast.style.animation = 'slideOutRight 0.3s ease-in'; setTimeout(() => toast.remove(), 300); }, 3000);
}
</script>
{% block scripts %}{% endblock %}
</body>
</html>