dsh-mikan 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +75 -2
- package/client.js +535 -0
- package/cordis.patch.yml +5 -0
- package/docs/DETAIL.md +76 -0
- package/icon.svg +14 -0
- package/index.js +890 -0
- package/lib/airdate.js +417 -0
- package/lib/bitcomet.js +278 -0
- package/lib/constants.js +41 -0
- package/lib/mikan.js +239 -0
- package/lib/net.js +298 -0
- package/lib/store.js +246 -0
- package/lib/tooldef.js +35 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +43 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-mikan contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-mikan
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DeepSeek Harness 的**蜜柑计划追番插件**:浏览季度新番、按字幕组订阅、把确认的作品一键送进比特彗星。
|
|
4
|
+
|
|
5
|
+
- 侧边栏「追番」页:七列周历 + 三级浏览 + 红绿黄更新点
|
|
6
|
+
- 对话工具:检索、订阅、检查更新、按 hash 下载
|
|
7
|
+
- 半自动:只通知你,下载永远由你确认
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
dsh plugin --profile web add dsh-mikan
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
或在 DSH 插件页点「添加插件」,输入 `dsh-mikan`。
|
|
16
|
+
|
|
17
|
+
安装后重启 DSH,侧边栏出现「追番」。
|
|
18
|
+
|
|
19
|
+
## 使用
|
|
20
|
+
|
|
21
|
+
打开「追番」:
|
|
22
|
+
|
|
23
|
+
1. **浏览季度** → 按放送星期折叠列出当季新番(只标题,点开才加载)
|
|
24
|
+
2. 点某部番 → 看开播日和做这部番的字幕组
|
|
25
|
+
3. 点某个字幕组 → 看它的作品列表,可「订阅本组」或直接下载
|
|
26
|
+
4. 订阅后出现在周历,卡片显示 `字幕组 已到 X / 全番 Y`
|
|
27
|
+
|
|
28
|
+
订阅只跟**指定字幕组**:该组出新集才通知,别组的进度只作参考(全番最新)。
|
|
29
|
+
|
|
30
|
+
## 配置
|
|
31
|
+
|
|
32
|
+
在 profile 的 `cordis.patch.yml` 中:
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
- id: dsh-mikan
|
|
36
|
+
config:
|
|
37
|
+
proxy: 'http://127.0.0.1:7890'
|
|
38
|
+
bitcometBase: 'http://127.0.0.1:10816'
|
|
39
|
+
savePath: 'D:\Downloads\Anime'
|
|
40
|
+
checkIntervalMinutes: 30
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| 字段 | 默认 | 说明 |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `proxy` | 空 | 本地代理地址,留空直连。有代理时会走墙外源 + bgm.tv 开播日 |
|
|
46
|
+
| `bitcometBase` | `http://127.0.0.1:10816` | 比特彗星 WebUI 地址 |
|
|
47
|
+
| `savePath` | 空(必填) | 下载保存目录,未设置时下载会被拒绝 |
|
|
48
|
+
| `checkIntervalMinutes` | 30 | 后台检查间隔 |
|
|
49
|
+
|
|
50
|
+
比特彗星的用户名密码会从 `%APPDATA%\BitComet\BitComet.xml` 自动读取,无需填写。
|
|
51
|
+
|
|
52
|
+
## 比特彗星准备
|
|
53
|
+
|
|
54
|
+
1. 选项 → 远程访问 → 监听端口填固定值(如 10816)
|
|
55
|
+
2. 勾选「启用网页版远程访问」
|
|
56
|
+
3. **不要**勾「始终使用 HTTPS」
|
|
57
|
+
4. 设置用户名和密码
|
|
58
|
+
5. 不要勾「执行远程访问操作时显示提示窗口」
|
|
59
|
+
|
|
60
|
+
插件未连接时,「追番」页顶部会出现连接指引,含「自动扫描端口」。
|
|
61
|
+
|
|
62
|
+
## 环境自适应
|
|
63
|
+
|
|
64
|
+
启动时自动探测:有可用代理 → 走墙外 `mikanani.me` + bgm.tv 补开播日;否则走墙内 `mikanime.tv` + AniList 兜底。
|
|
65
|
+
|
|
66
|
+
## 已知限制
|
|
67
|
+
|
|
68
|
+
- 没有字幕组做的番剧只有标题,开播日依赖 bgm/AniList,都不可用时显示未知
|
|
69
|
+
- 剧场版/OVA 的「放送日期」字段不可信,只用「放送开始」
|
|
70
|
+
- 全站 RSS 单次最多 100 条,订阅多时靠单番 RSS 补漏
|
|
71
|
+
- 比特彗星的添加/删除接口返回值不可靠,一律以任务列表复核
|
|
72
|
+
- 插件不会自己启动或关闭比特彗星
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT
|
package/client.js
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-mikan',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react');
|
|
5
|
+
const h = React.createElement;
|
|
6
|
+
const { useState, useEffect, useCallback } = React;
|
|
7
|
+
|
|
8
|
+
const API = '/dsh-mikan';
|
|
9
|
+
const WEEK = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
|
|
10
|
+
/** Fired after any action that can change the update digest. */
|
|
11
|
+
const CHANGED_EVENT = 'dsh-mikan:changed';
|
|
12
|
+
|
|
13
|
+
async function getJson(path, init) {
|
|
14
|
+
const res = await fetch(API + path, init);
|
|
15
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
16
|
+
return res.json();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function postJson(path, body) {
|
|
20
|
+
return getJson(path, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: { 'content-type': 'application/json' },
|
|
23
|
+
body: JSON.stringify(body || {}),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const border = '1px solid var(--dsw-alias-border, rgba(128,128,128,.25))';
|
|
28
|
+
const panel = { border, borderRadius: 10, background: 'var(--dsw-alias-surface, transparent)' };
|
|
29
|
+
const muted = { opacity: 0.62, fontSize: 12 };
|
|
30
|
+
const row = { display: 'flex', gap: 10, alignItems: 'center', padding: '7px 0', borderBottom: border };
|
|
31
|
+
|
|
32
|
+
function Pill({ ok, children }) {
|
|
33
|
+
return h('span', {
|
|
34
|
+
style: {
|
|
35
|
+
display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12,
|
|
36
|
+
padding: '2px 8px', borderRadius: 999, border,
|
|
37
|
+
color: ok ? 'var(--dsw-alias-success, #2f9e44)' : 'var(--dsw-alias-danger, #e03131)',
|
|
38
|
+
},
|
|
39
|
+
}, h('span', { style: { width: 6, height: 6, borderRadius: '50%', background: 'currentColor' } }), children);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function MikanIcon({ size = 18 }) {
|
|
43
|
+
const [level, setLevel] = useState('none');
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
let stopped = false;
|
|
46
|
+
const tick = async () => {
|
|
47
|
+
try {
|
|
48
|
+
const s = await getJson('/status');
|
|
49
|
+
if (!stopped) setLevel(s.level || 'none');
|
|
50
|
+
} catch { /* keep the previous dot */ }
|
|
51
|
+
};
|
|
52
|
+
tick();
|
|
53
|
+
const timer = setInterval(tick, 30000);
|
|
54
|
+
const onChange = () => { tick(); };
|
|
55
|
+
const onVisible = () => { if (document.visibilityState === 'visible') tick(); };
|
|
56
|
+
window.addEventListener(CHANGED_EVENT, onChange);
|
|
57
|
+
document.addEventListener('visibilitychange', onVisible);
|
|
58
|
+
return () => {
|
|
59
|
+
stopped = true;
|
|
60
|
+
clearInterval(timer);
|
|
61
|
+
window.removeEventListener(CHANGED_EVENT, onChange);
|
|
62
|
+
document.removeEventListener('visibilitychange', onVisible);
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
const dot = level === 'many' ? '#e03131' : level === 'few' ? '#f08c00' : '#2f9e44';
|
|
66
|
+
return h('svg', {
|
|
67
|
+
viewBox: '0 0 24 24', width: size, height: size, fill: 'none',
|
|
68
|
+
stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', 'aria-hidden': true,
|
|
69
|
+
},
|
|
70
|
+
h('circle', { cx: 12, cy: 13, r: 7 }),
|
|
71
|
+
h('path', { d: 'M12 6c1.6 2 3.6 2.8 5.6 2.6-1 2.4-3 3.8-5.6 4.2-2.6-.4-4.6-1.8-5.6-4.2 2 .2 4-.6 5.6-2.6z' }),
|
|
72
|
+
h('circle', { cx: 19.5, cy: 4.5, r: 3.2, fill: dot, stroke: 'none' }));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function Overlay({ title, onClose, children }) {
|
|
76
|
+
return h('div', {
|
|
77
|
+
style: {
|
|
78
|
+
position: 'fixed', inset: 0, zIndex: 60, display: 'flex',
|
|
79
|
+
alignItems: 'center', justifyContent: 'center', background: 'rgba(0,0,0,.42)',
|
|
80
|
+
},
|
|
81
|
+
onClick: onClose,
|
|
82
|
+
}, h('div', {
|
|
83
|
+
onClick: (e) => e.stopPropagation(),
|
|
84
|
+
style: {
|
|
85
|
+
...panel, width: 'min(820px, 94vw)', maxHeight: '80vh', display: 'flex',
|
|
86
|
+
flexDirection: 'column', background: 'var(--dsw-alias-bg, #1a1a1a)',
|
|
87
|
+
boxShadow: '0 18px 48px rgba(0,0,0,.42)',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
h('div', {
|
|
91
|
+
style: { display: 'flex', alignItems: 'center', gap: 8, padding: '12px 16px', borderBottom: border, flexWrap: 'wrap' },
|
|
92
|
+
},
|
|
93
|
+
h('div', { style: { flex: 1, fontSize: 14, display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap' } }, title),
|
|
94
|
+
h('button', { onClick: onClose }, '关闭')),
|
|
95
|
+
h('div', { style: { padding: '12px 16px', overflow: 'auto' } }, children),
|
|
96
|
+
));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function SchedulePage() {
|
|
100
|
+
const [schedule, setSchedule] = useState(null);
|
|
101
|
+
const [state, setState] = useState(null);
|
|
102
|
+
const [updateStatus, setUpdateStatus] = useState(null);
|
|
103
|
+
const [error, setError] = useState('');
|
|
104
|
+
const [busy, setBusy] = useState('');
|
|
105
|
+
const [notice, setNotice] = useState('');
|
|
106
|
+
const [port, setPort] = useState('7890');
|
|
107
|
+
const [dialog, setDialog] = useState(null);
|
|
108
|
+
const [browse, setBrowse] = useState(null);
|
|
109
|
+
const [expanded, setExpanded] = useState({});
|
|
110
|
+
|
|
111
|
+
const load = useCallback(async ({ autoCheck = false } = {}) => {
|
|
112
|
+
try {
|
|
113
|
+
const [s, st] = await Promise.all([getJson('/schedule'), getJson('/state')]);
|
|
114
|
+
setSchedule(s);
|
|
115
|
+
setState(st);
|
|
116
|
+
let up = await getJson('/status');
|
|
117
|
+
const age = up.checkedAt ? Date.now() - new Date(up.checkedAt).getTime() : Infinity;
|
|
118
|
+
if (autoCheck && age > 5 * 60 * 1000 && (up.subscriptions || 0) > 0) {
|
|
119
|
+
try {
|
|
120
|
+
await postJson('/check');
|
|
121
|
+
up = await getJson('/status');
|
|
122
|
+
} catch { /* keep the previous digest */ }
|
|
123
|
+
}
|
|
124
|
+
setUpdateStatus(up);
|
|
125
|
+
setError('');
|
|
126
|
+
} catch (e) {
|
|
127
|
+
setError(e.message);
|
|
128
|
+
}
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
useEffect(() => { load({ autoCheck: true }); }, [load]);
|
|
132
|
+
|
|
133
|
+
const bridge = useCallback(async () => {
|
|
134
|
+
setBusy('bridge');
|
|
135
|
+
setNotice('');
|
|
136
|
+
try {
|
|
137
|
+
const r = await postJson('/bridge', { input: port });
|
|
138
|
+
setNotice(r.ok ? `已桥接:${r.proxy}` : `失败:${r.reason}`);
|
|
139
|
+
await load();
|
|
140
|
+
} catch (e) { setNotice('桥接失败:' + e.message); } finally { setBusy(''); }
|
|
141
|
+
}, [port, load]);
|
|
142
|
+
|
|
143
|
+
const disconnect = useCallback(async () => {
|
|
144
|
+
setBusy('disconnect');
|
|
145
|
+
try { await postJson('/disconnect'); setNotice('已断开,回到直连模式'); await load(); }
|
|
146
|
+
catch (e) { setNotice('断开失败:' + e.message); } finally { setBusy(''); }
|
|
147
|
+
}, [load]);
|
|
148
|
+
|
|
149
|
+
const download = useCallback(async (hash, label) => {
|
|
150
|
+
setBusy('download');
|
|
151
|
+
try {
|
|
152
|
+
const r = await postJson('/download', { hashes: [hash] });
|
|
153
|
+
setNotice(r.ok ? `已加入下载:${label}` : `下载失败:${r.results?.[0]?.message || r.reason}`);
|
|
154
|
+
} catch (e) { setNotice('下载失败:' + e.message); } finally { setBusy(''); }
|
|
155
|
+
}, []);
|
|
156
|
+
|
|
157
|
+
const checkUpdates = useCallback(async () => {
|
|
158
|
+
setBusy('check');
|
|
159
|
+
setNotice('');
|
|
160
|
+
try {
|
|
161
|
+
const r = await postJson('/check');
|
|
162
|
+
setDialog({ type: 'check', title: '更新检查', updates: r.updates || [] });
|
|
163
|
+
window.dispatchEvent(new Event(CHANGED_EVENT));
|
|
164
|
+
await load();
|
|
165
|
+
} catch (e) { setNotice('检查失败:' + e.message); } finally { setBusy(''); }
|
|
166
|
+
}, [load]);
|
|
167
|
+
|
|
168
|
+
const ack = useCallback(async () => {
|
|
169
|
+
try { await postJson('/ack'); } catch { /* ignore */ }
|
|
170
|
+
setDialog(null);
|
|
171
|
+
window.dispatchEvent(new Event(CHANGED_EVENT));
|
|
172
|
+
await load();
|
|
173
|
+
}, [load]);
|
|
174
|
+
|
|
175
|
+
const setSilent = useCallback(async (item, silent) => {
|
|
176
|
+
setBusy('silent');
|
|
177
|
+
try {
|
|
178
|
+
await postJson('/silent', { id: item.id, silent });
|
|
179
|
+
setNotice(silent ? `已静默:${item.title}` : `已恢复:${item.title}`);
|
|
180
|
+
window.dispatchEvent(new Event(CHANGED_EVENT));
|
|
181
|
+
await load();
|
|
182
|
+
} catch (e) { setNotice('操作失败:' + e.message); } finally { setBusy(''); }
|
|
183
|
+
}, [load]);
|
|
184
|
+
|
|
185
|
+
const unsubscribe = useCallback(async (item) => {
|
|
186
|
+
setBusy('unsub');
|
|
187
|
+
try {
|
|
188
|
+
await postJson('/unsubscribe', { id: item.id });
|
|
189
|
+
setNotice(`已取消订阅:${item.title}`);
|
|
190
|
+
window.dispatchEvent(new Event(CHANGED_EVENT));
|
|
191
|
+
await load();
|
|
192
|
+
} catch (e) { setNotice('取消失败:' + e.message); } finally { setBusy(''); }
|
|
193
|
+
}, [load]);
|
|
194
|
+
|
|
195
|
+
/* ---------- browse (three levels) ---------- */
|
|
196
|
+
|
|
197
|
+
const openSeason = useCallback(async (year, season) => {
|
|
198
|
+
const y = year || new Date().getFullYear();
|
|
199
|
+
const s = season || '秋';
|
|
200
|
+
setDialog({ type: 'browse' });
|
|
201
|
+
setBrowse({ level: 'season', year: y, season: s, loading: true, groups: [] });
|
|
202
|
+
try {
|
|
203
|
+
const r = await getJson(`/season-list?year=${y}&season=${encodeURIComponent(s)}`);
|
|
204
|
+
setBrowse({ level: 'season', year: y, season: s, loading: false, groups: r.groups || [] });
|
|
205
|
+
} catch (e) {
|
|
206
|
+
setBrowse({ level: 'season', year: y, season: s, loading: false, groups: [], error: e.message });
|
|
207
|
+
}
|
|
208
|
+
}, []);
|
|
209
|
+
|
|
210
|
+
const openBangumi = useCallback(async (id, title, ctx) => {
|
|
211
|
+
setDialog({ type: 'browse' });
|
|
212
|
+
setBrowse({ level: 'bangumi', bangumiId: id, title, loading: true, subgroups: [], season: ctx?.season, year: ctx?.year, weekday: ctx?.weekday });
|
|
213
|
+
try {
|
|
214
|
+
const r = await getJson(`/bangumi-info?bangumiId=${encodeURIComponent(id)}&title=${encodeURIComponent(title || '')}`);
|
|
215
|
+
setBrowse({
|
|
216
|
+
level: 'bangumi', bangumiId: id, title: r.title || title, season: ctx?.season, year: ctx?.year,
|
|
217
|
+
weekday: r.weekday || ctx?.weekday || '', startDate: r.startDate || '', airDate: r.airDate || '',
|
|
218
|
+
subgroups: r.subgroups || [], hasWorks: r.hasWorks, loading: false,
|
|
219
|
+
});
|
|
220
|
+
} catch (e) {
|
|
221
|
+
setBrowse((b) => ({ ...b, loading: false, error: e.message }));
|
|
222
|
+
}
|
|
223
|
+
}, []);
|
|
224
|
+
|
|
225
|
+
const openWorks = useCallback(async (id, title, subgroup, ctx) => {
|
|
226
|
+
setBrowse((b) => ({
|
|
227
|
+
...b, level: 'works', bangumiId: id, title, season: ctx?.season, year: ctx?.year,
|
|
228
|
+
weekday: ctx?.weekday || b?.weekday || '',
|
|
229
|
+
subgroupId: subgroup.subgroupId, subgroupName: subgroup.name, loading: true, works: [],
|
|
230
|
+
}));
|
|
231
|
+
try {
|
|
232
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(id)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}`);
|
|
233
|
+
setBrowse((b) => ({ ...b, loading: false, works: r.items || [] }));
|
|
234
|
+
} catch (e) {
|
|
235
|
+
setBrowse((b) => ({ ...b, loading: false, works: [], error: e.message }));
|
|
236
|
+
}
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
239
|
+
const subscribeGroup = useCallback(async (subgroup) => {
|
|
240
|
+
if (!browse?.bangumiId || !subgroup) return;
|
|
241
|
+
setBusy('subscribe');
|
|
242
|
+
try {
|
|
243
|
+
const r = await postJson('/subscribe-group', {
|
|
244
|
+
bangumiId: browse.bangumiId,
|
|
245
|
+
title: browse.title,
|
|
246
|
+
season: browse.season || '',
|
|
247
|
+
weekday: browse.weekday || '',
|
|
248
|
+
subgroupId: subgroup.subgroupId || '',
|
|
249
|
+
subgroupName: subgroup.name,
|
|
250
|
+
});
|
|
251
|
+
setNotice(`已订阅:${browse.title} · ${subgroup.name}(从第 ${r.lastSeen} 集开始)`);
|
|
252
|
+
window.dispatchEvent(new Event(CHANGED_EVENT));
|
|
253
|
+
await load();
|
|
254
|
+
} catch (e) { setNotice('订阅失败:' + e.message); } finally { setBusy(''); }
|
|
255
|
+
}, [browse, load]);
|
|
256
|
+
|
|
257
|
+
const isSubscribed = useCallback((subgroup) => {
|
|
258
|
+
const list = schedule ? [...(schedule.days || []).flatMap((d) => d.items), ...(schedule.silent || [])] : [];
|
|
259
|
+
const sub = list.find((s) => s.bangumiId === browse?.bangumiId);
|
|
260
|
+
return Boolean(sub && sub.subgroups.some((g) => g.subgroupId === subgroup.subgroupId || g.name === subgroup.name));
|
|
261
|
+
}, [schedule, browse]);
|
|
262
|
+
|
|
263
|
+
/* ---------- render ---------- */
|
|
264
|
+
|
|
265
|
+
if (error) {
|
|
266
|
+
return h('div', { style: { padding: 24 } },
|
|
267
|
+
h('h2', { style: { margin: '0 0 8px' } }, '追番'),
|
|
268
|
+
h('div', { style: muted }, '加载失败:' + error),
|
|
269
|
+
h('button', { onClick: () => load(), style: { marginTop: 12 } }, '重试'));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const days = schedule?.days || [];
|
|
273
|
+
const total = schedule?.total ?? 0;
|
|
274
|
+
const silentList = schedule?.silent || [];
|
|
275
|
+
const byDay = new Map(days.map((d) => [d.label, d.items]));
|
|
276
|
+
|
|
277
|
+
const breadcrumb = (() => {
|
|
278
|
+
if (!browse) return null;
|
|
279
|
+
const parts = [];
|
|
280
|
+
const seasonLabel = `${browse.year || ''}${browse.season || ''}`;
|
|
281
|
+
if (browse.level === 'season') {
|
|
282
|
+
parts.push(h('strong', { key: 's' }, seasonLabel || '季度概览'));
|
|
283
|
+
} else {
|
|
284
|
+
parts.push(h('a', {
|
|
285
|
+
key: 's', href: '#', onClick: (e) => { e.preventDefault(); openSeason(browse.year, browse.season); },
|
|
286
|
+
style: { cursor: 'pointer', opacity: 0.75 },
|
|
287
|
+
}, seasonLabel || '季度概览'));
|
|
288
|
+
parts.push(h('span', { key: 'x1', style: muted }, '›'));
|
|
289
|
+
if (browse.level === 'bangumi') {
|
|
290
|
+
parts.push(h('strong', { key: 'b' }, browse.title));
|
|
291
|
+
} else {
|
|
292
|
+
parts.push(h('a', {
|
|
293
|
+
key: 'b', href: '#', onClick: (e) => { e.preventDefault(); openBangumi(browse.bangumiId, browse.title, browse); },
|
|
294
|
+
style: { cursor: 'pointer', opacity: 0.75 },
|
|
295
|
+
}, browse.title));
|
|
296
|
+
parts.push(h('span', { key: 'x2', style: muted }, '›'));
|
|
297
|
+
parts.push(h('strong', { key: 'w' }, browse.subgroupName));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return parts;
|
|
301
|
+
})();
|
|
302
|
+
|
|
303
|
+
function renderSeasonBrowse() {
|
|
304
|
+
if (browse.loading) return h('div', { style: muted }, '加载中…');
|
|
305
|
+
if (browse.error) return h('div', { style: muted }, browse.error);
|
|
306
|
+
return h('div', null,
|
|
307
|
+
browse.groups.map((g) => {
|
|
308
|
+
const open = expanded[g.label];
|
|
309
|
+
return h('div', { key: g.label, style: { marginBottom: 16 } },
|
|
310
|
+
h('div', {
|
|
311
|
+
onClick: () => setExpanded((p) => ({ ...p, [g.label]: !open })),
|
|
312
|
+
style: { display: 'flex', alignItems: 'center', gap: 8, cursor: 'pointer', padding: '6px 0', fontWeight: 600, fontSize: 13 },
|
|
313
|
+
},
|
|
314
|
+
h('span', null, g.label),
|
|
315
|
+
h('span', { style: muted }, `(${g.count})`),
|
|
316
|
+
h('span', { style: { ...muted, marginLeft: 'auto' } }, open ? '▾' : '▸')),
|
|
317
|
+
open ? g.items.map((it) => h('div', {
|
|
318
|
+
key: it.id,
|
|
319
|
+
onClick: () => openBangumi(it.id, it.title, browse),
|
|
320
|
+
style: { ...row, cursor: 'pointer', fontSize: 13, paddingLeft: 10 },
|
|
321
|
+
}, it.title)) : null,
|
|
322
|
+
);
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function renderBangumiBrowse() {
|
|
327
|
+
if (browse.loading) return h('div', { style: muted }, '加载中…');
|
|
328
|
+
if (browse.error) return h('div', { style: muted }, browse.error);
|
|
329
|
+
const when = [browse.weekday, browse.startDate ? `开播 ${browse.startDate}` : (browse.airDate ? `开播 ${browse.airDate}` : '')].filter(Boolean).join(' · ');
|
|
330
|
+
return h('div', null,
|
|
331
|
+
h('div', { style: { ...muted, marginBottom: 10 } }, when || '开播时间未知'),
|
|
332
|
+
browse.subgroups.length === 0
|
|
333
|
+
? h('div', { style: muted }, '这个番还没有字幕组上传作品。')
|
|
334
|
+
: browse.subgroups.map((s) => h('div', { key: (s.subgroupId || '') + s.name, style: row },
|
|
335
|
+
h('span', { style: { flex: 1, fontSize: 13 } }, s.name),
|
|
336
|
+
h('button', {
|
|
337
|
+
disabled: busy === 'subscribe' || isSubscribed(s),
|
|
338
|
+
onClick: () => subscribeGroup(s),
|
|
339
|
+
}, isSubscribed(s) ? '✓ 已订阅' : '订阅'),
|
|
340
|
+
h('button', { onClick: () => openWorks(browse.bangumiId, browse.title, s, browse) }, '查看作品'))));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function renderWorksBrowse() {
|
|
344
|
+
const sub = { subgroupId: browse.subgroupId, name: browse.subgroupName };
|
|
345
|
+
return h('div', null,
|
|
346
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, marginBottom: 12 } },
|
|
347
|
+
h('button', {
|
|
348
|
+
disabled: busy === 'subscribe' || isSubscribed(sub),
|
|
349
|
+
onClick: () => subscribeGroup(sub),
|
|
350
|
+
}, isSubscribed(sub) ? '✓ 已订阅本组' : '订阅本组')),
|
|
351
|
+
browse.loading
|
|
352
|
+
? h('div', { style: muted }, '加载中…')
|
|
353
|
+
: (browse.error
|
|
354
|
+
? h('div', { style: muted }, browse.error)
|
|
355
|
+
: (browse.works.length === 0
|
|
356
|
+
? h('div', { style: muted }, '这个字幕组还没有上传作品。')
|
|
357
|
+
: browse.works.map((w) => h('div', { key: w.hash, style: row },
|
|
358
|
+
h('div', { style: { flex: 1 } },
|
|
359
|
+
h('div', { style: { fontSize: 13, lineHeight: 1.35 } }, `[${w.episode || '?'}] ${w.title}`),
|
|
360
|
+
h('div', { style: muted }, `${w.size} · ${w.hash.slice(0, 8)}…`)),
|
|
361
|
+
h('button', { disabled: busy === 'download', onClick: () => download(w.hash, `第 ${w.episode} 集`) }, '下载'))))));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return h('div', { style: { padding: '18px 22px', overflow: 'auto', height: '100%' } },
|
|
365
|
+
h('div', { style: { display: 'flex', alignItems: 'baseline', gap: 12, marginBottom: 12, flexWrap: 'wrap' } },
|
|
366
|
+
h('h2', { style: { margin: 0, fontSize: 20 } }, '追番周历'),
|
|
367
|
+
h('span', { style: muted }, `${total} 部订阅`),
|
|
368
|
+
h('span', { style: { flex: 1 } }),
|
|
369
|
+
h('button', { onClick: () => openSeason(), disabled: Boolean(busy) }, '浏览季度'),
|
|
370
|
+
h('button', { onClick: checkUpdates, disabled: Boolean(busy) }, busy === 'check' ? '检查中…' : '检查更新'),
|
|
371
|
+
h('button', { onClick: () => load(), disabled: Boolean(busy) }, '刷新')),
|
|
372
|
+
|
|
373
|
+
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('span', { style: muted }, '蜜柑 ' + String(state.mikan || '').replace(/^https?:\/\//, '')),
|
|
376
|
+
h(Pill, { ok: state.bgm }, 'bgm ' + (state.bgm ? '可用' : '不可用')),
|
|
377
|
+
h(Pill, { ok: state.bitcomet?.ok }, 'BitComet ' + (state.bitcomet?.ok ? '已连接' : '未连接'))),
|
|
378
|
+
|
|
379
|
+
state && !state.bitcomet?.ok ? h('div', {
|
|
380
|
+
onClick: () => setDialog({ type: 'guide', title: '比特彗星连接指引' }),
|
|
381
|
+
style: {
|
|
382
|
+
...panel, padding: '8px 12px', marginBottom: 12, cursor: 'pointer',
|
|
383
|
+
borderColor: 'var(--dsw-alias-warning, #f08c00)', color: 'var(--dsw-alias-warning, #f08c00)', fontSize: 13,
|
|
384
|
+
},
|
|
385
|
+
}, '⚠ BitComet 未连接 —— 点击查看配置指引') : null,
|
|
386
|
+
|
|
387
|
+
(() => {
|
|
388
|
+
const count = updateStatus?.count || 0;
|
|
389
|
+
const titles = updateStatus?.titles || [];
|
|
390
|
+
const text = count === 0
|
|
391
|
+
? '暂无订阅更新'
|
|
392
|
+
: (count <= 2
|
|
393
|
+
? `您订阅的 ${titles.slice(0, 2).map((t) => `《${t}》`).join('、')} 有更新`
|
|
394
|
+
: `您订阅的 ${count} 部番剧有更新`);
|
|
395
|
+
const color = count === 0
|
|
396
|
+
? 'var(--dsw-alias-success, #2f9e44)'
|
|
397
|
+
: (count <= 2 ? 'var(--dsw-alias-warning, #f08c00)' : 'var(--dsw-alias-danger, #e03131)');
|
|
398
|
+
return h('div', {
|
|
399
|
+
title: count === 0 ? text : text + '(点击查看详情)',
|
|
400
|
+
onClick: count === 0 ? undefined : () => setDialog({ type: 'updates', title: '新集更新' }),
|
|
401
|
+
style: {
|
|
402
|
+
...panel, padding: '8px 12px', marginBottom: 12, display: 'flex', alignItems: 'center', gap: 8,
|
|
403
|
+
whiteSpace: 'nowrap', overflow: 'hidden', cursor: count === 0 ? 'default' : 'pointer',
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
h('span', { style: { width: 7, height: 7, borderRadius: '50%', background: color, flex: '0 0 auto' } }),
|
|
407
|
+
h('span', { style: { fontSize: 13, overflow: 'hidden', textOverflow: 'ellipsis' } }, text));
|
|
408
|
+
})(),
|
|
409
|
+
|
|
410
|
+
h('div', { style: { ...panel, display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center', padding: '10px 12px', marginBottom: 16 } },
|
|
411
|
+
h('label', { style: { fontSize: 13 } }, '代理桥接'),
|
|
412
|
+
h('input', { value: port, onChange: (e) => setPort(e.target.value), placeholder: '7890 或 http://127.0.0.1:7890', style: { width: 220, padding: '6px 8px' } }),
|
|
413
|
+
h('button', { onClick: bridge, disabled: busy === 'bridge' }, busy === 'bridge' ? '桥接中…' : '自动桥接'),
|
|
414
|
+
state?.mode === 'proxy' ? h('button', { onClick: disconnect, disabled: busy === 'disconnect' }, '断开桥接') : null,
|
|
415
|
+
notice ? h('span', { style: muted }, notice) : null),
|
|
416
|
+
|
|
417
|
+
h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(7, minmax(0, 1fr))', gap: 8 } },
|
|
418
|
+
WEEK.map((label) => {
|
|
419
|
+
const items = byDay.get(label) || [];
|
|
420
|
+
return h('div', { key: label, style: { ...panel, padding: '10px 10px 12px', minHeight: 150 } },
|
|
421
|
+
h('div', { style: { fontWeight: 600, marginBottom: 8, fontSize: 13 } }, label),
|
|
422
|
+
items.length === 0
|
|
423
|
+
? h('div', { style: muted }, '—')
|
|
424
|
+
: items.map((item) => h('div', {
|
|
425
|
+
key: item.id,
|
|
426
|
+
onClick: () => openBangumi(item.bangumiId, item.title, { weekday: item.weekday, season: item.season }),
|
|
427
|
+
style: {
|
|
428
|
+
padding: '9px 10px', borderRadius: 8, marginBottom: 22, cursor: 'pointer',
|
|
429
|
+
background: 'var(--dsw-alias-surface-2, rgba(128,128,128,.08))',
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
h('div', { style: { fontSize: 13, lineHeight: 1.35 } }, item.title),
|
|
433
|
+
(item.subgroups || []).length === 0
|
|
434
|
+
? h('div', { style: { ...muted, marginTop: 4 } }, '任意字幕组')
|
|
435
|
+
: item.subgroups.map((g, i) => h('div', { key: (g.subgroupId || '') + i, style: { ...muted, marginTop: 4 } },
|
|
436
|
+
`${g.name} · 已到 ${g.lastSeen}${item.peakEpisode ? ` / 全番 ${item.peakEpisode}` : ''}`)),
|
|
437
|
+
h('div', { style: { display: 'flex', gap: 6, marginTop: 6 } },
|
|
438
|
+
h('button', { style: { fontSize: 11, padding: '2px 7px' }, onClick: (e) => { e.stopPropagation(); setSilent(item, true); } }, '静默'),
|
|
439
|
+
h('button', { style: { fontSize: 11, padding: '2px 7px' }, onClick: (e) => { e.stopPropagation(); unsubscribe(item); } }, '取消订阅')))));
|
|
440
|
+
})),
|
|
441
|
+
|
|
442
|
+
silentList.length > 0 ? h('div', { style: { marginTop: 18 } },
|
|
443
|
+
h('div', { style: { ...muted, marginBottom: 6 } }, `静默关注(${silentList.length})— 已从周表下架,仍会收到更新`),
|
|
444
|
+
silentList.map((item) => h('div', { key: item.id, style: row },
|
|
445
|
+
h('span', { style: { flex: 1, fontSize: 13 } }, item.title),
|
|
446
|
+
h('span', { style: muted }, (item.subgroups || []).map((g) => g.name).join('、') || '任意字幕组'),
|
|
447
|
+
h('button', { style: { fontSize: 11, padding: '2px 7px' }, onClick: () => setSilent(item, false) }, '恢复'),
|
|
448
|
+
h('button', { style: { fontSize: 11, padding: '2px 7px' }, onClick: () => unsubscribe(item) }, '取消订阅'))),
|
|
449
|
+
) : null,
|
|
450
|
+
|
|
451
|
+
total === 0 && silentList.length === 0
|
|
452
|
+
? h('div', { style: { ...muted, marginTop: 16 } }, '还没有订阅。点「浏览季度」找番剧,或去对话里说「追某某番的某个字幕组」。')
|
|
453
|
+
: h('div', { style: { ...muted, marginTop: 12 } }, '点番剧卡片可查看字幕组与作品;卡片上可「静默」或「取消订阅」。'),
|
|
454
|
+
|
|
455
|
+
dialog && dialog.type === 'browse' && browse ? h(Overlay, {
|
|
456
|
+
title: breadcrumb,
|
|
457
|
+
onClose: () => { setDialog(null); setBrowse(null); },
|
|
458
|
+
}, browse.level === 'season' ? renderSeasonBrowse() : browse.level === 'bangumi' ? renderBangumiBrowse() : renderWorksBrowse()) : null,
|
|
459
|
+
|
|
460
|
+
dialog && dialog.type === 'updates' ? h(Overlay, {
|
|
461
|
+
title: '新集更新', onClose: () => setDialog(null),
|
|
462
|
+
}, h('div', null,
|
|
463
|
+
(updateStatus?.details || []).length === 0
|
|
464
|
+
? h('div', { style: muted }, '暂无新集。')
|
|
465
|
+
: (updateStatus.details || []).map((u) => h('div', { key: u.id + u.subgroupName, style: { marginBottom: 16 } },
|
|
466
|
+
h('div', { style: { fontWeight: 600, fontSize: 13, marginBottom: 6 } },
|
|
467
|
+
`${u.title} · ${u.subgroupName}`,
|
|
468
|
+
h('span', { style: { ...muted, marginLeft: 8 } }, `已到 ${u.lastSeen}${u.peak ? ` / 全番 ${u.peak}` : ''}`)),
|
|
469
|
+
(u.episodes || []).map((e, i) => h('div', { key: i, style: row },
|
|
470
|
+
h('div', { style: { flex: 1 } },
|
|
471
|
+
h('div', { style: { fontSize: 13, lineHeight: 1.35 } }, e.title),
|
|
472
|
+
h('div', { style: muted }, `${e.size} · ${String(e.hash || '').slice(0, 8)}…`)),
|
|
473
|
+
h('button', { onClick: () => download(e.hash, `${u.title} 第${e.episode}集`) }, '下载'))))),
|
|
474
|
+
h('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 18 } },
|
|
475
|
+
h('button', { onClick: () => setDialog(null) }, '暂时挂起'),
|
|
476
|
+
h('button', { onClick: ack }, '我知道了')))) : null,
|
|
477
|
+
|
|
478
|
+
dialog && dialog.type === 'check' ? h(Overlay, {
|
|
479
|
+
title: '更新检查', onClose: () => setDialog(null),
|
|
480
|
+
}, h('div', null,
|
|
481
|
+
(dialog.updates || []).length === 0
|
|
482
|
+
? h('div', { style: muted }, '没有新集。')
|
|
483
|
+
: dialog.updates.map((u) => h('div', { key: u.id + u.subgroupName, style: { marginBottom: 14 } },
|
|
484
|
+
h('div', { style: { fontWeight: 600, fontSize: 13, marginBottom: 6 } }, `${u.title} · ${u.subgroupName}`),
|
|
485
|
+
(u.episodes || []).map((e, i) => h('div', { key: i, style: row },
|
|
486
|
+
h('div', { style: { flex: 1 } },
|
|
487
|
+
h('div', { style: { fontSize: 13 } }, e.title),
|
|
488
|
+
h('div', { style: muted }, `${e.size}`)),
|
|
489
|
+
h('button', { onClick: () => download(e.hash, `${u.title} 第${e.episode}集`) }, '下载'))))))) : null,
|
|
490
|
+
|
|
491
|
+
dialog && dialog.type === 'guide' ? h(Overlay, {
|
|
492
|
+
title: '比特彗星连接指引', onClose: () => setDialog(null),
|
|
493
|
+
}, h('div', null,
|
|
494
|
+
h('ol', { style: { paddingLeft: 20, lineHeight: 1.95, fontSize: 13, margin: 0 } },
|
|
495
|
+
h('li', null, '打开 BitComet → 选项 → 远程访问'),
|
|
496
|
+
h('li', null, '「监听端口」填固定值,例如 10816(不要用 0 或随机端口)'),
|
|
497
|
+
h('li', null, '勾选「启用网页版远程访问」'),
|
|
498
|
+
h('li', null, '不要勾「始终使用 HTTPS」'),
|
|
499
|
+
h('li', null, '设置「用户名 / 密码」——插件会自动从 BitComet 配置文件读取'),
|
|
500
|
+
h('li', null, '不要勾「执行远程访问操作时显示提示窗口」'),
|
|
501
|
+
h('li', null, '点击「应用」保存'),
|
|
502
|
+
h('li', null, '回到这里点下面的按钮')),
|
|
503
|
+
h('div', { style: { ...muted, marginTop: 14 } }, '插件不会自己启动或关闭 BitComet,请保持它运行。'),
|
|
504
|
+
h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8, marginTop: 18 } },
|
|
505
|
+
h('button', { onClick: () => setDialog(null) }, '关闭'),
|
|
506
|
+
h('button', {
|
|
507
|
+
onClick: async () => {
|
|
508
|
+
setBusy('scan');
|
|
509
|
+
try {
|
|
510
|
+
const r = await postJson('/bitcomet-scan');
|
|
511
|
+
setNotice(r.ok ? `已连接 BitComet:端口 ${r.port}` : `未找到端口:${r.reason}`);
|
|
512
|
+
await load();
|
|
513
|
+
} catch (e) { setNotice('扫描失败:' + e.message); } finally { setBusy(''); }
|
|
514
|
+
setDialog(null);
|
|
515
|
+
},
|
|
516
|
+
}, busy === 'scan' ? '扫描中…' : '自动扫描端口'),
|
|
517
|
+
h('button', {
|
|
518
|
+
onClick: async () => { setBusy('probe'); try { await load(); } finally { setBusy(''); setDialog(null); } },
|
|
519
|
+
}, busy === 'probe' ? '检测中…' : '重新检测')))) : null,
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return {
|
|
524
|
+
inject: ['slots'],
|
|
525
|
+
apply(ctx) {
|
|
526
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
527
|
+
name: 'sidebar.panellist', id: 'mikan', order: 60, label: '追番',
|
|
528
|
+
}, (owner = {}) => h(MikanIcon, { size: owner.size })));
|
|
529
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
530
|
+
name: 'main', key: 'mikan',
|
|
531
|
+
}, () => h(SchedulePage)));
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
},
|
|
535
|
+
});
|