305 lines
10 KiB
HTML
Executable File
305 lines
10 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;
|
|
}
|
|
@media (max-width: 768px) {
|
|
.grid-2 {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
</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] = await Promise.all([
|
|
fetch(`${API_BASE}/entries/stats/`),
|
|
fetch(`${API_BASE}/entries/recent/`),
|
|
fetch(`${API_BASE}/experiences/stats/`),
|
|
fetch(`${API_BASE}/experiences/recent/`)
|
|
]);
|
|
|
|
const stats = await statsRes.json();
|
|
const entries = await entriesRes.json();
|
|
const expStats = await expStatsRes.json();
|
|
const experiences = await experiencesRes.json();
|
|
|
|
render(stats, entries, expStats, experiences);
|
|
} catch (error) {
|
|
document.getElementById('app').innerHTML = `
|
|
<div class="error">加载失败:${error.message}</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
function render(stats, entries, expStats, experiences) {
|
|
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>${expStats.total_experiences || 0}</h3>
|
|
<p>经验总结</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>${stats.first_entry || '-'}</h3>
|
|
<p>第一天</p>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>${stats.latest_entry || '-'}</h3>
|
|
<p>最新日记</p>
|
|
</div>
|
|
</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>
|