dsh-half-page 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +26 -10
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -155,6 +155,18 @@ window.__ModuleLoader__.load({
|
|
|
155
155
|
if (r && r.ok) { setCfg(r.config); setMsg(favs.includes(key) ? '已取消收藏' : '已收藏') }
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
const copyFav = async (f) => {
|
|
159
|
+
if (String(f).startsWith('file:')) {
|
|
160
|
+
const r = await getJson('/dsh-reading.file?path=' + encodeURIComponent(f.slice(5)))
|
|
161
|
+
if (r && r.ok) { copy(r.text); setMsg('已复制正文') } else setMsg('复制失败:' + (r && r.error))
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
const [book, chapter] = String(f).split('|')
|
|
165
|
+
const bk = notes.find((x) => x.book === book)
|
|
166
|
+
const ch = bk && (bk.chapters || []).find((x) => x.title === chapter)
|
|
167
|
+
if (ch) { copy(ch.lines.join('\n')); setMsg('已复制这条读后感') } else setMsg('这条读后感已经不在了')
|
|
168
|
+
}
|
|
169
|
+
|
|
158
170
|
const saveCfg = async (patch) => {
|
|
159
171
|
const r = await getJson('/dsh-reading.config', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(patch) })
|
|
160
172
|
if (r && r.ok) { setCfg(r.config); setMsg('已保存') ; await load() } else setMsg('保存失败:' + (r && r.error))
|
|
@@ -174,9 +186,9 @@ window.__ModuleLoader__.load({
|
|
|
174
186
|
)
|
|
175
187
|
|
|
176
188
|
const tabs = h('div', { style: S.row },
|
|
177
|
-
['read', 'works', 'set'].map((k) => h('div', {
|
|
189
|
+
['read', 'works', 'fav', 'set'].map((k) => h('div', {
|
|
178
190
|
key: k, style: S.tab(tab === k), onClick: () => { setTab(k); if (k === 'works' && !works) loadWorks() },
|
|
179
|
-
}, k === 'read' ? '读书' : k === 'works' ? '她的作品' : '设置')),
|
|
191
|
+
}, k === 'read' ? '读书' : k === 'works' ? '她的作品' : k === 'fav' ? '收藏' : '设置')),
|
|
180
192
|
h('div', { style: { flex: 1 } }),
|
|
181
193
|
msg ? h('div', { style: { ...S.dim, color: C.ok } }, msg) : null,
|
|
182
194
|
)
|
|
@@ -416,13 +428,6 @@ window.__ModuleLoader__.load({
|
|
|
416
428
|
h('div', { style: S.dim }, '关掉后我只读书,不写东西'),
|
|
417
429
|
),
|
|
418
430
|
),
|
|
419
|
-
h('div', { style: S.card },
|
|
420
|
-
h('div', { style: { fontWeight: 600, marginBottom: 6 } }, '收藏'),
|
|
421
|
-
favs.length ? favs.map((f, i) => h('div', { key: i, style: S.row },
|
|
422
|
-
h('div', { style: { flex: 1 } }, f.replace(/^file:/, '')),
|
|
423
|
-
h('button', { style: S.btn, onClick: () => toggleFav(f) }, '取消'),
|
|
424
|
-
)) : h('div', { style: S.dim }, '在读后感或作品上点 ☆ 收藏。'),
|
|
425
|
-
),
|
|
426
431
|
h('div', { style: S.card },
|
|
427
432
|
h('div', { style: { fontWeight: 600, marginBottom: 6 } }, '导出'),
|
|
428
433
|
h('div', { style: S.row },
|
|
@@ -433,10 +438,21 @@ window.__ModuleLoader__.load({
|
|
|
433
438
|
),
|
|
434
439
|
)
|
|
435
440
|
|
|
441
|
+
const favTab = h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } },
|
|
442
|
+
h('div', { style: S.card },
|
|
443
|
+
h('div', { style: { fontWeight: 600, marginBottom: 6 } }, '收藏'),
|
|
444
|
+
favs.length ? favs.map((f, i) => h('div', { key: i, style: S.row },
|
|
445
|
+
h('div', { style: { flex: 1 } }, String(f).startsWith('file:') ? f.slice(5) : f.replace('|', ' · ')),
|
|
446
|
+
h('button', { style: S.btn, onClick: () => copyFav(f) }, '复制'),
|
|
447
|
+
h('button', { style: S.btn, onClick: () => toggleFav(f) }, '取消收藏'),
|
|
448
|
+
)) : h('div', { style: S.dim }, '在读后感或作品上点 ☆,收藏的东西会出现在这儿。'),
|
|
449
|
+
),
|
|
450
|
+
)
|
|
451
|
+
|
|
436
452
|
return h('div', { style: S.wrap },
|
|
437
453
|
head,
|
|
438
454
|
tabs,
|
|
439
|
-
tab === 'read' ? readTab : tab === 'works' ? worksTab : setTabView,
|
|
455
|
+
tab === 'read' ? readTab : tab === 'works' ? worksTab : tab === 'fav' ? favTab : setTabView,
|
|
440
456
|
)
|
|
441
457
|
}
|
|
442
458
|
|