dsh-half-page 0.3.22 → 0.3.23

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.
Files changed (2) hide show
  1. package/client.js +23 -2
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -167,6 +167,21 @@ window.__ModuleLoader__.load({
167
167
  if (ch) { copy(ch.lines.join('\n')); setMsg('已复制这条读后感') } else setMsg('这条读后感已经不在了')
168
168
  }
169
169
 
170
+ // 收藏页点一下就地展开:作品看正文,读后感看那一条
171
+ const openFav = async (f) => {
172
+ const key = 'fav:' + f
173
+ if (opened && opened.path === key) return setOpened(null)
174
+ if (String(f).startsWith('file:')) {
175
+ const p = f.slice(5)
176
+ const r = await getJson('/dsh-reading.file?path=' + encodeURIComponent(p))
177
+ return setOpened({ path: key, title: p, text: r && r.ok ? r.text : '读不到:' + (r && r.error) })
178
+ }
179
+ const parts = String(f).split('|')
180
+ const bk = notes.find((x) => x.book === parts[0])
181
+ const ch = bk && (bk.chapters || []).find((x) => x.title === parts[1])
182
+ setOpened({ path: key, title: parts.join(' · '), text: ch ? ch.lines.join('\n') : '这条读后感已经不在了' })
183
+ }
184
+
170
185
  const saveCfg = async (patch) => {
171
186
  const r = await getJson('/dsh-reading.config', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(patch) })
172
187
  if (r && r.ok) { setCfg(r.config); setMsg('已保存') ; await load() } else setMsg('保存失败:' + (r && r.error))
@@ -441,12 +456,18 @@ window.__ModuleLoader__.load({
441
456
  const favTab = h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } },
442
457
  h('div', { style: S.card },
443
458
  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('|', ' · ')),
459
+ favs.length ? favs.map((f, i) => h('div', { key: i, style: S.item },
460
+ h('div', {
461
+ style: { flex: 1, cursor: 'pointer', borderTop: i ? '1px solid ' + C.line : 'none', paddingTop: i ? 8 : 0 },
462
+ onClick: () => openFav(f),
463
+ }, String(f).startsWith('file:') ? f.slice(5) : f.replace('|', ' · ')),
446
464
  h('button', { style: S.btn, onClick: () => copyFav(f) }, '复制'),
447
465
  h('button', { style: S.btn, onClick: () => toggleFav(f) }, '取消收藏'),
448
466
  )) : h('div', { style: S.dim }, '在读后感或作品上点 ☆,收藏的东西会出现在这儿。'),
449
467
  ),
468
+ opened && String(opened.path || '').startsWith('fav:')
469
+ ? h('div', { style: { ...S.text, marginTop: 0 } }, (opened.title ? opened.title + '\n\n' : '') + opened.text)
470
+ : null,
450
471
  )
451
472
 
452
473
  return h('div', { style: S.wrap },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-half-page",
3
- "version": "0.3.22",
3
+ "version": "0.3.23",
4
4
  "private": false,
5
5
  "author": "鹿野 <luye@dsh.local>",
6
6
  "license": "MIT",