dsh-mikan 0.1.0 → 0.2.1
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/CHANGELOG.md +71 -0
- package/README.md +46 -25
- package/client.js +437 -34
- package/docs/DETAIL.md +61 -27
- package/index.js +246 -74
- package/lib/airdate.js +4 -3
- package/lib/constants.js +11 -1
- package/lib/mikan.js +65 -6
- package/lib/mirrors.js +58 -0
- package/lib/net.js +10 -2
- package/lib/qbittorrent.js +164 -0
- package/package.json +7 -3
package/client.js
CHANGED
|
@@ -28,13 +28,24 @@ window.__ModuleLoader__.load({
|
|
|
28
28
|
const panel = { border, borderRadius: 10, background: 'var(--dsw-alias-surface, transparent)' };
|
|
29
29
|
const muted = { opacity: 0.62, fontSize: 12 };
|
|
30
30
|
const row = { display: 'flex', gap: 10, alignItems: 'center', padding: '7px 0', borderBottom: border };
|
|
31
|
+
const SUB_LABEL = { trad: '繁', simp: '简', multi: '多' };
|
|
32
|
+
const SUB_COLOR = {
|
|
33
|
+
trad: 'var(--dsw-alias-warning, #f08c00)',
|
|
34
|
+
simp: 'var(--dsw-alias-success, #2f9e44)',
|
|
35
|
+
multi: 'var(--dsw-alias-text-secondary, #868e96)',
|
|
36
|
+
};
|
|
31
37
|
|
|
32
|
-
function Pill({ ok, children }) {
|
|
38
|
+
function Pill({ ok, warn, children, onClick }) {
|
|
39
|
+
const color = warn
|
|
40
|
+
? 'var(--dsw-alias-warning, #f08c00)'
|
|
41
|
+
: (ok ? 'var(--dsw-alias-success, #2f9e44)' : 'var(--dsw-alias-danger, #e03131)');
|
|
33
42
|
return h('span', {
|
|
43
|
+
onClick,
|
|
34
44
|
style: {
|
|
35
45
|
display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12,
|
|
36
46
|
padding: '2px 8px', borderRadius: 999, border,
|
|
37
|
-
color
|
|
47
|
+
color,
|
|
48
|
+
cursor: onClick ? 'pointer' : 'default',
|
|
38
49
|
},
|
|
39
50
|
}, h('span', { style: { width: 6, height: 6, borderRadius: '50%', background: 'currentColor' } }), children);
|
|
40
51
|
}
|
|
@@ -107,6 +118,12 @@ window.__ModuleLoader__.load({
|
|
|
107
118
|
const [dialog, setDialog] = useState(null);
|
|
108
119
|
const [browse, setBrowse] = useState(null);
|
|
109
120
|
const [expanded, setExpanded] = useState({});
|
|
121
|
+
const [scanResult, setScanResult] = useState(null);
|
|
122
|
+
const [groupByLang, setGroupByLang] = useState(false);
|
|
123
|
+
const [batchTarget, setBatchTarget] = useState(null);
|
|
124
|
+
const [batchStats, setBatchStats] = useState(null);
|
|
125
|
+
const [mikanBaseInput, setMikanBaseInput] = useState('');
|
|
126
|
+
const [bgmBaseInput, setBgmBaseInput] = useState('');
|
|
110
127
|
|
|
111
128
|
const load = useCallback(async ({ autoCheck = false } = {}) => {
|
|
112
129
|
try {
|
|
@@ -146,6 +163,40 @@ window.__ModuleLoader__.load({
|
|
|
146
163
|
catch (e) { setNotice('断开失败:' + e.message); } finally { setBusy(''); }
|
|
147
164
|
}, [load]);
|
|
148
165
|
|
|
166
|
+
const runScan = useCallback(async () => {
|
|
167
|
+
setBusy('scan');
|
|
168
|
+
try {
|
|
169
|
+
const r = await postJson('/downloader-scan');
|
|
170
|
+
setScanResult(r);
|
|
171
|
+
const label = r.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet';
|
|
172
|
+
if (r.ok) setNotice(r.switched ? `已切换并连接 ${label}:端口 ${r.port}` : `已连接 ${label}:端口 ${r.port}`);
|
|
173
|
+
else setNotice(r.reason);
|
|
174
|
+
await load();
|
|
175
|
+
} catch (e) {
|
|
176
|
+
setNotice('检测失败:' + e.message);
|
|
177
|
+
} finally {
|
|
178
|
+
setBusy('');
|
|
179
|
+
}
|
|
180
|
+
}, [load]);
|
|
181
|
+
|
|
182
|
+
const switchTo = useCallback(async (type) => {
|
|
183
|
+
setBusy('switch');
|
|
184
|
+
try {
|
|
185
|
+
await postJson('/config', { downloader: type });
|
|
186
|
+
await load();
|
|
187
|
+
const r = await postJson('/downloader-scan');
|
|
188
|
+
setScanResult(r);
|
|
189
|
+
const label = r.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet';
|
|
190
|
+
if (r.ok) setNotice(`已切换并连接 ${label}:端口 ${r.port}`);
|
|
191
|
+
else setNotice(r.reason);
|
|
192
|
+
await load();
|
|
193
|
+
} catch (e) {
|
|
194
|
+
setNotice('切换失败:' + e.message);
|
|
195
|
+
} finally {
|
|
196
|
+
setBusy('');
|
|
197
|
+
}
|
|
198
|
+
}, [load]);
|
|
199
|
+
|
|
149
200
|
const download = useCallback(async (hash, label) => {
|
|
150
201
|
setBusy('download');
|
|
151
202
|
try {
|
|
@@ -154,6 +205,28 @@ window.__ModuleLoader__.load({
|
|
|
154
205
|
} catch (e) { setNotice('下载失败:' + e.message); } finally { setBusy(''); }
|
|
155
206
|
}, []);
|
|
156
207
|
|
|
208
|
+
const batchDownload = useCallback(async (lang, label) => {
|
|
209
|
+
if (!browse) return;
|
|
210
|
+
setBusy('batch');
|
|
211
|
+
try {
|
|
212
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(browse.bangumiId)}&subgroupId=${encodeURIComponent(browse.subgroupId || '')}&subgroupName=${encodeURIComponent(browse.subgroupName || '')}&limit=500`);
|
|
213
|
+
const list = r.items || [];
|
|
214
|
+
const candidates = list.filter((w) => lang === 'all' || (w.subtitle || 'multi') === lang);
|
|
215
|
+
if (candidates.length === 0) {
|
|
216
|
+
setNotice(`没有「${label}」的作品`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const res = await postJson('/download', { hashes: candidates.map((w) => w.hash) });
|
|
220
|
+
setNotice(res.ok
|
|
221
|
+
? `已批量加入 ${candidates.length} 个「${label}」任务`
|
|
222
|
+
: `批量下载部分失败:${res.results?.find((x) => !x.added)?.message || '未知错误'}`);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
setNotice('批量下载失败:' + e.message);
|
|
225
|
+
} finally {
|
|
226
|
+
setBusy('');
|
|
227
|
+
}
|
|
228
|
+
}, [browse]);
|
|
229
|
+
|
|
157
230
|
const checkUpdates = useCallback(async () => {
|
|
158
231
|
setBusy('check');
|
|
159
232
|
setNotice('');
|
|
@@ -195,8 +268,11 @@ window.__ModuleLoader__.load({
|
|
|
195
268
|
/* ---------- browse (three levels) ---------- */
|
|
196
269
|
|
|
197
270
|
const openSeason = useCallback(async (year, season) => {
|
|
198
|
-
const
|
|
199
|
-
const
|
|
271
|
+
const now = new Date();
|
|
272
|
+
const month = now.getMonth() + 1;
|
|
273
|
+
const curSeason = month <= 3 ? '冬' : month <= 6 ? '春' : month <= 9 ? '夏' : '秋';
|
|
274
|
+
const y = year || now.getFullYear();
|
|
275
|
+
const s = season || curSeason;
|
|
200
276
|
setDialog({ type: 'browse' });
|
|
201
277
|
setBrowse({ level: 'season', year: y, season: s, loading: true, groups: [] });
|
|
202
278
|
try {
|
|
@@ -229,8 +305,8 @@ window.__ModuleLoader__.load({
|
|
|
229
305
|
subgroupId: subgroup.subgroupId, subgroupName: subgroup.name, loading: true, works: [],
|
|
230
306
|
}));
|
|
231
307
|
try {
|
|
232
|
-
const r = await getJson(`/works?bangumiId=${encodeURIComponent(id)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}`);
|
|
233
|
-
setBrowse((b) => ({ ...b, loading: false, works: r.items || [] }));
|
|
308
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(id)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}&subgroupName=${encodeURIComponent(subgroup.name || '')}&limit=30`);
|
|
309
|
+
setBrowse((b) => ({ ...b, loading: false, works: r.items || [], total: r.total || 0, limit: 30, counts: r.counts || null }));
|
|
234
310
|
} catch (e) {
|
|
235
311
|
setBrowse((b) => ({ ...b, loading: false, works: [], error: e.message }));
|
|
236
312
|
}
|
|
@@ -260,6 +336,119 @@ window.__ModuleLoader__.load({
|
|
|
260
336
|
return Boolean(sub && sub.subgroups.some((g) => g.subgroupId === subgroup.subgroupId || g.name === subgroup.name));
|
|
261
337
|
}, [schedule, browse]);
|
|
262
338
|
|
|
339
|
+
const loadMoreWorks = useCallback(async () => {
|
|
340
|
+
if (!browse) return;
|
|
341
|
+
const next = Math.min((browse.limit || 30) + 30, browse.total || 0);
|
|
342
|
+
try {
|
|
343
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(browse.bangumiId)}&subgroupId=${encodeURIComponent(browse.subgroupId || '')}&subgroupName=${encodeURIComponent(browse.subgroupName || '')}&limit=${next}`);
|
|
344
|
+
setBrowse((b) => ({ ...b, works: r.items || [], total: r.total || 0, limit: next }));
|
|
345
|
+
} catch (e) {
|
|
346
|
+
setNotice('加载更多失败:' + e.message);
|
|
347
|
+
}
|
|
348
|
+
}, [browse]);
|
|
349
|
+
|
|
350
|
+
const showAllWorks = useCallback(async () => {
|
|
351
|
+
if (!browse) return;
|
|
352
|
+
try {
|
|
353
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(browse.bangumiId)}&subgroupId=${encodeURIComponent(browse.subgroupId || '')}&subgroupName=${encodeURIComponent(browse.subgroupName || '')}&limit=500`);
|
|
354
|
+
setBrowse((b) => ({ ...b, works: r.items || [], total: r.total || 0, limit: r.displayed || 500 }));
|
|
355
|
+
} catch (e) {
|
|
356
|
+
setNotice('加载失败:' + e.message);
|
|
357
|
+
}
|
|
358
|
+
}, [browse]);
|
|
359
|
+
|
|
360
|
+
const openBatch = useCallback(async (bangumiId, title, subgroup, ctx) => {
|
|
361
|
+
setBatchTarget({
|
|
362
|
+
bangumiId,
|
|
363
|
+
title,
|
|
364
|
+
subgroupId: subgroup.subgroupId,
|
|
365
|
+
subgroupName: subgroup.name,
|
|
366
|
+
season: ctx?.season,
|
|
367
|
+
year: ctx?.year,
|
|
368
|
+
});
|
|
369
|
+
setBatchStats(null);
|
|
370
|
+
setDialog({ type: 'batch' });
|
|
371
|
+
try {
|
|
372
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(bangumiId)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}&subgroupName=${encodeURIComponent(subgroup.name || '')}&limit=500`);
|
|
373
|
+
const list = r.items || [];
|
|
374
|
+
setBatchStats({
|
|
375
|
+
all: list.length,
|
|
376
|
+
simp: list.filter((w) => (w.subtitle || 'multi') === 'simp').length,
|
|
377
|
+
trad: list.filter((w) => (w.subtitle || 'multi') === 'trad').length,
|
|
378
|
+
multi: list.filter((w) => (w.subtitle || 'multi') === 'multi').length,
|
|
379
|
+
items: list,
|
|
380
|
+
});
|
|
381
|
+
} catch (e) {
|
|
382
|
+
setNotice('加载作品失败:' + e.message);
|
|
383
|
+
}
|
|
384
|
+
}, []);
|
|
385
|
+
|
|
386
|
+
const runBatch = useCallback(async (lang, label) => {
|
|
387
|
+
if (!batchStats?.items) return;
|
|
388
|
+
const candidates = batchStats.items.filter((w) => lang === 'all' || (w.subtitle || 'multi') === lang);
|
|
389
|
+
if (candidates.length === 0) {
|
|
390
|
+
setNotice(`没有「${label}」的作品`);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
setBusy('batch');
|
|
394
|
+
try {
|
|
395
|
+
const res = await postJson('/download', { hashes: candidates.map((w) => w.hash) });
|
|
396
|
+
setNotice(res.ok
|
|
397
|
+
? `已批量加入 ${candidates.length} 个「${label}」任务`
|
|
398
|
+
: `批量下载部分失败:${res.results?.find((x) => !x.added)?.message || '未知错误'}`);
|
|
399
|
+
setDialog(null);
|
|
400
|
+
} catch (e) {
|
|
401
|
+
setNotice('批量下载失败:' + e.message);
|
|
402
|
+
} finally {
|
|
403
|
+
setBusy('');
|
|
404
|
+
}
|
|
405
|
+
}, [batchStats]);
|
|
406
|
+
|
|
407
|
+
const refreshEnv = useCallback(async () => {
|
|
408
|
+
setBusy('env');
|
|
409
|
+
try {
|
|
410
|
+
const r = await getJson('/state?refresh=1');
|
|
411
|
+
setState(r);
|
|
412
|
+
setNotice(r.mikanOk
|
|
413
|
+
? `蜜柑可达:${String(r.mikan || '').replace(/^https?:\/\//, '')}`
|
|
414
|
+
: '蜜柑不可达,请检查网络或配置镜像');
|
|
415
|
+
} catch (e) {
|
|
416
|
+
setNotice('检测失败:' + e.message);
|
|
417
|
+
} finally {
|
|
418
|
+
setBusy('');
|
|
419
|
+
}
|
|
420
|
+
}, []);
|
|
421
|
+
|
|
422
|
+
const saveMikanBase = useCallback(async () => {
|
|
423
|
+
setBusy('mikan');
|
|
424
|
+
try {
|
|
425
|
+
await postJson('/config', { mikanBase: mikanBaseInput.trim() });
|
|
426
|
+
const r = await getJson('/state?refresh=1');
|
|
427
|
+
setState(r);
|
|
428
|
+
setNotice(r.mikanOk
|
|
429
|
+
? `已保存并连接:${String(r.mikan || '').replace(/^https?:\/\//, '')}`
|
|
430
|
+
: '已保存,但该镜像当前不可达');
|
|
431
|
+
} catch (e) {
|
|
432
|
+
setNotice('保存失败:' + e.message);
|
|
433
|
+
} finally {
|
|
434
|
+
setBusy('');
|
|
435
|
+
}
|
|
436
|
+
}, [mikanBaseInput]);
|
|
437
|
+
|
|
438
|
+
const saveBgmBase = useCallback(async () => {
|
|
439
|
+
setBusy('bgm');
|
|
440
|
+
try {
|
|
441
|
+
await postJson('/config', { bgmBase: bgmBaseInput.trim() });
|
|
442
|
+
const r = await getJson('/state?refresh=1');
|
|
443
|
+
setState(r);
|
|
444
|
+
setNotice(r.bgm ? 'bgm 已连接' : 'bgm 不可用(需要代理,或填一个国内可达的镜像)');
|
|
445
|
+
} catch (e) {
|
|
446
|
+
setNotice('保存失败:' + e.message);
|
|
447
|
+
} finally {
|
|
448
|
+
setBusy('');
|
|
449
|
+
}
|
|
450
|
+
}, [bgmBaseInput]);
|
|
451
|
+
|
|
263
452
|
/* ---------- render ---------- */
|
|
264
453
|
|
|
265
454
|
if (error) {
|
|
@@ -337,28 +526,86 @@ window.__ModuleLoader__.load({
|
|
|
337
526
|
disabled: busy === 'subscribe' || isSubscribed(s),
|
|
338
527
|
onClick: () => subscribeGroup(s),
|
|
339
528
|
}, isSubscribed(s) ? '✓ 已订阅' : '订阅'),
|
|
529
|
+
h('button', { onClick: () => openBatch(browse.bangumiId, browse.title, s, browse) }, '批量下载'),
|
|
340
530
|
h('button', { onClick: () => openWorks(browse.bangumiId, browse.title, s, browse) }, '查看作品'))));
|
|
341
531
|
}
|
|
342
532
|
|
|
533
|
+
function renderWorkItem(w) {
|
|
534
|
+
return h('div', { key: w.hash, style: row },
|
|
535
|
+
h('div', { style: { flex: 1 } },
|
|
536
|
+
h('div', { style: { fontSize: 13, lineHeight: 1.35 } },
|
|
537
|
+
h('span', {
|
|
538
|
+
style: {
|
|
539
|
+
fontSize: 11, padding: '1px 5px', borderRadius: 4, marginRight: 6, border,
|
|
540
|
+
color: SUB_COLOR[w.subtitle] || SUB_COLOR.multi,
|
|
541
|
+
},
|
|
542
|
+
}, SUB_LABEL[w.subtitle] || '多'),
|
|
543
|
+
`[${w.episode || '?'}] ${w.title}`),
|
|
544
|
+
h('div', { style: muted }, `${w.size} · ${w.hash.slice(0, 8)}…`)),
|
|
545
|
+
h('button', { disabled: busy === 'download', onClick: () => download(w.hash, `第 ${w.episode} 集`) }, '下载'));
|
|
546
|
+
}
|
|
547
|
+
|
|
343
548
|
function renderWorksBrowse() {
|
|
344
549
|
const sub = { subgroupId: browse.subgroupId, name: browse.subgroupName };
|
|
550
|
+
const buckets = [
|
|
551
|
+
['simp', '简体'],
|
|
552
|
+
['trad', '繁体'],
|
|
553
|
+
['multi', '多字幕 / 生肉 / 未知'],
|
|
554
|
+
];
|
|
555
|
+
const items = browse.works || [];
|
|
556
|
+
const counts = browse.counts || {
|
|
557
|
+
all: items.length,
|
|
558
|
+
simp: items.filter((w) => (w.subtitle || 'multi') === 'simp').length,
|
|
559
|
+
trad: items.filter((w) => (w.subtitle || 'multi') === 'trad').length,
|
|
560
|
+
multi: items.filter((w) => (w.subtitle || 'multi') === 'multi').length,
|
|
561
|
+
};
|
|
562
|
+
const grouped = buckets.map(([key, label]) => ({
|
|
563
|
+
key,
|
|
564
|
+
label,
|
|
565
|
+
items: items.filter((w) => (w.subtitle || 'multi') === key),
|
|
566
|
+
}));
|
|
345
567
|
return h('div', null,
|
|
346
|
-
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, marginBottom: 12 } },
|
|
568
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, marginBottom: 12, flexWrap: 'wrap' } },
|
|
347
569
|
h('button', {
|
|
348
570
|
disabled: busy === 'subscribe' || isSubscribed(sub),
|
|
349
571
|
onClick: () => subscribeGroup(sub),
|
|
350
|
-
}, isSubscribed(sub) ? '✓ 已订阅本组' : '订阅本组')
|
|
572
|
+
}, isSubscribed(sub) ? '✓ 已订阅本组' : '订阅本组'),
|
|
573
|
+
h('button', {
|
|
574
|
+
onClick: () => setGroupByLang((v) => !v),
|
|
575
|
+
style: groupByLang
|
|
576
|
+
? { borderColor: 'var(--dsw-alias-accent, #4c8dff)', color: 'var(--dsw-alias-accent, #4c8dff)' }
|
|
577
|
+
: undefined,
|
|
578
|
+
}, groupByLang ? '✓ 按语言分组' : '按语言分组'),
|
|
579
|
+
h('span', { style: { flex: 1 } }),
|
|
580
|
+
h('button', { disabled: Boolean(busy) || counts.all === 0, onClick: () => batchDownload('all', '全部') }, `全部下载(${counts.all})`),
|
|
581
|
+
h('button', { disabled: Boolean(busy) || counts.simp === 0, onClick: () => batchDownload('simp', '简中') }, `简中(${counts.simp})`),
|
|
582
|
+
h('button', { disabled: Boolean(busy) || counts.trad === 0, onClick: () => batchDownload('trad', '繁中') }, `繁中(${counts.trad})`),
|
|
583
|
+
h('button', { disabled: Boolean(busy) || counts.multi === 0, onClick: () => batchDownload('multi', '多字幕') }, `多字幕(${counts.multi})`)),
|
|
351
584
|
browse.loading
|
|
352
585
|
? h('div', { style: muted }, '加载中…')
|
|
353
586
|
: (browse.error
|
|
354
587
|
? h('div', { style: muted }, browse.error)
|
|
355
|
-
: (
|
|
588
|
+
: (items.length === 0
|
|
356
589
|
? h('div', { style: muted }, '这个字幕组还没有上传作品。')
|
|
357
|
-
:
|
|
358
|
-
h('div', { style: {
|
|
359
|
-
h('div', {
|
|
360
|
-
|
|
361
|
-
|
|
590
|
+
: (groupByLang
|
|
591
|
+
? grouped.map((g) => h('div', { key: g.key, style: { marginBottom: 18 } },
|
|
592
|
+
h('div', {
|
|
593
|
+
style: {
|
|
594
|
+
fontWeight: 600, fontSize: 13, marginBottom: 6,
|
|
595
|
+
color: SUB_COLOR[g.key] || 'inherit',
|
|
596
|
+
},
|
|
597
|
+
}, `${g.label}(${g.items.length})`),
|
|
598
|
+
g.items.length === 0
|
|
599
|
+
? h('div', { style: muted }, '—')
|
|
600
|
+
: g.items.map(renderWorkItem)))
|
|
601
|
+
: items.map(renderWorkItem)))),
|
|
602
|
+
items.length > 0 && items.length < (browse.total || 0)
|
|
603
|
+
? h('div', { style: { display: 'flex', gap: 8, justifyContent: 'center', marginTop: 14 } },
|
|
604
|
+
h('button', { onClick: loadMoreWorks, disabled: Boolean(busy) },
|
|
605
|
+
`显示更多(已显示 ${items.length} / 共 ${browse.total})`),
|
|
606
|
+
h('button', { onClick: showAllWorks, disabled: Boolean(busy) },
|
|
607
|
+
`显示全部(${browse.total})`))
|
|
608
|
+
: null);
|
|
362
609
|
}
|
|
363
610
|
|
|
364
611
|
return h('div', { style: { padding: '18px 22px', overflow: 'auto', height: '100%' } },
|
|
@@ -366,23 +613,35 @@ window.__ModuleLoader__.load({
|
|
|
366
613
|
h('h2', { style: { margin: 0, fontSize: 20 } }, '追番周历'),
|
|
367
614
|
h('span', { style: muted }, `${total} 部订阅`),
|
|
368
615
|
h('span', { style: { flex: 1 } }),
|
|
369
|
-
h('button', { onClick: () => openSeason(), disabled: Boolean(busy) }, '
|
|
616
|
+
h('button', { onClick: () => openSeason(), disabled: Boolean(busy) }, '当季浏览'),
|
|
617
|
+
h('button', { onClick: () => setDialog({ type: 'season-picker' }), disabled: Boolean(busy) }, '往季浏览'),
|
|
370
618
|
h('button', { onClick: checkUpdates, disabled: Boolean(busy) }, busy === 'check' ? '检查中…' : '检查更新'),
|
|
371
619
|
h('button', { onClick: () => load(), disabled: Boolean(busy) }, '刷新')),
|
|
372
620
|
|
|
373
621
|
state && h('div', { style: { ...panel, display: 'flex', flexWrap: 'wrap', gap: 10, alignItems: 'center', padding: '10px 12px', marginBottom: 12 } },
|
|
374
|
-
h(Pill, { ok: state.mode === 'proxy' }, state.mode === 'proxy' ? '代理模式' : '直连模式'),
|
|
375
|
-
h(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
622
|
+
h(Pill, { ok: state.mode === 'proxy', warn: state.mode !== 'proxy' }, state.mode === 'proxy' ? '代理模式' : '直连模式'),
|
|
623
|
+
h(Pill, {
|
|
624
|
+
ok: state.mikanOk !== false,
|
|
625
|
+
onClick: () => { setMikanBaseInput(state?.mikanCustom || ''); setDialog({ type: 'mikan' }); },
|
|
626
|
+
}, state.mikanOk !== false ? 'Mikan 可用' : 'Mikan 不可用'),
|
|
627
|
+
h(Pill, {
|
|
628
|
+
ok: state.bgm,
|
|
629
|
+
onClick: () => { setBgmBaseInput(state?.bgmCustom || ''); setDialog({ type: 'bgm' }); },
|
|
630
|
+
}, 'bgm ' + (state.bgm ? '可用' : '不可用')),
|
|
631
|
+
h(Pill, {
|
|
632
|
+
ok: state.downloader?.ok,
|
|
633
|
+
onClick: () => setDialog({ type: 'downloader' }),
|
|
634
|
+
}, state.downloader?.ok
|
|
635
|
+
? `${state.downloader?.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet'} 已连接`
|
|
636
|
+
: '下载器 未连接')),
|
|
637
|
+
|
|
638
|
+
state && !state.downloader?.ok ? h('div', {
|
|
639
|
+
onClick: () => setDialog({ type: 'guide', title: '下载器连接指引' }),
|
|
381
640
|
style: {
|
|
382
641
|
...panel, padding: '8px 12px', marginBottom: 12, cursor: 'pointer',
|
|
383
642
|
borderColor: 'var(--dsw-alias-warning, #f08c00)', color: 'var(--dsw-alias-warning, #f08c00)', fontSize: 13,
|
|
384
643
|
},
|
|
385
|
-
}, '⚠
|
|
644
|
+
}, '⚠ 下载器未连接 —— 点击查看配置指引') : null,
|
|
386
645
|
|
|
387
646
|
(() => {
|
|
388
647
|
const count = updateStatus?.count || 0;
|
|
@@ -452,6 +711,23 @@ window.__ModuleLoader__.load({
|
|
|
452
711
|
? h('div', { style: { ...muted, marginTop: 16 } }, '还没有订阅。点「浏览季度」找番剧,或去对话里说「追某某番的某个字幕组」。')
|
|
453
712
|
: h('div', { style: { ...muted, marginTop: 12 } }, '点番剧卡片可查看字幕组与作品;卡片上可「静默」或「取消订阅」。'),
|
|
454
713
|
|
|
714
|
+
dialog && dialog.type === 'season-picker' ? h(Overlay, {
|
|
715
|
+
title: '往季浏览', onClose: () => setDialog(null),
|
|
716
|
+
}, h('div', null,
|
|
717
|
+
h('div', { style: { ...muted, marginBottom: 10 } }, '选一个年份和季节'),
|
|
718
|
+
Array.from({ length: 12 }, (_, i) => new Date().getFullYear() - i).map((y) => h('div', {
|
|
719
|
+
key: y,
|
|
720
|
+
style: { display: 'flex', gap: 8, alignItems: 'center', padding: '7px 0', borderBottom: border },
|
|
721
|
+
},
|
|
722
|
+
h('span', { style: { width: 52, fontWeight: 600, fontSize: 13 } }, String(y)),
|
|
723
|
+
[['冬', '1月'], ['春', '4月'], ['夏', '7月'], ['秋', '10月']].map(([s, m]) => h('button', {
|
|
724
|
+
key: s,
|
|
725
|
+
style: { minWidth: 72 },
|
|
726
|
+
onClick: () => openSeason(y, s),
|
|
727
|
+
}, `${s}(${m})`)),
|
|
728
|
+
)),
|
|
729
|
+
)) : null,
|
|
730
|
+
|
|
455
731
|
dialog && dialog.type === 'browse' && browse ? h(Overlay, {
|
|
456
732
|
title: breadcrumb,
|
|
457
733
|
onClose: () => { setDialog(null); setBrowse(null); },
|
|
@@ -488,32 +764,159 @@ window.__ModuleLoader__.load({
|
|
|
488
764
|
h('div', { style: muted }, `${e.size}`)),
|
|
489
765
|
h('button', { onClick: () => download(e.hash, `${u.title} 第${e.episode}集`) }, '下载'))))))) : null,
|
|
490
766
|
|
|
767
|
+
dialog && dialog.type === 'batch' && batchTarget ? h(Overlay, {
|
|
768
|
+
title: `批量下载 · ${batchTarget.title} / ${batchTarget.subgroupName}`, onClose: () => setDialog(null),
|
|
769
|
+
}, h('div', null,
|
|
770
|
+
batchStats
|
|
771
|
+
? h('div', null,
|
|
772
|
+
h('div', { style: { ...muted, marginBottom: 12 } },
|
|
773
|
+
`共 ${batchStats.all} 个作品 · 简中 ${batchStats.simp} · 繁中 ${batchStats.trad} · 多字幕 ${batchStats.multi}`),
|
|
774
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
775
|
+
h('button', {
|
|
776
|
+
disabled: Boolean(busy) || batchStats.all === 0,
|
|
777
|
+
onClick: () => runBatch('all', '全部'),
|
|
778
|
+
}, `全部下载(${batchStats.all})`),
|
|
779
|
+
h('button', {
|
|
780
|
+
disabled: Boolean(busy) || batchStats.simp === 0,
|
|
781
|
+
onClick: () => runBatch('simp', '简中'),
|
|
782
|
+
}, `简中(${batchStats.simp})`),
|
|
783
|
+
h('button', {
|
|
784
|
+
disabled: Boolean(busy) || batchStats.trad === 0,
|
|
785
|
+
onClick: () => runBatch('trad', '繁中'),
|
|
786
|
+
}, `繁中(${batchStats.trad})`),
|
|
787
|
+
h('button', {
|
|
788
|
+
disabled: Boolean(busy) || batchStats.multi === 0,
|
|
789
|
+
onClick: () => runBatch('multi', '多字幕'),
|
|
790
|
+
}, `多字幕(${batchStats.multi})`)))
|
|
791
|
+
: h('div', { style: muted }, '加载作品中…'),
|
|
792
|
+
h('div', { style: { ...muted, marginTop: 12 } }, '没有对应语言的作品会置灰。'))) : null,
|
|
793
|
+
|
|
794
|
+
dialog && dialog.type === 'bgm' ? h(Overlay, {
|
|
795
|
+
title: 'bgm 连接', onClose: () => setDialog(null),
|
|
796
|
+
}, h('div', null,
|
|
797
|
+
h('div', { style: { marginBottom: 10, fontSize: 13 } },
|
|
798
|
+
state?.bgm
|
|
799
|
+
? `当前:可用${state.bgmActive ? `(${String(state.bgmActive).replace(/^https?:\/\//, '')})` : ''}`
|
|
800
|
+
: '当前:不可用'),
|
|
801
|
+
h('div', { style: { ...muted, marginBottom: 12, lineHeight: 1.7 } },
|
|
802
|
+
'bgm.tv 用于补全开播日期。官方 API 在大陆需要代理;如果你有国内可达的镜像,填在下面。'),
|
|
803
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
|
|
804
|
+
h('input', {
|
|
805
|
+
value: bgmBaseInput,
|
|
806
|
+
onChange: (e) => setBgmBaseInput(e.target.value),
|
|
807
|
+
placeholder: '自定义 API,留空自动(官方 / api.bgm.lat)',
|
|
808
|
+
style: { flex: 1, minWidth: 240, padding: '6px 8px' },
|
|
809
|
+
}),
|
|
810
|
+
h('button', { onClick: saveBgmBase, disabled: Boolean(busy) }, busy === 'bgm' ? '保存中…' : '保存并检测'),
|
|
811
|
+
h('button', { onClick: refreshEnv, disabled: Boolean(busy) }, busy === 'env' ? '检测中…' : '重新检测')),
|
|
812
|
+
h('div', { style: muted }, '留空则使用官方 api.bgm.tv(需要代理)或内置目录镜像。'),
|
|
813
|
+
)) : null,
|
|
814
|
+
|
|
815
|
+
dialog && dialog.type === 'mikan' ? h(Overlay, {
|
|
816
|
+
title: '蜜柑连接', onClose: () => setDialog(null),
|
|
817
|
+
}, h('div', null,
|
|
818
|
+
h('div', { style: { marginBottom: 10, fontSize: 13 } },
|
|
819
|
+
state?.mikanOk
|
|
820
|
+
? `当前:可达 · ${String(state.mikan || '').replace(/^https?:\/\//, '')}(${state.mikanReason || ''})`
|
|
821
|
+
: '当前:不可达'),
|
|
822
|
+
h('div', { style: { ...muted, marginBottom: 12, lineHeight: 1.7 } },
|
|
823
|
+
'蜜柑的内置域名都在 Cloudflare 后面。部分运营商封锁 Cloudflare 节点时,插件会完全无法获取数据;此时只能通过代理,或在这里填一个可用的自定义镜像。'),
|
|
824
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
|
|
825
|
+
h('input', {
|
|
826
|
+
value: mikanBaseInput,
|
|
827
|
+
onChange: (e) => setMikanBaseInput(e.target.value),
|
|
828
|
+
placeholder: '自定义镜像,如 https://mirror.example',
|
|
829
|
+
style: { flex: 1, minWidth: 240, padding: '6px 8px' },
|
|
830
|
+
}),
|
|
831
|
+
h('button', { onClick: saveMikanBase, disabled: Boolean(busy) }, busy === 'mikan' ? '保存中…' : '保存并检测'),
|
|
832
|
+
h('button', { onClick: refreshEnv, disabled: Boolean(busy) }, busy === 'env' ? '检测中…' : '重新检测')),
|
|
833
|
+
h('div', { style: muted }, '留空则使用内置域名自动探测(mikanime.tv / mikanani.me)。'),
|
|
834
|
+
)) : null,
|
|
835
|
+
|
|
836
|
+
dialog && dialog.type === 'downloader' ? (() => {
|
|
837
|
+
const dl = state?.downloader || {};
|
|
838
|
+
const typeLabel = dl.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet';
|
|
839
|
+
let currentPort = '';
|
|
840
|
+
try { currentPort = new URL(dl.base || '').port; } catch { /* unknown */ }
|
|
841
|
+
return h(Overlay, {
|
|
842
|
+
title: '下载器', onClose: () => setDialog(null),
|
|
843
|
+
}, h('div', null,
|
|
844
|
+
h('div', { style: { marginBottom: 12, fontSize: 13 } },
|
|
845
|
+
dl.ok ? `当前:${typeLabel} 已连接 · 端口 ${currentPort || '?????'}` : '当前:下载器 未连接'),
|
|
846
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 14 } },
|
|
847
|
+
h('button', { onClick: runScan, disabled: Boolean(busy) }, busy === 'scan' ? '检测中…' : '自动检测'),
|
|
848
|
+
h('button', {
|
|
849
|
+
onClick: () => switchTo('qbittorrent'),
|
|
850
|
+
disabled: Boolean(busy) || dl.type === 'qbittorrent',
|
|
851
|
+
}, '使用 qBittorrent'),
|
|
852
|
+
h('button', {
|
|
853
|
+
onClick: () => switchTo('bitcomet'),
|
|
854
|
+
disabled: Boolean(busy) || dl.type === 'bitcomet',
|
|
855
|
+
}, '使用 BitComet')),
|
|
856
|
+
scanResult
|
|
857
|
+
? h('div', null,
|
|
858
|
+
h('div', { style: { ...muted, marginBottom: 6 } }, '上次扫描结果:'),
|
|
859
|
+
(scanResult.tried || []).map((t, i) => h('div', { key: i, style: row },
|
|
860
|
+
h('span', { style: { flex: 1, fontSize: 13 } },
|
|
861
|
+
`${t.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet'} · 端口 ${t.port}`),
|
|
862
|
+
h('span', {
|
|
863
|
+
style: {
|
|
864
|
+
fontSize: 12,
|
|
865
|
+
color: t.ok ? 'var(--dsw-alias-success, #2f9e44)' : 'var(--dsw-alias-danger, #e03131)',
|
|
866
|
+
},
|
|
867
|
+
}, t.ok ? '✓ 已连接' : `✗ ${t.reason || '未连接'}`))))
|
|
868
|
+
: h('div', { style: muted }, '点「自动检测」查看各端口的连接状态'),
|
|
869
|
+
h('div', { style: { ...muted, marginTop: 12 } }, '切换会写入插件配置,并立即重新检测。'),
|
|
870
|
+
));
|
|
871
|
+
})() : null,
|
|
872
|
+
|
|
491
873
|
dialog && dialog.type === 'guide' ? h(Overlay, {
|
|
492
|
-
title: '
|
|
874
|
+
title: '下载器连接指引', onClose: () => setDialog(null),
|
|
493
875
|
}, h('div', null,
|
|
494
|
-
h('
|
|
495
|
-
|
|
496
|
-
|
|
876
|
+
h('div', { style: { ...muted, marginBottom: 12 } },
|
|
877
|
+
'任选一个下载器开启 Web 接口,然后在插件配置里用 downloader 指定它。'),
|
|
878
|
+
|
|
879
|
+
h('div', { style: { fontWeight: 600, fontSize: 13, marginBottom: 6 } }, 'qBittorrent(端口默认 8080)'),
|
|
880
|
+
h('ol', { style: { paddingLeft: 20, lineHeight: 1.9, fontSize: 13, margin: 0 } },
|
|
881
|
+
h('li', null, '工具 → 选项 → Web UI'),
|
|
882
|
+
h('li', null, '勾选「启用 Web 用户界面」'),
|
|
883
|
+
h('li', null, '端口默认 8080,可改(记下实际值)'),
|
|
884
|
+
h('li', null, '设置「用户名 / 密码」;只在本机使用可勾「对本地主机跳过身份验证」'),
|
|
885
|
+
h('li', null, '点击「应用」保存')),
|
|
886
|
+
|
|
887
|
+
h('div', { style: { fontWeight: 600, fontSize: 13, margin: '16px 0 6px' } }, 'BitComet(监听端口自定,例如 10816)'),
|
|
888
|
+
h('ol', { style: { paddingLeft: 20, lineHeight: 1.9, fontSize: 13, margin: 0 } },
|
|
889
|
+
h('li', null, '选项 → 远程访问'),
|
|
890
|
+
h('li', null, '「监听端口」填固定值(不要用 0 或随机端口)'),
|
|
497
891
|
h('li', null, '勾选「启用网页版远程访问」'),
|
|
498
892
|
h('li', null, '不要勾「始终使用 HTTPS」'),
|
|
499
893
|
h('li', null, '设置「用户名 / 密码」——插件会自动从 BitComet 配置文件读取'),
|
|
500
894
|
h('li', null, '不要勾「执行远程访问操作时显示提示窗口」'),
|
|
501
|
-
h('li', null, '点击「应用」保存'),
|
|
502
|
-
|
|
503
|
-
h('div', { style: { ...muted, marginTop: 14 } },
|
|
895
|
+
h('li', null, '点击「应用」保存')),
|
|
896
|
+
|
|
897
|
+
h('div', { style: { ...muted, marginTop: 14, lineHeight: 1.8 } },
|
|
898
|
+
'插件不会自己启动或关闭下载器,请保持它运行。',
|
|
899
|
+
h('br'),
|
|
900
|
+
'配置项:downloader 填 qbittorrent 或 bitcomet,并把对应的 base 字段填成上面的地址。'),
|
|
901
|
+
|
|
504
902
|
h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8, marginTop: 18 } },
|
|
505
903
|
h('button', { onClick: () => setDialog(null) }, '关闭'),
|
|
506
904
|
h('button', {
|
|
507
905
|
onClick: async () => {
|
|
508
906
|
setBusy('scan');
|
|
509
907
|
try {
|
|
510
|
-
const r = await postJson('/
|
|
511
|
-
|
|
908
|
+
const r = await postJson('/downloader-scan');
|
|
909
|
+
const label = r.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet';
|
|
910
|
+
if (r.ok) {
|
|
911
|
+
setNotice(r.switched ? `已切换并连接 ${label}:端口 ${r.port}` : `已连接 ${label}:端口 ${r.port}`);
|
|
912
|
+
} else {
|
|
913
|
+
setNotice(r.reason);
|
|
914
|
+
}
|
|
512
915
|
await load();
|
|
513
|
-
} catch (e) { setNotice('
|
|
916
|
+
} catch (e) { setNotice('检测失败:' + e.message); } finally { setBusy(''); }
|
|
514
917
|
setDialog(null);
|
|
515
918
|
},
|
|
516
|
-
}, busy === 'scan' ? '
|
|
919
|
+
}, busy === 'scan' ? '检测中…' : '自动检测'),
|
|
517
920
|
h('button', {
|
|
518
921
|
onClick: async () => { setBusy('probe'); try { await load(); } finally { setBusy(''); setDialog(null); } },
|
|
519
922
|
}, busy === 'probe' ? '检测中…' : '重新检测')))) : null,
|