- 新增 Task 模型(状态、优先级、进展百分比) - 任务 API(列表、统计、进展更新、完成标记) - 前端任务板块(统计卡片 + 任务列表) - 进展可视化(进度条 + 进展记录)
410 lines
15 KiB
HTML
Executable File
410 lines
15 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>码神的日记系统</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
.container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
header {
|
|
text-align: center;
|
|
color: white;
|
|
margin-bottom: 30px;
|
|
}
|
|
header h1 {
|
|
font-size: 2.5em;
|
|
margin-bottom: 10px;
|
|
}
|
|
header p {
|
|
opacity: 0.9;
|
|
}
|
|
.stats {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 30px;
|
|
}
|
|
.stat-card {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
text-align: center;
|
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
}
|
|
.stat-card h3 {
|
|
color: #667eea;
|
|
font-size: 2em;
|
|
margin-bottom: 5px;
|
|
}
|
|
.stat-card p {
|
|
color: #666;
|
|
}
|
|
.section-box {
|
|
background: white;
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
margin-bottom: 30px;
|
|
}
|
|
.section-box h2 {
|
|
color: #333;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 2px solid #667eea;
|
|
}
|
|
.diary-item {
|
|
padding: 15px;
|
|
border-left: 4px solid #667eea;
|
|
background: #f8f9fa;
|
|
margin-bottom: 15px;
|
|
border-radius: 5px;
|
|
}
|
|
.diary-item h3 {
|
|
color: #333;
|
|
margin-bottom: 10px;
|
|
}
|
|
.diary-item .date {
|
|
color: #667eea;
|
|
font-weight: bold;
|
|
margin-bottom: 10px;
|
|
}
|
|
.diary-item .section {
|
|
margin: 10px 0;
|
|
}
|
|
.diary-item .section-title {
|
|
font-weight: bold;
|
|
color: #555;
|
|
}
|
|
.diary-item .section-content {
|
|
color: #666;
|
|
margin-left: 20px;
|
|
white-space: pre-wrap;
|
|
}
|
|
.experience-item {
|
|
padding: 15px;
|
|
border-left: 4px solid #f59e0b;
|
|
background: #fffbeb;
|
|
margin-bottom: 15px;
|
|
border-radius: 5px;
|
|
}
|
|
.experience-item .header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 10px;
|
|
}
|
|
.experience-item .title {
|
|
font-weight: bold;
|
|
color: #333;
|
|
font-size: 1.1em;
|
|
}
|
|
.experience-item .category {
|
|
background: #f59e0b;
|
|
color: white;
|
|
padding: 4px 12px;
|
|
border-radius: 20px;
|
|
font-size: 0.85em;
|
|
}
|
|
.experience-item .problem {
|
|
margin: 10px 0;
|
|
}
|
|
.experience-item .problem-title {
|
|
font-weight: bold;
|
|
color: #dc2626;
|
|
margin-bottom: 5px;
|
|
}
|
|
.experience-item .solution {
|
|
margin: 10px 0;
|
|
}
|
|
.experience-item .solution-title {
|
|
font-weight: bold;
|
|
color: #059669;
|
|
margin-bottom: 5px;
|
|
}
|
|
.experience-item .lesson {
|
|
margin: 10px 0;
|
|
padding: 10px;
|
|
background: #fef3c7;
|
|
border-radius: 5px;
|
|
}
|
|
.experience-item .lesson-title {
|
|
font-weight: bold;
|
|
color: #92400e;
|
|
margin-bottom: 5px;
|
|
}
|
|
.loading {
|
|
text-align: center;
|
|
padding: 40px;
|
|
color: white;
|
|
font-size: 1.2em;
|
|
}
|
|
.error {
|
|
background: #fee;
|
|
color: #c00;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.emoji {
|
|
font-size: 1.2em;
|
|
}
|
|
.grid-2 {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
|
|
gap: 30px;
|
|
}
|
|
.grid-3 {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
|
|
gap: 30px;
|
|
}
|
|
@media (max-width: 768px) {
|
|
.grid-2, .grid-3 {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
.task-item {
|
|
padding: 15px;
|
|
border-left: 4px solid #667eea;
|
|
background: #f8f9fa;
|
|
margin-bottom: 15px;
|
|
border-radius: 5px;
|
|
}
|
|
.task-item.status-pending { border-left-color: #6b7280; }
|
|
.task-item.status-in_progress { border-left-color: #3b82f6; }
|
|
.task-item.status-blocked { border-left-color: #f59e0b; }
|
|
.task-item.status-completed { border-left-color: #10b981; }
|
|
.task-item.status-cancelled { border-left-color: #ef4444; opacity: 0.6; }
|
|
.task-item .header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 10px;
|
|
}
|
|
.task-item .title {
|
|
font-weight: bold;
|
|
color: #333;
|
|
font-size: 1.1em;
|
|
}
|
|
.task-item .status {
|
|
padding: 4px 12px;
|
|
border-radius: 20px;
|
|
font-size: 0.85em;
|
|
color: white;
|
|
}
|
|
.status-pending .status { background: #6b7280; }
|
|
.status-in_progress .status { background: #3b82f6; }
|
|
.status-blocked .status { background: #f59e0b; }
|
|
.status-completed .status { background: #10b981; }
|
|
.status-cancelled .status { background: #ef4444; }
|
|
.task-item .priority {
|
|
font-size: 0.8em;
|
|
color: #666;
|
|
margin-bottom: 8px;
|
|
}
|
|
.task-item .progress-bar {
|
|
height: 8px;
|
|
background: #e5e7eb;
|
|
border-radius: 4px;
|
|
overflow: hidden;
|
|
margin: 10px 0;
|
|
}
|
|
.task-item .progress-fill {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, #667eea, #764ba2);
|
|
transition: width 0.3s;
|
|
}
|
|
.task-item .progress-text {
|
|
font-size: 0.85em;
|
|
color: #666;
|
|
text-align: right;
|
|
}
|
|
.task-item .description {
|
|
color: #666;
|
|
margin: 10px 0;
|
|
white-space: pre-wrap;
|
|
}
|
|
.task-item .progress-notes {
|
|
background: #fef3c7;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
font-size: 0.85em;
|
|
color: #92400e;
|
|
white-space: pre-wrap;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<h1>⚡ 码神的日记系统</h1>
|
|
<p>记录每天的进步与成长</p>
|
|
</header>
|
|
|
|
<div id="app">
|
|
<div class="loading">加载中...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const API_BASE = '/api';
|
|
|
|
async function loadDiary() {
|
|
try {
|
|
const [statsRes, entriesRes, expStatsRes, experiencesRes, taskStatsRes, tasksRes] = await Promise.all([
|
|
fetch(`${API_BASE}/entries/stats/`),
|
|
fetch(`${API_BASE}/entries/recent/`),
|
|
fetch(`${API_BASE}/experiences/stats/`),
|
|
fetch(`${API_BASE}/experiences/recent/`),
|
|
fetch(`${API_BASE}/tasks/stats/`),
|
|
fetch(`${API_BASE}/tasks/active/`)
|
|
]);
|
|
|
|
const stats = await statsRes.json();
|
|
const entries = await entriesRes.json();
|
|
const expStats = await expStatsRes.json();
|
|
const experiences = await experiencesRes.json();
|
|
const taskStats = await taskStatsRes.json();
|
|
const tasks = await tasksRes.json();
|
|
|
|
render(stats, entries, expStats, experiences, taskStats, tasks);
|
|
} catch (error) {
|
|
document.getElementById('app').innerHTML = `
|
|
<div class="error">加载失败:${error.message}</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
function render(stats, entries, expStats, experiences, taskStats, tasks) {
|
|
const app = document.getElementById('app');
|
|
|
|
app.innerHTML = `
|
|
<div class="stats">
|
|
<div class="stat-card">
|
|
<h3>${stats.total_entries || 0}</h3>
|
|
<p>总日记数</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>${taskStats.total || 0}</h3>
|
|
<p>总任务</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>${taskStats.in_progress || 0}</h3>
|
|
<p>进行中</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>${taskStats.completed || 0}</h3>
|
|
<p>已完成</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>${taskStats.completion_rate || 0}%</h3>
|
|
<p>完成率</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>${expStats.total_experiences || 0}</h3>
|
|
<p>经验总结</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section-box" style="margin-bottom: 30px;">
|
|
<h2>📋 工作任务</h2>
|
|
${tasks.length === 0 ? '<p>暂无活跃任务</p>' : tasks.map(task => `
|
|
<div class="task-item status-${task.status}">
|
|
<div class="header">
|
|
<span class="title">${task.title}</span>
|
|
<span class="status">${task.status_display}</span>
|
|
</div>
|
|
<div class="priority">优先级:${task.priority_display} | 负责人:${task.assigned_to || '码神'}</div>
|
|
${task.description ? `<div class="description">${task.description}</div>` : ''}
|
|
<div class="progress-bar">
|
|
<div class="progress-fill" style="width: ${task.progress_percent}%"></div>
|
|
</div>
|
|
<div class="progress-text">进展:${task.progress_percent}%</div>
|
|
${task.progress_notes ? `<div class="progress-notes"><strong>进展记录:</strong><br>${task.progress_notes}</div>` : ''}
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
|
|
<div class="grid-2">
|
|
<div class="section-box">
|
|
<h2>📝 最近日记</h2>
|
|
${entries.length === 0 ? '<p>暂无日记</p>' : entries.map(entry => `
|
|
<div class="diary-item">
|
|
<div class="date">${entry.date}</div>
|
|
<h3>${entry.title || '每日日记'}</h3>
|
|
${entry.completed_tasks ? `
|
|
<div class="section">
|
|
<span class="section-title">✅ 完成的任务</span>
|
|
<div class="section-content">${entry.completed_tasks}</div>
|
|
</div>
|
|
` : ''}
|
|
${entry.learned ? `
|
|
<div class="section">
|
|
<span class="section-title">📚 学到的东西</span>
|
|
<div class="section-content">${entry.learned}</div>
|
|
</div>
|
|
` : ''}
|
|
${entry.reflections ? `
|
|
<div class="section">
|
|
<span class="section-title">💡 想法和反思</span>
|
|
<div class="section-content">${entry.reflections}</div>
|
|
</div>
|
|
` : ''}
|
|
${entry.improvements ? `
|
|
<div class="section">
|
|
<span class="section-title">📈 进步点</span>
|
|
<div class="section-content">${entry.improvements}</div>
|
|
</div>
|
|
` : ''}
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
|
|
<div class="section-box">
|
|
<h2>💡 经验总结</h2>
|
|
${experiences.length === 0 ? '<p>暂无经验总结</p>' : experiences.map(exp => `
|
|
<div class="experience-item">
|
|
<div class="header">
|
|
<span class="title">${exp.title}</span>
|
|
<span class="category">${exp.category}</span>
|
|
</div>
|
|
<div class="problem">
|
|
<div class="problem-title">🐛 问题</div>
|
|
<div class="section-content">${exp.problem}</div>
|
|
</div>
|
|
<div class="solution">
|
|
<div class="solution-title">✅ 解决方案</div>
|
|
<div class="section-content">${exp.solution}</div>
|
|
</div>
|
|
${exp.lesson_learned ? `
|
|
<div class="lesson">
|
|
<div class="lesson-title">📌 经验教训</div>
|
|
<div class="section-content">${exp.lesson_learned}</div>
|
|
</div>
|
|
` : ''}
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
loadDiary();
|
|
</script>
|
|
</body>
|
|
</html>
|