dsh-half-page 0.3.29 → 0.3.30
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 +20 -2
- package/index.js +6 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -54,7 +54,17 @@ window.__ModuleLoader__.load({
|
|
|
54
54
|
ch = { title: line.replace(/^###\s+/, '').trim(), lines: [] }
|
|
55
55
|
if (book) book.chapters.push(ch)
|
|
56
56
|
} else if (/^[-*]\s+/.test(line)) {
|
|
57
|
-
if (ch)
|
|
57
|
+
if (ch) {
|
|
58
|
+
const t = line.replace(/^[-*]\s+/, '')
|
|
59
|
+
ch.lines.push(t)
|
|
60
|
+
// 署名行里带着时间:- ↳ 来自:鹿野 · 2026-11-10 20:31
|
|
61
|
+
if (/^↳/.test(t)) {
|
|
62
|
+
const m = t.match(/(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/)
|
|
63
|
+
if (m) ch.at = m[1] + ' ' + m[2]
|
|
64
|
+
const b = t.replace(/^\u21b3\s*\u6765\u81ea\uff1a/, '').split('\u00b7')[0].trim()
|
|
65
|
+
if (b) ch.by = b
|
|
66
|
+
}
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
return out
|
|
@@ -322,7 +332,14 @@ window.__ModuleLoader__.load({
|
|
|
322
332
|
const total = bk.chapters.length
|
|
323
333
|
const pages = Math.max(1, Math.ceil(total / NOTE_PAGE))
|
|
324
334
|
const page = Math.min(v.page || 0, pages - 1)
|
|
325
|
-
|
|
335
|
+
// 排序:章节升 / 章节降 / 时间新在前(没写时间的排在后面)
|
|
336
|
+
const sortLabels = ['章节 \u2191', '章节 \u2193', '时间 \u2193']
|
|
337
|
+
const sortMode = v.sort || 0
|
|
338
|
+
const sorted = bk.chapters.slice()
|
|
339
|
+
if (sortMode === 1) sorted.sort((a, b) => (chapterNo(b.title) || -1) - (chapterNo(a.title) || -1))
|
|
340
|
+
else if (sortMode === 2) sorted.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')))
|
|
341
|
+
else sorted.sort((a, b) => (chapterNo(a.title) || 1e9) - (chapterNo(b.title) || 1e9))
|
|
342
|
+
const list = all ? sorted : sorted.slice(page * NOTE_PAGE, page * NOTE_PAGE + NOTE_PAGE)
|
|
326
343
|
const setView = (patch) => setNoteView(Object.assign({}, noteView, { [bi]: Object.assign({}, v, patch) }))
|
|
327
344
|
const paged = total > NOTE_PAGE
|
|
328
345
|
const tabs = h('div', { style: { ...S.row, gap: 6, marginBottom: 8, flexWrap: 'wrap' } },
|
|
@@ -341,6 +358,7 @@ window.__ModuleLoader__.load({
|
|
|
341
358
|
paged ? h('div', { style: { ...S.dim, minWidth: 46, textAlign: 'center' } }, all ? '全部' : ((page + 1) + ' / ' + pages)) : null,
|
|
342
359
|
paged ? h('button', { style: S.btn, disabled: all || page >= pages - 1, onClick: () => setView({ page: page + 1 }) }, '›') : null,
|
|
343
360
|
paged ? h('button', { style: all ? S.btnOn : S.btn, onClick: () => setView({ all: !all, page: 0 }) }, all ? '分页' : '全部') : null,
|
|
361
|
+
h('button', { style: S.btn, onClick: () => setView({ sort: (sortMode + 1) % 3, page: 0 }) }, sortLabels[sortMode]),
|
|
344
362
|
h('button', { style: S.btn, onClick: () => copy(bk.chapters.map((c) => '## ' + c.title + '\n' + c.lines.join('\n')).join('\n\n')) }, '复制这本'),
|
|
345
363
|
),
|
|
346
364
|
list.map((c, ci) => h('div', { key: ci, style: { marginBottom: 6 } },
|
package/index.js
CHANGED
|
@@ -209,7 +209,12 @@ export async function appendNote(dir, bookTitle, chapterTitle, lines, by) {
|
|
|
209
209
|
raw += (raw.trim() ? '\n\n' : '') + `## ${bookTitle}\n`
|
|
210
210
|
}
|
|
211
211
|
raw += `\n### ${chapterTitle}\n` + lines.map((l) => `- ${l}`).join('\n') + '\n'
|
|
212
|
-
if (by)
|
|
212
|
+
if (by) {
|
|
213
|
+
const d = new Date()
|
|
214
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
215
|
+
const ts = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`
|
|
216
|
+
raw += `- ↳ 来自:${by} · ${ts}\n`
|
|
217
|
+
}
|
|
213
218
|
await writeFile(p, raw, 'utf8')
|
|
214
219
|
return p
|
|
215
220
|
}
|