You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

388 lines
12 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我的Git日记本</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}
body {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
padding: 20px;
color: #333;
}
.container {
max-width: 900px;
margin: 0 auto;
background: white;
border-radius: 12px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
header {
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
color: white;
padding: 25px 30px;
text-align: center;
}
h1 {
font-size: 2.2rem;
margin-bottom: 10px;
}
.subtitle {
font-size: 1rem;
opacity: 0.9;
}
.main-content {
display: flex;
min-height: 500px;
}
.sidebar {
width: 250px;
background: #f8f9fa;
border-right: 1px solid #eaeaea;
padding: 20px;
}
.diary-list {
list-style: none;
}
.diary-item {
padding: 12px 15px;
margin-bottom: 8px;
background: white;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s;
border-left: 4px solid #6a11cb;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.diary-item:hover {
background: #eef4ff;
transform: translateX(3px);
}
.diary-item.active {
background: #e6f0ff;
border-left: 4px solid #2575fc;
}
.diary-date {
font-weight: 600;
font-size: 0.9rem;
}
.diary-preview {
font-size: 0.8rem;
color: #666;
margin-top: 5px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.editor-container {
flex: 1;
padding: 25px;
display: flex;
flex-direction: column;
}
.date-picker {
margin-bottom: 20px;
}
#diary-date {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 1rem;
}
#diary-title {
width: 100%;
padding: 12px 15px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 1.2rem;
margin-bottom: 15px;
font-weight: 600;
}
#diary-content {
flex: 1;
padding: 15px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 1rem;
line-height: 1.6;
resize: none;
margin-bottom: 20px;
}
.actions {
display: flex;
gap: 10px;
}
button {
padding: 10px 20px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: 600;
transition: all 0.3s;
}
#save-btn {
background: #4CAF50;
color: white;
}
#save-btn:hover {
background: #45a049;
transform: translateY(-2px);
}
#new-btn {
background: #2196F3;
color: white;
}
#new-btn:hover {
background: #0b7dda;
transform: translateY(-2px);
}
#delete-btn {
background: #f44336;
color: white;
}
#delete-btn:hover {
background: #da190b;
transform: translateY(-2px);
}
.git-guide {
background: #f1f8ff;
border-top: 1px solid #e1e4e8;
padding: 20px 30px;
}
.git-guide h2 {
color: #0366d6;
margin-bottom: 15px;
font-size: 1.4rem;
}
.git-steps {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
}
.step {
background: white;
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.step-number {
display: inline-block;
width: 25px;
height: 25px;
background: #0366d6;
color: white;
border-radius: 50%;
text-align: center;
line-height: 25px;
margin-right: 10px;
font-weight: bold;
}
.step-title {
font-weight: 600;
margin-bottom: 8px;
}
.step-desc {
font-size: 0.9rem;
color: #555;
}
footer {
text-align: center;
padding: 15px;
color: #666;
font-size: 0.9rem;
border-top: 1px solid #eaeaea;
}
@media (max-width: 768px) {
.main-content {
flex-direction: column;
}
.sidebar {
width: 100%;
border-right: none;
border-bottom: 1px solid #eaeaea;
}
.git-steps {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>我的Git日记本</h1>
<p class="subtitle">记录生活点滴,学习版本控制</p>
</header>
<div class="main-content">
<div class="sidebar">
<h3>日记列表</h3>
<ul class="diary-list">
<li class="diary-item active">
<div class="diary-date">2023-10-15</div>
<div class="diary-preview">今天开始学习Git版本控制...</div>
</li>
<li class="diary-item">
<div class="diary-date">2023-10-14</div>
<div class="diary-preview">完成了第一个网页项目,感觉很有成就感...</div>
</li>
<li class="diary-item">
<div class="diary-date">2023-10-12</div>
<div class="diary-preview">阅读了一篇关于前端框架的文章...</div>
</li>
</ul>
</div>
<div class="editor-container">
<div class="date-picker">
<input type="date" id="diary-date" value="2023-10-15">
</div>
<input type="text" id="diary-title" placeholder="日记标题" value="开始Git日记本项目">
<textarea id="diary-content" placeholder="记录今天的点滴...">今天我开始使用Git来管理我的日记本项目。这是一个很好的练习方式既能记录生活又能学习版本控制。
我计划每天写一点代码同时记录学习心得。这样我就可以通过Git来追踪我的进步过程。
Git的基本命令
- git init: 初始化仓库
- git add: 添加文件到暂存区
- git commit: 提交更改
- git log: 查看提交历史</textarea>
<div class="actions">
<button id="save-btn">保存日记</button>
<button id="new-btn">新建日记</button>
<button id="delete-btn">删除日记</button>
</div>
</div>
</div>
<div class="git-guide">
<h2>Git使用指南</h2>
<div class="git-steps">
<div class="step">
<div class="step-title"><span class="step-number">1</span>初始化仓库</div>
<div class="step-desc">在项目文件夹中打开终端,运行 git init 命令初始化Git仓库。</div>
</div>
<div class="step">
<div class="step-title"><span class="step-number">2</span>添加文件</div>
<div class="step-desc">使用 git add . 命令添加所有文件到暂存区,准备提交。</div>
</div>
<div class="step">
<div class="step-title"><span class="step-number">3</span>提交更改</div>
<div class="step-desc">使用 git commit -m "提交信息" 命令提交更改到仓库。</div>
</div>
<div class="step">
<div class="step-title"><span class="step-number">4</span>查看历史</div>
<div class="step-desc">使用 git log 命令查看提交历史,了解项目演变过程。</div>
</div>
</div>
</div>
<footer>
<p>Git日记本 - 通过实践学习版本控制 | 建议每天提交日记记录学习进度</p>
</footer>
</div>
<script>
// 简单的日记功能实现
document.addEventListener('DOMContentLoaded', function() {
const diaryItems = document.querySelectorAll('.diary-item');
const diaryDate = document.getElementById('diary-date');
const diaryTitle = document.getElementById('diary-title');
const diaryContent = document.getElementById('diary-content');
const saveBtn = document.getElementById('save-btn');
const newBtn = document.getElementById('new-btn');
const deleteBtn = document.getElementById('delete-btn');
// 日记点击事件
diaryItems.forEach(item => {
item.addEventListener('click', function() {
diaryItems.forEach(i => i.classList.remove('active'));
this.classList.add('active');
// 在实际应用中,这里会从存储中加载日记内容
diaryDate.value = this.querySelector('.diary-date').textContent;
diaryTitle.value = "已加载的日记标题";
diaryContent.value = "这是从存储中加载的日记内容...";
});
});
// 保存日记
saveBtn.addEventListener('click', function() {
alert('日记已保存!在实际应用中,这里会将数据保存到本地存储或后端。');
// 实际应用中这里会有保存逻辑
});
// 新建日记
newBtn.addEventListener('click', function() {
const today = new Date();
const formattedDate = today.toISOString().split('T')[0];
diaryDate.value = formattedDate;
diaryTitle.value = "";
diaryContent.value = "";
// 取消所有日记的选中状态
diaryItems.forEach(i => i.classList.remove('active'));
alert('新建日记已准备!开始记录今天的生活吧。');
});
// 删除日记
deleteBtn.addEventListener('click', function() {
if (confirm('确定要删除这篇日记吗?此操作不可撤销。')) {
alert('日记已删除!在实际应用中,这里会从存储中删除数据。');
// 实际应用中这里会有删除逻辑
}
});
});
</script>
</body>
</html>