Files
schedule-planner/capture.html
2026-04-06 13:46:31 +00:00

317 lines
7.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="随手记">
<meta name="theme-color" content="#667eea">
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="apple-touch-icon" href="icon-192.png">
<link rel="manifest" href="manifest.json">
<title>随手记</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: #667eea;
min-height: 100vh;
min-height: 100dvh;
display: flex;
flex-direction: column;
padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.top {
padding: 20px 20px 0;
flex-shrink: 0;
}
.greeting {
color: rgba(255,255,255,0.7);
font-size: 13px;
margin-bottom: 4px;
}
.title {
color: white;
font-size: 20px;
font-weight: 600;
margin-bottom: 16px;
}
.input-area {
position: relative;
}
textarea {
width: 100%;
min-height: 100px;
padding: 16px;
padding-right: 16px;
border: none;
border-radius: 16px;
font-size: 16px;
font-family: inherit;
outline: none;
resize: none;
background: white;
color: #333;
line-height: 1.6;
box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
textarea::placeholder { color: #bbb; }
.tags {
display: flex;
gap: 8px;
margin-top: 12px;
flex-wrap: wrap;
}
.tag-btn {
padding: 8px 16px;
border-radius: 20px;
border: 1.5px solid rgba(255,255,255,0.3);
background: rgba(255,255,255,0.1);
color: white;
font-size: 13px;
cursor: pointer;
transition: all 0.15s;
-webkit-tap-highlight-color: transparent;
}
.tag-btn:active { transform: scale(0.95); }
.tag-btn.active {
background: white;
color: #667eea;
border-color: white;
font-weight: 600;
}
.save-btn {
margin-top: 14px;
width: 100%;
padding: 14px;
border: none;
border-radius: 14px;
background: white;
color: #667eea;
font-size: 16px;
font-weight: 600;
cursor: pointer;
font-family: inherit;
transition: all 0.15s;
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
-webkit-tap-highlight-color: transparent;
}
.save-btn:active { transform: scale(0.97); opacity: 0.9; }
.save-btn:disabled { opacity: 0.4; }
/* 成功反馈 */
.toast {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0.8);
background: rgba(0,0,0,0.8);
color: white;
padding: 20px 32px;
border-radius: 16px;
font-size: 15px;
font-weight: 500;
opacity: 0;
pointer-events: none;
transition: all 0.3s;
text-align: center;
}
.toast.show {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.toast .toast-icon { font-size: 32px; display: block; margin-bottom: 6px; }
/* 最近记录 */
.recent {
flex: 1;
padding: 20px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.recent-title {
color: rgba(255,255,255,0.5);
font-size: 12px;
font-weight: 500;
letter-spacing: 0.05em;
margin-bottom: 10px;
}
.recent-item {
background: rgba(255,255,255,0.12);
border-radius: 12px;
padding: 12px 14px;
margin-bottom: 8px;
backdrop-filter: blur(4px);
}
.recent-item .ri-tag {
font-size: 11px;
color: rgba(255,255,255,0.5);
}
.recent-item .ri-text {
color: white;
font-size: 14px;
margin-top: 3px;
line-height: 1.5;
word-break: break-word;
}
.recent-item .ri-time {
font-size: 11px;
color: rgba(255,255,255,0.35);
margin-top: 4px;
}
.empty-hint {
text-align: center;
color: rgba(255,255,255,0.3);
font-size: 13px;
padding: 30px 0;
line-height: 1.8;
}
</style>
</head>
<body>
<div class="top">
<div class="greeting" id="greeting"></div>
<div class="title">随手记</div>
<div class="input-area">
<textarea id="noteInput" placeholder="想到什么,写下来…" autofocus></textarea>
</div>
<div class="tags" id="tagBtns">
<button class="tag-btn active" data-tag="灵感" onclick="pickTag(this)">💡 灵感</button>
<button class="tag-btn" data-tag="备忘" onclick="pickTag(this)">📌 备忘</button>
<button class="tag-btn" data-tag="读书" onclick="pickTag(this)">📖 读书</button>
<button class="tag-btn" data-tag="待办" onclick="pickTag(this)">✅ 待办</button>
</div>
<button class="save-btn" id="saveBtn" onclick="saveNote()">保存</button>
</div>
<div class="recent">
<div class="recent-title">最近记录</div>
<div id="recentList"></div>
</div>
<div class="toast" id="toast">
<span class="toast-icon"></span>
记下了!
</div>
<script>
let selectedTag = '灵感';
let notes = JSON.parse(localStorage.getItem('sp_notes')) || [];
// 问候语
function updateGreeting() {
const h = new Date().getHours();
let g = '晚上好';
if (h < 6) g = '夜深了,早点休息';
else if (h < 12) g = '早上好';
else if (h < 14) g = '中午好';
else if (h < 18) g = '下午好';
document.getElementById('greeting').textContent = g + 'Hera';
}
updateGreeting();
function pickTag(btn) {
document.querySelectorAll('.tag-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
selectedTag = btn.dataset.tag;
}
function saveNote() {
const input = document.getElementById('noteInput');
const text = input.value.trim();
if (!text) return;
const now = new Date();
notes.unshift({
text,
tag: selectedTag,
id: Date.now(),
time: now.toLocaleString('zh-CN', {
month:'numeric', day:'numeric',
hour:'2-digit', minute:'2-digit'
}),
date: now.toISOString().slice(0,10),
});
localStorage.setItem('sp_notes', JSON.stringify(notes));
// 如果是"待办"标签,同时丢进收集箱
if (selectedTag === '待办') {
const inbox = JSON.parse(localStorage.getItem('sp_inbox')) || [];
inbox.push({
text,
id: Date.now(),
time: now.toLocaleString('zh-CN', { month:'numeric', day:'numeric', hour:'2-digit', minute:'2-digit' }),
});
localStorage.setItem('sp_inbox', JSON.stringify(inbox));
}
input.value = '';
showToast();
renderRecent();
input.focus();
}
function showToast() {
const t = document.getElementById('toast');
const msgs = ['记下了!','保存成功!','已记录 ✓','收到!'];
t.innerHTML = `<span class="toast-icon">✨</span>${msgs[Math.floor(Math.random()*msgs.length)]}`;
t.classList.add('show');
setTimeout(() => t.classList.remove('show'), 1200);
}
function renderRecent() {
const list = document.getElementById('recentList');
const recent = notes.slice(0, 10);
if (recent.length === 0) {
list.innerHTML = '<div class="empty-hint">还没有记录<br>想到什么就写下来吧</div>';
return;
}
const TAG_ICONS = { '灵感':'💡', '备忘':'📌', '读书':'📖', '待办':'✅' };
list.innerHTML = recent.map(n => `
<div class="recent-item">
<div class="ri-tag">${TAG_ICONS[n.tag]||'📝'} ${n.tag}</div>
<div class="ri-text">${escHtml(n.text)}</div>
<div class="ri-time">${n.time}</div>
</div>
`).join('');
}
function escHtml(s) {
return s.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}
// 自动调整 textarea 高度
document.getElementById('noteInput').addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = Math.min(this.scrollHeight, 200) + 'px';
});
renderRecent();
</script>
</body>
</html>