Files
insightflow/frontend/index.html
2026-02-17 18:34:09 +08:00

305 lines
9.3 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>InsightFlow - 项目管理</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0a0a0a;
color: #e0e0e0;
min-height: 100vh;
}
.header {
height: 60px;
background: #111;
border-bottom: 1px solid #222;
display: flex;
align-items: center;
padding: 0 40px;
justify-content: space-between;
}
.header h1 {
font-size: 1.5rem;
background: linear-gradient(90deg, #00d4ff, #7b2cbf);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 40px;
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
}
.toolbar h2 {
font-size: 1.2rem;
color: #888;
}
.btn {
background: linear-gradient(90deg, #00d4ff, #7b2cbf);
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 0.95rem;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
}
.btn:hover {
opacity: 0.9;
}
.project-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
}
.project-card {
background: #141414;
border: 1px solid #222;
border-radius: 12px;
padding: 24px;
cursor: pointer;
transition: all 0.2s;
}
.project-card:hover {
border-color: #00d4ff;
transform: translateY(-2px);
}
.project-card h3 {
font-size: 1.1rem;
margin-bottom: 8px;
color: #fff;
}
.project-card p {
color: #666;
font-size: 0.9rem;
line-height: 1.5;
margin-bottom: 16px;
}
.project-meta {
display: flex;
gap: 16px;
font-size: 0.8rem;
color: #888;
}
.project-meta span {
display: flex;
align-items: center;
gap: 4px;
}
.empty-state {
text-align: center;
padding: 80px 20px;
}
.empty-state h3 {
color: #666;
margin-bottom: 20px;
}
/* Modal */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.8);
display: none;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modal-overlay.show {
display: flex;
}
.modal {
background: #1a1a1a;
border-radius: 12px;
padding: 32px;
width: 100%;
max-width: 480px;
}
.modal h3 {
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #888;
font-size: 0.9rem;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 12px;
background: #0a0a0a;
border: 1px solid #333;
border-radius: 8px;
color: #fff;
font-size: 0.95rem;
}
.form-group input:focus,
.form-group textarea:focus {
outline: none;
border-color: #00d4ff;
}
.modal-actions {
display: flex;
gap: 12px;
justify-content: flex-end;
}
.btn-secondary {
background: transparent;
border: 1px solid #444;
color: #888;
padding: 12px 24px;
border-radius: 8px;
cursor: pointer;
}
.btn-secondary:hover {
border-color: #666;
color: #fff;
}
</style>
</head>
<body>
<div class="header">
<h1>📁 InsightFlow 项目管理</h1>
<a href="/workbench.html" style="color:#666;text-decoration:none;">进入工作台 →</a>
</div>
<div class="container">
<div class="toolbar">
<h2>我的项目</h2>
<button class="btn" onclick="showModal()">
<span>+</span> 新建项目
</button>
</div>
<div id="projectList" class="project-grid">
<!-- Projects loaded here -->
</div>
</div>
<!-- Create Project Modal -->
<div class="modal-overlay" id="modal">
<div class="modal">
<h3>新建项目</h3>
<div class="form-group">
<label>项目名称</label>
<input type="text" id="projectName" placeholder="输入项目名称">
</div>
<div class="form-group">
<label>项目描述</label>
<textarea id="projectDesc" rows="3" placeholder="简要描述项目内容"></textarea>
</div>
<div class="modal-actions">
<button class="btn-secondary" onclick="hideModal()">取消</button>
<button class="btn" onclick="createProject()">创建</button>
</div>
</div>
</div>
<script>
const API_BASE = '/api/v1';
// Load projects on page load
document.addEventListener('DOMContentLoaded', loadProjects);
async function loadProjects() {
try {
const res = await fetch(`${API_BASE}/projects`);
if (!res.ok) throw new Error('Failed to load');
const projects = await res.json();
const container = document.getElementById('projectList');
if (projects.length === 0) {
container.innerHTML = `
<div class="empty-state">
<h3>暂无项目,创建第一个项目开始吧</h3>
<button class="btn" onclick="showModal()">创建项目</button>
</div>
`;
return;
}
container.innerHTML = projects.map(p => `
<div class="project-card" onclick="enterProject('${p.id}')">
<h3>${p.name}</h3>
<p>${p.description || '暂无描述'}</p>
<div class="project-meta">
<span>📅 ${new Date(p.created_at).toLocaleDateString()}</span>
</div>
</div>
`).join('');
} catch (err) {
console.error('Load failed:', err);
document.getElementById('projectList').innerHTML = '
<div class="empty-state"><h3>加载失败,请刷新重试</h3></div>
';
}
}
function showModal() {
document.getElementById('modal').classList.add('show');
}
function hideModal() {
document.getElementById('modal').classList.remove('show');
document.getElementById('projectName').value = '';
document.getElementById('projectDesc').value = '';
}
async function createProject() {
const name = document.getElementById('projectName').value.trim();
const desc = document.getElementById('projectDesc').value.trim();
if (!name) {
alert('请输入项目名称');
return;
}
try {
const res = await fetch(`${API_BASE}/projects`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, description: desc })
});
if (!res.ok) throw new Error('Create failed');
hideModal();
loadProjects();
} catch (err) {
alert('创建失败: ' + err.message);
}
}
function enterProject(projectId) {
// Store selected project and redirect to workbench
localStorage.setItem('currentProject', projectId);
window.location.href = '/workbench.html';
}
// Close modal on overlay click
document.getElementById('modal').addEventListener('click', (e) => {
if (e.target.id === 'modal') hideModal();
});
</script>
</body>
</html>