-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
263 lines (238 loc) · 20 KB
/
index.html
File metadata and controls
263 lines (238 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>日省录</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📜</text></svg>">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500;600;700&family=ZCOOL+XiaoWei&family=Ma+Shan+Zheng&display=swap" rel="stylesheet">
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--ink: #2c2416; --ink-light: #5c4a36; --ink-lighter: #8a7a66;
--ink-faint: #b5a898; --paper: #f7f3ec; --paper-dark: #ede7dc;
--paper-darker: #e0d6c8; --seal: #c23a2e; --gold: #b8963e;
}
body {
min-height: 100vh; min-height: 100dvh; background: var(--paper);
font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
color: var(--ink); -webkit-font-smoothing: antialiased;
}
body::before {
content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.035;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='4' height='4' fill='%23000' opacity='0.03'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23000' opacity='0.06'/%3E%3C/svg%3E");
}
.container { max-width: 640px; margin: 0 auto; padding: 24px 20px 80px; position: relative; z-index: 1; }
.header { text-align: center; padding: 40px 0 12px; position: relative; }
.header-title { font-family: 'Ma Shan Zheng', cursive; font-size: 48px; color: var(--ink); letter-spacing: 12px; font-weight: 400; margin-bottom: 12px; }
.header-line { width: 60px; height: 1px; background: var(--ink-faint); margin: 0 auto 12px; }
.header-quote { font-size: 12px; color: var(--ink-lighter); letter-spacing: 2px; line-height: 1.8; }
.seal { position: absolute; top: 32px; right: 0; width: 52px; height: 52px; border: 2px solid var(--seal); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--seal); letter-spacing: 2px; font-family: 'Noto Serif SC', serif; font-weight: 700; transform: rotate(6deg); opacity: 0.7; writing-mode: vertical-rl; }
.stats { display: flex; justify-content: center; gap: 40px; padding: 20px 0; margin-bottom: 4px; }
.stat { text-align: center; }
.stat-num { font-size: 22px; font-weight: 600; color: var(--ink); }
.stat-label { font-size: 11px; color: var(--ink-lighter); letter-spacing: 2px; margin-top: 2px; }
.stat-divider { width: 1px; background: var(--paper-darker); align-self: stretch; }
.tabs { display: flex; justify-content: center; gap: 0; border-bottom: 1px solid var(--paper-darker); margin-bottom: 32px; }
.tab { padding: 12px 24px; border: none; background: none; font-size: 14px; font-family: inherit; color: var(--ink-lighter); cursor: pointer; position: relative; transition: color 0.3s; letter-spacing: 2px; }
.tab::after { content: ''; position: absolute; bottom: -1px; left: 50%; width: 0; height: 2px; background: var(--ink); transition: all 0.3s ease; transform: translateX(-50%); }
.tab.active { color: var(--ink); }
.tab.active::after { width: 24px; }
.write-card { background: var(--paper); border: 1px solid var(--paper-darker); padding: 32px 28px; position: relative; }
.write-card::before, .write-card::after { content: ''; position: absolute; width: 16px; height: 16px; border-color: var(--ink-faint); border-style: solid; }
.write-card::before { top: 8px; left: 8px; border-width: 1px 0 0 1px; }
.write-card::after { bottom: 8px; right: 8px; border-width: 0 1px 1px 0; }
.write-date { text-align: center; margin-bottom: 24px; }
.write-date-text { font-size: 15px; color: var(--ink-light); font-weight: 500; letter-spacing: 3px; }
.today-mark { display: inline-block; margin-left: 8px; font-size: 10px; color: var(--seal); border: 1px solid var(--seal); padding: 1px 8px; border-radius: 2px; vertical-align: middle; letter-spacing: 1px; }
.section-label { font-size: 12px; color: var(--ink-lighter); letter-spacing: 3px; text-align: center; margin-bottom: 12px; }
.moods { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.mood-btn { width: 48px; height: 48px; border: 1px solid var(--paper-darker); background: none; cursor: pointer; font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: all 0.2s ease; border-radius: 2px; }
.mood-btn:hover { border-color: var(--ink-faint); }
.mood-btn.selected { border-color: var(--ink-light); background: rgba(44,36,22,0.04); transform: scale(1.08); }
.mood-btn .m-label { font-size: 9px; color: var(--ink-lighter); }
.wisdom-box { text-align: center; margin-bottom: 24px; padding: 14px 20px; border-top: 1px solid var(--paper-darker); border-bottom: 1px solid var(--paper-darker); cursor: pointer; transition: opacity 0.2s; }
.wisdom-box:hover { opacity: 0.7; }
.wisdom-text { font-size: 13px; color: var(--ink-lighter); line-height: 1.8; letter-spacing: 1px; }
.wisdom-source { font-size: 11px; color: var(--ink-faint); margin-top: 6px; letter-spacing: 1px; }
.wisdom-hint { font-size: 10px; color: var(--ink-faint); margin-top: 4px; opacity: 0.6; }
.journal-area { width: 100%; min-height: 240px; border: none; outline: none; resize: vertical; font-size: 15px; line-height: 2.2; font-family: 'Noto Serif SC', 'Songti SC', serif; color: var(--ink); background: transparent; padding: 0; letter-spacing: 0.5px; background-image: repeating-linear-gradient(transparent, transparent 34px, var(--paper-darker) 34px, var(--paper-darker) 35px); background-size: 100% 35px; background-position: 0 -2px; }
.journal-area::placeholder { color: var(--ink-faint); letter-spacing: 1px; }
.word-count { text-align: right; font-size: 11px; color: var(--ink-faint); margin: 6px 0 20px; letter-spacing: 1px; }
.btn-row { display: flex; gap: 12px; justify-content: center; }
.btn-save { padding: 11px 40px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font-size: 14px; font-family: inherit; cursor: pointer; letter-spacing: 4px; transition: all 0.25s ease; }
.btn-save:hover { background: var(--ink-light); }
.btn-save:disabled { background: var(--ink-faint); border-color: var(--ink-faint); cursor: default; }
.btn-delete { padding: 11px 20px; border: 1px solid var(--paper-darker); background: none; color: var(--ink-faint); font-size: 13px; font-family: inherit; cursor: pointer; letter-spacing: 2px; transition: all 0.2s; }
.btn-delete:hover { border-color: var(--seal); color: var(--seal); }
.cal-card { border: 1px solid var(--paper-darker); padding: 28px 24px; }
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.cal-nav button { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--ink-light); padding: 4px 12px; transition: color 0.2s; }
.cal-nav button:hover { color: var(--ink); }
.cal-month { font-size: 16px; font-weight: 500; color: var(--ink); letter-spacing: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-wk { font-size: 11px; color: var(--ink-faint); padding: 10px 0; letter-spacing: 2px; }
.cal-d { aspect-ratio: 1; border: none; background: none; cursor: pointer; font-size: 13px; font-family: inherit; color: var(--ink-light); position: relative; transition: all 0.15s; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cal-d:hover { background: var(--paper-dark); }
.cal-d.today { font-weight: 700; color: var(--ink); }
.cal-d.today::before { content: ''; position: absolute; bottom: 6px; width: 4px; height: 4px; background: var(--ink); border-radius: 50%; }
.cal-d.selected { background: var(--ink); color: var(--paper); }
.cal-d .dot { position: absolute; bottom: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--seal); }
.cal-d.today .dot { bottom: 12px; }
.search-bar { border-bottom: 1px solid var(--paper-darker); padding: 10px 0; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.search-bar input { flex: 1; border: none; outline: none; background: none; font-size: 14px; font-family: inherit; color: var(--ink); letter-spacing: 1px; }
.search-bar input::placeholder { color: var(--ink-faint); }
.search-icon { font-size: 14px; color: var(--ink-faint); }
.empty { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty .e-icon { font-size: 36px; margin-bottom: 16px; opacity: 0.5; }
.empty .e-msg { font-size: 14px; letter-spacing: 2px; line-height: 1.8; }
.list { display: flex; flex-direction: column; gap: 0; }
.list-item { display: block; width: 100%; text-align: left; font-family: inherit; padding: 18px 0; border-bottom: 1px solid var(--paper-darker); background: none; border-left: none; border-right: none; border-top: none; cursor: pointer; transition: padding-left 0.2s; }
.list-item:first-child { border-top: 1px solid var(--paper-darker); }
.list-item:hover { padding-left: 8px; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.list-date { font-size: 14px; font-weight: 500; color: var(--ink); letter-spacing: 2px; }
.list-year { font-size: 11px; color: var(--ink-faint); margin-left: 8px; }
.list-mood { font-size: 18px; }
.list-preview { font-size: 13px; color: var(--ink-lighter); line-height: 1.8; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.footer { text-align: center; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--paper-darker); }
.footer-text { font-size: 11px; color: var(--ink-faint); letter-spacing: 3px; }
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(60px); background: var(--ink); color: var(--paper); padding: 10px 28px; font-size: 13px; font-family: inherit; letter-spacing: 3px; box-shadow: 0 4px 20px rgba(0,0,0,0.12); z-index: 999; transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s; opacity: 0; pointer-events: none; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.view-panel { animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 480px) {
.container { padding: 16px 14px 60px; }
.header-title { font-size: 38px; letter-spacing: 8px; }
.seal { width: 42px; height: 42px; font-size: 12px; top: 28px; }
.write-card { padding: 24px 18px; }
.tab { padding: 10px 16px; font-size: 13px; }
.mood-btn { width: 42px; height: 42px; font-size: 18px; }
}
</style>
</head>
<body>
<div class="container" id="app">
<header class="header">
<div class="header-title">日省录</div>
<div class="seal">修身</div>
<div class="header-line"></div>
<div class="header-quote">一日三省吾身</div>
</header>
<div class="stats">
<div class="stat"><div class="stat-num" id="totalCount">0</div><div class="stat-label">篇</div></div>
<div class="stat-divider"></div>
<div class="stat"><div class="stat-num" id="streakCount">0</div><div class="stat-label">日不辍</div></div>
</div>
<div class="tabs">
<button class="tab active" data-view="write" onclick="switchView('write')">省思</button>
<button class="tab" data-view="calendar" onclick="switchView('calendar')">日历</button>
<button class="tab" data-view="list" onclick="switchView('list')">回览</button>
</div>
<div id="view-write" class="view-panel">
<div class="write-card">
<div class="write-date"><span class="write-date-text" id="writeDateDisplay"></span></div>
<div class="section-label">今日心境</div>
<div class="moods" id="moodSelector"></div>
<div class="wisdom-box" id="wisdomBox" onclick="refreshWisdom()">
<div class="wisdom-text" id="wisdomText"></div>
<div class="wisdom-source" id="wisdomSource"></div>
<div class="wisdom-hint">点击换一则</div>
</div>
<textarea class="journal-area" id="journalText" placeholder="今日所思、所行、所悟..."></textarea>
<div class="word-count"><span id="wordCount">0</span> 字</div>
<div class="btn-row">
<button class="btn-save" id="btnSave" onclick="saveEntry()">落笔</button>
<button class="btn-delete" id="btnDelete" onclick="deleteEntry()" style="display:none">删除</button>
</div>
</div>
</div>
<div id="view-calendar" class="view-panel" style="display:none">
<div class="cal-card">
<div class="cal-nav">
<button onclick="changeMonth(-1)">‹</button>
<div class="cal-month" id="calTitle"></div>
<button onclick="changeMonth(1)">›</button>
</div>
<div class="cal-grid" id="calGrid"></div>
</div>
</div>
<div id="view-list" class="view-panel" style="display:none">
<div class="search-bar">
<span class="search-icon">⌕</span>
<input type="text" id="searchInput" placeholder="检索..." oninput="renderList()">
</div>
<div id="entriesList"></div>
</div>
<div class="footer"><div class="footer-text">不为圣贤 便为禽兽</div></div>
</div>
<div class="toast" id="toast"></div>
<script>
const MOODS=[{emoji:"😊",label:"畅然"},{emoji:"😌",label:"安然"},{emoji:"😢",label:"惆怅"},{emoji:"😤",label:"忿然"},{emoji:"🤔",label:"思索"},{emoji:"😴",label:"倦怠"}];
const WISDOMS=[
{text:"天下古今之庸人,皆以一惰字致败",source:"曾国藩"},
{text:"坚其志,苦其心,劳其力,事无大小,必有所成",source:"曾国藩"},
{text:"唯天下之至诚能胜天下之至伪,唯天下之至拙能胜天下之至巧",source:"曾国藩"},
{text:"凡人做一事,便须全副精神注在此一事",source:"曾国藩"},
{text:"士人读书,第一要有志,第二要有识,第三要有恒",source:"曾国藩"},
{text:"既往不恋,当下不杂,未来不迎",source:"曾国藩"},
{text:"慎独则心安,主敬则身强",source:"曾国藩"},
{text:"以能立能达为体,以不怨不尤为用",source:"曾国藩"},
{text:"养得胸中一种恬静",source:"曾国藩"},
{text:"轻财足以聚人,律己足以服人,量宽足以得人,身先足以率人",source:"曾国藩"},
{text:"每日不拘何时,静坐半时,体验静极生阳来复之仁心",source:"曾国藩"},
{text:"吾日三省吾身",source:"论语"},
{text:"君子慎独,不欺暗室",source:"礼记"},
{text:"静以修身,俭以养德",source:"诸葛亮"},
{text:"知止而后有定,定而后能静",source:"大学"},
{text:"博学之,审问之,慎思之,明辨之,笃行之",source:"中庸"},
];
const MONTHS=["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];
const WKS=["日","一","二","三","四","五","六"];
let entries={},selectedDate=fmtDate(new Date()),selectedMood=null,vMonth=new Date().getMonth(),vYear=new Date().getFullYear();
function fmtDate(d){return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`}
function todayStr(){return fmtDate(new Date())}
function dispDate(s){const p=s.split('-');return `${p[0]}年${+p[1]}月${+p[2]}日`}
function showToast(m){const t=document.getElementById('toast');t.textContent=m;t.classList.add('show');setTimeout(()=>t.classList.remove('show'),1800)}
function loadEntries(){try{const r=localStorage.getItem('journal-v2');if(r)entries=JSON.parse(r)}catch(e){}}
function save(){try{localStorage.setItem('journal-v2',JSON.stringify(entries))}catch(e){}}
function updateStats(){document.getElementById('totalCount').textContent=Object.keys(entries).length;let s=0,d=new Date();while(entries[fmtDate(d)]){s++;d.setDate(d.getDate()-1)}document.getElementById('streakCount').textContent=s}
function switchView(name){
['write','calendar','list'].forEach(v=>{document.getElementById('view-'+v).style.display=v===name?'block':'none';document.querySelector(`.tab[data-view="${v}"]`).classList.toggle('active',v===name)});
if(name==='write')renderWrite();if(name==='calendar')renderCalendar();if(name==='list')renderList();
}
function renderWrite(){
const e=entries[selectedDate],today=selectedDate===todayStr();
document.getElementById('writeDateDisplay').innerHTML=dispDate(selectedDate)+(today?'<span class="today-mark">今</span>':'');
document.getElementById('journalText').value=e?.text||'';selectedMood=e?.mood??null;updateWC();renderMoods();updateBtn();
document.getElementById('btnDelete').style.display=e?'inline-block':'none';
}
function renderMoods(){document.getElementById('moodSelector').innerHTML=MOODS.map((m,i)=>`<button class="mood-btn ${selectedMood===i?'selected':''}" onclick="pickMood(${i})"><span>${m.emoji}</span><span class="m-label">${m.label}</span></button>`).join('')}
function pickMood(i){selectedMood=selectedMood===i?null:i;renderMoods();updateBtn()}
function updateWC(){document.getElementById('wordCount').textContent=document.getElementById('journalText').value.length}
function updateBtn(){const t=document.getElementById('journalText').value.trim();document.getElementById('btnSave').disabled=!t&&selectedMood===null}
document.addEventListener('DOMContentLoaded',()=>{document.getElementById('journalText').addEventListener('input',()=>{updateWC();updateBtn()})});
function refreshWisdom(){const w=WISDOMS[Math.floor(Math.random()*WISDOMS.length)];document.getElementById('wisdomText').textContent='「'+w.text+'」';document.getElementById('wisdomSource').textContent='— '+w.source}
function saveEntry(){const t=document.getElementById('journalText').value.trim();if(!t&&selectedMood===null)return;entries[selectedDate]={text:t,mood:selectedMood,at:new Date().toISOString()};save();updateStats();showToast('已记录');document.getElementById('btnDelete').style.display='inline-block'}
function deleteEntry(){if(!confirm('确定删除此篇?'))return;delete entries[selectedDate];save();updateStats();document.getElementById('journalText').value='';selectedMood=null;renderMoods();updateBtn();document.getElementById('btnDelete').style.display='none';showToast('已删除')}
function renderCalendar(){
document.getElementById('calTitle').textContent=`${vYear} ${MONTHS[vMonth]}`;
const f=new Date(vYear,vMonth,1),l=new Date(vYear,vMonth+1,0);
let h=WKS.map(w=>`<div class="cal-wk">${w}</div>`).join('');
for(let i=0;i<f.getDay();i++)h+='<div></div>';
for(let d=1;d<=l.getDate();d++){const ds=`${vYear}-${String(vMonth+1).padStart(2,'0')}-${String(d).padStart(2,'0')}`,e=entries[ds],is2=ds===todayStr(),isSel=ds===selectedDate;let c='cal-d';if(isSel)c+=' selected';else if(is2)c+=' today';const dot=e&&!isSel?'<span class="dot"></span>':'';h+=`<button class="${c}" onclick="selCal('${ds}')"><span>${d}</span>${dot}</button>`}
document.getElementById('calGrid').innerHTML=h;
}
function selCal(d){selectedDate=d;switchView('write')}
function changeMonth(delta){vMonth+=delta;if(vMonth>11){vMonth=0;vYear++}if(vMonth<0){vMonth=11;vYear--}renderCalendar()}
function renderList(){
const q=(document.getElementById('searchInput')?.value||'').toLowerCase();
const sorted=Object.entries(entries).filter(([d,e])=>!q||(e.text||'').toLowerCase().includes(q)||d.includes(q)).sort((a,b)=>b[0].localeCompare(a[0]));
const box=document.getElementById('entriesList');
if(!sorted.length){box.innerHTML=`<div class="empty"><div class="e-icon">📜</div><div class="e-msg">${q?'未找到相关记录':'尚无记录,提笔落墨'}</div></div>`;return}
box.innerHTML='<div class="list">'+sorted.map(([d,e])=>{const p=d.split('-'),mi=e.mood!==null?MOODS[e.mood]:null;return`<button class="list-item" onclick="selCal('${d}')"><div class="list-head"><div><span class="list-date">${+p[1]}月${+p[2]}日</span><span class="list-year">${p[0]}</span></div>${mi?`<span class="list-mood">${mi.emoji}</span>`:''}</div><div class="list-preview">${e.text||(mi?'心境:'+mi.label:'')}</div></button>`}).join('')+'</div>';
}
loadEntries();updateStats();refreshWisdom();renderWrite();
</script>
</body>
</html>