dsh-learning-assistant 0.0.1 → 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.
Files changed (69) hide show
  1. package/README.md +41 -7
  2. package/assets/collect/README.md +55 -0
  3. package/assets/skills/course-inbox-sync.md +182 -0
  4. package/assets/skills/course-material-digest.md +173 -0
  5. package/assets/skills/one-to-one-tutor.md +320 -0
  6. package/assets/tools/pdf/pdf-render.ps1 +30 -0
  7. package/assets/tools/pptx-digest.py +99 -0
  8. package/assets/tools/pptx-map.py +98 -0
  9. package/assets/tools/pptx-media.py +101 -0
  10. package/assets/tools/qq-group-msg.py +258 -0
  11. package/assets/tools/qq-group-sync.py +265 -0
  12. package/docs//345/215/217/344/275/234/345/274/200/345/217/221.md +18 -10
  13. package/lib/client.js +110 -0
  14. package/lib/{index.d.mts → index.d.ts} +3 -1
  15. package/lib/index.js +392 -0
  16. package/package.json +8 -7
  17. package/src/client/settings.tsx +6 -4
  18. package/src/index.ts +36 -11
  19. package/src/practice/learn/api.mjs +393 -0
  20. package/src/practice/learn/cli.mjs +175 -0
  21. package/src/practice/learn/curriculum.mjs +292 -0
  22. package/src/practice/learn/handoff.mjs +73 -0
  23. package/src/practice/learn/jsonschema.mjs +171 -0
  24. package/src/practice/learn/mapping.mjs +90 -0
  25. package/src/practice/learn/progress.mjs +247 -0
  26. package/src/practice/learn/schema/curriculum.schema.json +88 -0
  27. package/src/practice/learn/schema/handoff.schema.json +56 -0
  28. package/src/practice/learn/schema/node-practice-map.schema.json +28 -0
  29. package/src/practice/learn/schema/progress.schema.json +66 -0
  30. package/src/practice/learn/schemas.mjs +53 -0
  31. package/src/practice/learn/store.mjs +247 -0
  32. package/src/practice/public/app.js +883 -0
  33. package/src/practice/public/index.html +19 -0
  34. package/src/practice/public/ink.js +349 -0
  35. package/src/practice/public/learn.css +20 -0
  36. package/src/practice/public/learn.js +329 -0
  37. package/src/practice/public/style.css +326 -0
  38. package/src/practice/public/vendor/katex/contrib/auto-render.min.js +1 -0
  39. package/src/practice/public/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  40. package/src/practice/public/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  41. package/src/practice/public/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  42. package/src/practice/public/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  43. package/src/practice/public/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  44. package/src/practice/public/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  45. package/src/practice/public/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  46. package/src/practice/public/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  47. package/src/practice/public/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  48. package/src/practice/public/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  49. package/src/practice/public/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  50. package/src/practice/public/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  51. package/src/practice/public/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  52. package/src/practice/public/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  53. package/src/practice/public/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  54. package/src/practice/public/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  55. package/src/practice/public/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  56. package/src/practice/public/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  57. package/src/practice/public/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  58. package/src/practice/public/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  59. package/src/practice/public/vendor/katex/katex.min.css +1 -0
  60. package/src/practice/public/vendor/katex/katex.min.js +1 -0
  61. package/src/practice//346/234/215/345/212/241.mjs +443 -0
  62. package/src/practice//346/240/241/351/252/214/351/242/230/347/233/256.mjs +114 -0
  63. package/src/practice//347/255/211/345/276/205/346/217/220/344/272/244.mjs +100 -0
  64. package/src/practice-service.ts +99 -0
  65. package/src/practice-tool.ts +91 -0
  66. package/src/skills.ts +156 -0
  67. package/lib/client.d.mts +0 -10
  68. package/lib/client.mjs +0 -87
  69. package/lib/index.mjs +0 -29
@@ -0,0 +1,329 @@
1
+ /* 学习助手前端:课程计划 / 路线图 / 进度。
2
+ *
3
+ * 独立文件,不改 app.js 的既有视图逻辑;app.js 只在路由表里把 #/learn* 交给 window.__LEARN__。
4
+ * 硬规则(对应方案 §2、§4):
5
+ * - 草案未确认前,页面绝不显示为「已生效计划」
6
+ * - 浏览器上的分数不构成掌握判定:本文件**不提供任何写 mastered 的按钮**
7
+ * - 材料缺失显示「缺失」,不编造内容
8
+ */
9
+ (() => {
10
+ 'use strict';
11
+
12
+ const $ = (sel, root) => (root || document).querySelector(sel);
13
+ const app = $('#app');
14
+
15
+ const el = (tag, props, ...kids) => {
16
+ const n = document.createElement(tag);
17
+ if (props) {
18
+ for (const [k, v] of Object.entries(props)) {
19
+ if (v === null || v === undefined || v === false) continue;
20
+ if (k === 'class') n.className = v;
21
+ else if (k === 'html') n.innerHTML = v;
22
+ else if (k.startsWith('on') && typeof v === 'function') n.addEventListener(k.slice(2), v);
23
+ else if (k === 'dataset') Object.assign(n.dataset, v);
24
+ else n.setAttribute(k, v === true ? '' : String(v));
25
+ }
26
+ }
27
+ for (const kid of kids.flat()) {
28
+ if (kid === null || kid === undefined || kid === false) continue;
29
+ n.appendChild(kid instanceof Node ? kid : document.createTextNode(String(kid)));
30
+ }
31
+ return n;
32
+ };
33
+
34
+ function tex(node) {
35
+ if (!window.renderMathInElement) return node;
36
+ try {
37
+ window.renderMathInElement(node, {
38
+ delimiters: [
39
+ { left: '$$', right: '$$', display: true },
40
+ { left: '\\[', right: '\\]', display: true },
41
+ { left: '$', right: '$', display: false },
42
+ { left: '\\(', right: '\\)', display: false },
43
+ ],
44
+ throwOnError: false,
45
+ ignoredTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
46
+ });
47
+ } catch (_) { /* 单条公式写坏不影响整页 */ }
48
+ return node;
49
+ }
50
+
51
+ function toast(msg, ms) {
52
+ const t = $('.toast') || el('div', { class: 'toast' });
53
+ if (!t.parentNode) document.body.appendChild(t);
54
+ t.textContent = msg;
55
+ t.classList.add('on');
56
+ clearTimeout(toast._t);
57
+ toast._t = setTimeout(() => t.classList.remove('on'), ms || 2200);
58
+ }
59
+
60
+ async function api(p, opt) {
61
+ let r;
62
+ try { r = await fetch(p, opt); }
63
+ catch { throw new Error('连不上练习台服务。请确认服务在运行。'); }
64
+ const j = await r.json().catch(() => ({ error: 'bad json' }));
65
+ if (!r.ok) throw new Error(j.error || r.statusText);
66
+ return j;
67
+ }
68
+
69
+ const fmtTime = (iso) => {
70
+ if (!iso) return '—';
71
+ const d = new Date(iso);
72
+ if (isNaN(d)) return String(iso);
73
+ const p = (n) => String(n).padStart(2, '0');
74
+ return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
75
+ };
76
+
77
+ const STATUS_LABEL = { not_started: '未开始', in_progress: '学习中', mastered: '已掌握', needs_review: '待复习' };
78
+ const STATUS_CLASS = { not_started: 'mute', in_progress: '', mastered: 'ok', needs_review: 'warn' };
79
+ const KIND_LABEL = { concept: '讲解', practice: '练习', review: '复习' };
80
+
81
+ function topbar(title, sub, ...actions) {
82
+ return el('div', { class: 'topbar' },
83
+ el('div', { class: 'grow', style: 'flex:1;min-width:0' },
84
+ el('h1', {}, title),
85
+ sub ? el('div', { class: 'sub' }, sub) : null),
86
+ ...actions);
87
+ }
88
+
89
+ const go = (hash) => { location.hash = hash; };
90
+ const goHome = () => go('#/');
91
+
92
+ /* ---------- 科目列表 ---------- */
93
+
94
+ async function viewLearnHome() {
95
+ app.replaceChildren(topbar('课程计划', '学习助手:计划与掌握进度(与题库练习分开存储)',
96
+ el('button', { class: 'btn ghost', onclick: goHome }, '返回练习台')));
97
+ const box = el('div', {}, el('div', { class: 'empty' }, '加载中…'));
98
+ app.appendChild(box);
99
+
100
+ let items = [];
101
+ try { items = (await api('/api/learn/subjects')).items || []; }
102
+ catch (e) { box.replaceChildren(el('div', { class: 'empty' }, '读不到课程计划:' + e.message)); return; }
103
+
104
+ if (!items.length) {
105
+ box.replaceChildren(el('div', { class: 'empty' },
106
+ '还没有课程计划。学习助手不会自动建课——需要你明确选定一门课,再生成计划草案并由你确认。'));
107
+ return;
108
+ }
109
+
110
+ box.replaceChildren();
111
+ for (const it of items) {
112
+ const s = it.summary || {};
113
+ box.appendChild(el('div', { class: 'card', style: 'padding:14px' },
114
+ el('div', { class: 'course-head' },
115
+ el('strong', {}, it.title || it.subject_id),
116
+ el('span', { class: 'badge ' + (it.active ? 'ok' : 'warn') }, it.active ? `已生效 r${it.revision}` : `草案 r${it.revision}(未生效)`),
117
+ it.has_draft ? el('span', { class: 'badge warn' }, '有待确认草案') : null,
118
+ it.fixture ? el('span', { class: 'badge mute' }, '测试数据') : null),
119
+ el('div', { class: 'hint', style: 'margin:6px 0' }, it.goal || '(未写课程目标)'),
120
+ el('div', { class: 'rec', style: 'gap:8px;flex-wrap:wrap' },
121
+ el('span', { class: 'badge ok' }, `已掌握 ${s.mastered || 0}`),
122
+ el('span', { class: 'badge' }, `学习中 ${s.in_progress || 0}`),
123
+ s.needs_review ? el('span', { class: 'badge warn' }, `待复习 ${s.needs_review}`) : null,
124
+ el('span', { class: 'badge mute' }, `共 ${s.total || 0} 节点`),
125
+ s.current_node ? el('span', { class: 'hint' }, `当前:${s.current_node.title}`) : null),
126
+ el('div', { class: 'foot', style: 'margin-top:10px' },
127
+ el('button', { class: 'btn primary', onclick: () => go('#/learn/' + encodeURIComponent(it.subject_id)) }, '打开课程页'))));
128
+ }
129
+ }
130
+
131
+ /* ---------- 单科课程页 ---------- */
132
+
133
+ let fold = { roadmap: true, materials: true };
134
+
135
+ async function viewSubject(subjectId, focusNodeId) {
136
+ app.replaceChildren(topbar('课程页', '加载中…', el('button', { class: 'btn ghost', onclick: () => go('#/learn') }, '所有课程')));
137
+ let v;
138
+ try { v = await api('/api/learn/subject?subject=' + encodeURIComponent(subjectId)); }
139
+ catch (e) {
140
+ app.replaceChildren(topbar('课程页', subjectId, el('button', { class: 'btn ghost', onclick: () => go('#/learn') }, '所有课程')),
141
+ el('div', { class: 'empty' }, e.message));
142
+ return;
143
+ }
144
+
145
+ const s = v.summary || {};
146
+ const plan = v.plan || {};
147
+ const header = topbar(plan.title || subjectId,
148
+ [plan.goal, `revision ${plan.revision}`, plan.active ? '已生效' : '草案(未生效)'].filter(Boolean).join(' · '),
149
+ el('button', { class: 'btn ghost', onclick: () => go('#/learn') }, '所有课程'),
150
+ el('button', { class: 'btn ghost', onclick: () => location.reload() }, '刷新'));
151
+
152
+ const top = el('div', { class: 'card' },
153
+ el('div', { class: 'rec', style: 'gap:8px;flex-wrap:wrap' },
154
+ el('span', { class: 'badge ' + (plan.active ? 'ok' : 'warn') }, plan.active ? '计划已生效' : '计划草案未生效'),
155
+ el('span', { class: 'badge ok' }, `已掌握 ${s.mastered || 0}`),
156
+ el('span', { class: 'badge' }, `学习中 ${s.in_progress || 0}`),
157
+ el('span', { class: 'badge warn' }, `待复习 ${s.needs_review || 0}`),
158
+ el('span', { class: 'badge mute' }, `未开始 ${s.not_started || 0}`),
159
+ el('span', { class: 'badge mute' }, `共 ${s.total || 0}`)),
160
+ el('div', { class: 'hint', style: 'margin-top:8px' },
161
+ `当前节点:${s.current_node ? `${s.current_node.title}(${s.current_node.id})` : '—'} · 创建 ${fmtTime(plan.created_at)} · 更新 ${fmtTime(plan.updated_at)}` +
162
+ (plan.confirmed_at ? ` · 确认于 ${fmtTime(plan.confirmed_at)}(${plan.confirmed_by || '—'})` : '')),
163
+ plan.change_note ? el('div', { class: 'hint' }, '变更说明:' + plan.change_note) : null,
164
+ v.draft ? el('div', { style: 'margin-top:10px' },
165
+ el('div', { class: 'badge warn' }, `⚠️ 有待确认的重规划草案 r${v.draft.revision}(基于 r${v.draft.based_on})`),
166
+ el('pre', { class: 'hint', style: 'white-space:pre-wrap;margin:8px 0' }, v.draft.diff),
167
+ el('div', { class: 'hint' }, '未经你确认,上面的草案不会影响当前生效计划与已有掌握记录。'),
168
+ el('div', { class: 'foot', style: 'margin-top:8px' },
169
+ el('button', {
170
+ class: 'btn primary',
171
+ onclick: async (ev) => {
172
+ ev.target.disabled = true;
173
+ try {
174
+ await api('/api/learn/accept', {
175
+ method: 'POST', headers: { 'content-type': 'application/json' },
176
+ body: JSON.stringify({ subject: subjectId, expected_revision: v.draft.revision, by: 'user' }),
177
+ });
178
+ toast('已确认,新计划生效');
179
+ location.reload();
180
+ } catch (e) { ev.target.disabled = false; toast('确认失败:' + e.message, 4000); }
181
+ },
182
+ }, '确认这份草案,使其生效'),
183
+ el('span', { class: 'grow' }),
184
+ el('span', { class: 'hint' }, '旧版本会保留在 学习助手数据/_history/ 下'))) : null,
185
+ v.plan.missing && v.plan.missing.length ? el('div', { class: 'hint', style: 'margin-top:8px' },
186
+ '⚠️ 缺材料:' + v.plan.missing.join('、')) : null,
187
+ plan.open_questions && plan.open_questions.length ? el('div', { class: 'hint', style: 'margin-top:6px' },
188
+ '待澄清:' + plan.open_questions.join(';')) : null);
189
+
190
+ app.replaceChildren(header, top, continuePanel(subjectId, v));
191
+
192
+ /* 路线图 */
193
+ const roadmap = el('div', { class: 'card' },
194
+ el('div', { class: 'course-head' },
195
+ el('strong', {}, '学习路线'),
196
+ el('span', { class: 'grow' }),
197
+ el('button', {
198
+ class: 'btn ghost',
199
+ onclick: (ev) => { fold.roadmap = !fold.roadmap; ev.target.textContent = fold.roadmap ? '展开' : '收起'; list.style.display = fold.roadmap ? '' : 'none'; },
200
+ }, fold.roadmap ? '收起' : '展开')));
201
+ const list = el('div', { style: fold.roadmap ? '' : 'display:none' });
202
+ roadmap.appendChild(list);
203
+ app.appendChild(roadmap);
204
+
205
+ for (const n of v.nodes) list.appendChild(nodeCard(v, n, focusNodeId));
206
+
207
+ if (v.detached && Object.keys(v.detached).length) {
208
+ app.appendChild(el('div', { class: 'card' },
209
+ el('div', { class: 'hint' }, '已移出当前计划的旧节点(成绩保留,未删除):' +
210
+ Object.keys(v.detached).map((k) => `${k}(${STATUS_LABEL[v.detached[k].status] || v.detached[k].status})`).join('、'))));
211
+ }
212
+
213
+ /* 数据位置(透明) */
214
+ app.appendChild(el('div', { class: 'hint', style: 'margin-top:12px' },
215
+ `数据目录:${v.data_root || '(未知)'} · 计划与进度分开存储,进度是掌握状态的唯一权威来源`));
216
+ }
217
+
218
+ /* ---------- 继续学习 ---------- */
219
+
220
+ // 上下文包机制已停用(2026-10-20):进度以 学习助手数据 的 progress.json 与
221
+ // 知识整理 的《_学习进度.md》为准,不再生成/落盘 当前上下文.md,也不用手工交接。
222
+ function continuePanel(subjectId, v) {
223
+ const cur = (v.summary && v.summary.current_node) || null;
224
+ const nodeId = cur ? cur.id : (v.nodes[0] ? v.nodes[0].id : '');
225
+ const box = el('div', { class: 'card' });
226
+ box.appendChild(el('div', { class: 'course-head' },
227
+ el('strong', {}, '继续学习'),
228
+ el('span', { class: 'grow' }),
229
+ el('span', { class: 'badge mute' }, v.plan.active ? '计划已生效' : '计划未生效')));
230
+ box.appendChild(el('div', { class: 'hint', style: 'margin:6px 0' },
231
+ cur ? `当前节点:${cur.title}(${nodeId})` : '当前没有可学的节点。'));
232
+ box.appendChild(el('div', { class: 'hint' },
233
+ '「继续学习」会走唯一的一对一讲解流程:先讲本节目标与核心讲解,再让你到练习台做题,提交后我批改,达标才推进。'));
234
+ box.appendChild(el('div', { class: 'hint', style: 'margin-top:8px' },
235
+ '📌 进度看两个地方就够:本页的节点状态(来自 progress.json)和 知识整理\\ 里的《_学习进度.md》。' +
236
+ '新开 DSH 会话后直接说「继续学习 ' + subjectId + '」,我会先读这两处再接着讲。'));
237
+ return box;
238
+ }
239
+
240
+ function nodeCard(v, n, focusNodeId) {
241
+ const focus = focusNodeId && focusNodeId === n.id;
242
+ const card = el('div', { class: 'card', style: 'padding:12px 14px' + (focus ? ';outline:2px solid var(--accent)' : '') });
243
+ const stCls = STATUS_CLASS[n.status] || 'mute';
244
+ card.appendChild(el('div', { class: 'qhead' },
245
+ el('span', { class: 'tag ' + (n.kind === 'practice' ? 'mid' : n.kind === 'review' ? 'hard' : 'easy') }, KIND_LABEL[n.kind] || n.kind),
246
+ el('span', { class: 'badge ' + stCls }, STATUS_LABEL[n.status] || n.status),
247
+ el('span', { class: 'grow', style: 'flex:1' }, el('strong', {}, n.title)),
248
+ el('span', { class: 'hint' }, `${n.id} · ${n.estimated_minutes} 分钟`)));
249
+ card.appendChild(el('div', { class: 'hint', style: 'margin:6px 0' }, n.objective));
250
+ if (n.prerequisites.length) {
251
+ card.appendChild(el('div', { class: 'hint' }, '先修:' + n.prerequisites.join('、')));
252
+ }
253
+ if (n.lock_reason) card.appendChild(el('div', { class: 'badge warn', style: 'margin-top:6px' }, '🔒 ' + n.lock_reason));
254
+ if (n.last_score !== null && n.last_score !== undefined) {
255
+ card.appendChild(el('div', { class: 'hint' }, `最近成绩 ${Math.round(n.last_score * 100)}% · 作答 ${n.attempts} 次 · ${fmtTime(n.last_studied_at)}`));
256
+ }
257
+ if (n.misconception_refs && n.misconception_refs.length) {
258
+ card.appendChild(el('div', { class: 'hint' }, '已知错因:' + n.misconception_refs.join('、')));
259
+ }
260
+ if (n.mastered_at) card.appendChild(el('div', { class: 'hint' }, `掌握判定时间:${fmtTime(n.mastered_at)}`));
261
+
262
+ /* 材料:引用先如实列出(含缺失标注),正文按需展开 */
263
+ if (n.source_refs && n.source_refs.length) {
264
+ card.appendChild(el('div', { style: 'margin-top:8px' },
265
+ el('div', { class: 'hint' }, '来源材料(本节点唯一允许读取的出处)'),
266
+ ...n.source_refs.map((r) => el('div', { class: 'hint', style: 'margin:2px 0' },
267
+ el('span', { class: 'badge ' + (r.missing ? 'bad' : 'mute') }, r.missing ? '缺失' : '可读'),
268
+ ' ',
269
+ el('span', {}, `${r.path} —— ${r.location}`),
270
+ r.missing ? el('span', { class: 'hint' }, '(文件不存在:页面不会编造内容,需补材料或改引用)') : null))));
271
+ const matBox = el('div', { style: 'margin-top:8px' });
272
+ card.appendChild(matBox);
273
+ const btn = el('button', {
274
+ class: 'btn ghost',
275
+ onclick: async (ev) => {
276
+ if (matBox.dataset.open === '1') {
277
+ matBox.dataset.open = '0';
278
+ [...matBox.querySelectorAll('.mat')].forEach((x) => x.remove());
279
+ ev.target.textContent = '查看来源材料';
280
+ return;
281
+ }
282
+ matBox.dataset.open = '1';
283
+ ev.target.textContent = '收起材料';
284
+ for (const r of n.source_refs) {
285
+ const wrap = el('div', { class: 'mat', style: 'margin-top:8px' },
286
+ el('div', { class: 'hint' }, `${r.path} —— ${r.location}`));
287
+ matBox.appendChild(wrap);
288
+ try {
289
+ const m = await api('/api/learn/material?limit=4000&path=' + encodeURIComponent(r.path) + '&location=' + encodeURIComponent(r.location));
290
+ if (m.missing) wrap.appendChild(el('div', { class: 'badge bad' }, '材料缺失:文件不存在,页面不会编造内容'));
291
+ else {
292
+ wrap.appendChild(el('pre', {
293
+ class: 'hint',
294
+ style: 'white-space:pre-wrap;max-height:320px;overflow:auto;background:var(--bg);padding:8px;border-radius:8px;margin:6px 0',
295
+ }, m.text + (m.truncated ? '\n…(已截断,完整内容见原文件)' : '')));
296
+ wrap.appendChild(el('a', { class: 'hint', href: '/api/learn/material?raw=1&path=' + encodeURIComponent(r.path), target: '_blank' }, '在新标签打开完整文件'));
297
+ }
298
+ } catch (e) { wrap.appendChild(el('div', { class: 'badge bad' }, '读取失败:' + e.message)); }
299
+ }
300
+ },
301
+ }, '查看来源材料');
302
+ card.appendChild(btn);
303
+ } else {
304
+ card.appendChild(el('div', { class: 'hint', style: 'margin-top:6px' }, '(本节点未登记来源材料)'));
305
+ }
306
+
307
+ /* 练习与答卷:只读展示,不给「判掌握」按钮 */
308
+ const links = n.linked_practices || [];
309
+ if (links.length) {
310
+ card.appendChild(el('div', { style: 'margin-top:8px' },
311
+ el('div', { class: 'hint' }, '关联练习(成绩来自练习台记录)'),
312
+ ...links.map((l) => el('button', {
313
+ class: 'btn ghost',
314
+ onclick: () => go('#/p/' + encodeURIComponent(l.course) + '/' + encodeURIComponent(l.practice_id)),
315
+ }, `${l.course} / ${l.practice_id}`))));
316
+ }
317
+ return card;
318
+ }
319
+
320
+ /* ---------- 导出 ---------- */
321
+
322
+ window.__LEARN__ = {
323
+ render(route) {
324
+ if (route.name === 'learn' && !route.subject) return void viewLearnHome();
325
+ if (route.name === 'learn' && route.subject) return void viewSubject(route.subject, route.node || null);
326
+ return void viewLearnHome();
327
+ },
328
+ };
329
+ })();
@@ -0,0 +1,326 @@
1
+ /* 练习台样式:自带明暗主题(iframe 内拿不到宿主 token),跟随系统偏好 */
2
+ :root {
3
+ --bg: #f7f7f5;
4
+ --panel: #ffffff;
5
+ --text: #1f2328;
6
+ --muted: #6b7280;
7
+ --line: #e3e4e8;
8
+ --accent: #2f6feb;
9
+ --accent-soft: #e8f0fe;
10
+ --ok: #1a7f43;
11
+ --ok-soft: #e6f4ea;
12
+ --bad: #c0392b;
13
+ --bad-soft: #fdecea;
14
+ --warn: #9a6700;
15
+ --warn-soft: #fff8e1;
16
+ --radius: 10px;
17
+ }
18
+ @media (prefers-color-scheme: dark) {
19
+ :root {
20
+ --bg: #1a1b1e;
21
+ --panel: #232428;
22
+ --text: #e6e6e6;
23
+ --muted: #9aa0a6;
24
+ --line: #35373c;
25
+ --accent: #6ea8fe;
26
+ --accent-soft: #1e2a42;
27
+ --ok: #6bd08a;
28
+ --ok-soft: #16301f;
29
+ --bad: #ff8b7d;
30
+ --bad-soft: #3a1d1a;
31
+ --warn: #e5c07b;
32
+ --warn-soft: #332b16;
33
+ }
34
+ }
35
+
36
+ * { box-sizing: border-box; }
37
+ html, body { margin: 0; padding: 0; }
38
+ body {
39
+ background: var(--bg);
40
+ color: var(--text);
41
+ font: 15px/1.65 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
42
+ -webkit-font-smoothing: antialiased;
43
+ }
44
+ #app { max-width: 780px; margin: 0 auto; padding: 16px 18px 64px; }
45
+
46
+ /* 顶栏 */
47
+ .topbar {
48
+ display: flex; align-items: center; gap: 10px;
49
+ padding: 10px 0 14px; position: sticky; top: 0;
50
+ background: linear-gradient(var(--bg) 70%, transparent);
51
+ z-index: 5;
52
+ }
53
+ .topbar h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 650; letter-spacing: .3px; }
54
+ .topbar .sub { font-size: 12px; color: var(--muted); font-weight: 400; }
55
+ .btn {
56
+ font: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
57
+ background: var(--panel); color: var(--text);
58
+ border: 1px solid var(--line); border-radius: 8px;
59
+ transition: background .12s, border-color .12s;
60
+ }
61
+ .btn:hover { border-color: var(--accent); }
62
+ .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
63
+ .btn.primary:hover { filter: brightness(1.08); }
64
+ .btn:disabled { opacity: .45; cursor: not-allowed; }
65
+ .btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
66
+ .btn.ghost:hover { color: var(--text); border-color: var(--line); }
67
+
68
+ /* 卡片 */
69
+ .card {
70
+ background: var(--panel); border: 1px solid var(--line);
71
+ border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
72
+ }
73
+ .card h2 { font-size: 15px; margin: 0 0 4px; }
74
+ .card .meta { font-size: 12.5px; color: var(--muted); }
75
+ .course-head {
76
+ font-size: 12.5px; font-weight: 700; color: var(--muted);
77
+ letter-spacing: .6px; margin: 22px 0 8px; text-transform: none;
78
+ }
79
+ .course-head:first-child { margin-top: 4px; }
80
+
81
+ /* 题库条目 */
82
+ .item {
83
+ display: flex; align-items: center; gap: 12px; cursor: pointer;
84
+ background: var(--panel); border: 1px solid var(--line);
85
+ border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
86
+ transition: border-color .12s, transform .08s;
87
+ }
88
+ .item:hover { border-color: var(--accent); }
89
+ .item:active { transform: scale(.995); }
90
+ .item .grow { flex: 1; min-width: 0; }
91
+ .item .name { font-weight: 600; }
92
+ .item .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
93
+ .badge {
94
+ font-size: 11.5px; padding: 3px 8px; border-radius: 999px;
95
+ background: var(--accent-soft); color: var(--accent); font-weight: 600; white-space: nowrap;
96
+ }
97
+ .badge.ok { background: var(--ok-soft); color: var(--ok); }
98
+ .badge.bad { background: var(--bad-soft); color: var(--bad); }
99
+ .badge.mute { background: transparent; color: var(--muted); border: 1px solid var(--line); }
100
+
101
+ /* 进度条 */
102
+ .bar { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 12px 0 4px; }
103
+ .bar > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
104
+
105
+ /* 题干 */
106
+ .qhead {
107
+ display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
108
+ }
109
+ .qhead .tag {
110
+ font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 6px;
111
+ background: var(--accent-soft); color: var(--accent);
112
+ }
113
+ .qhead .tag.easy { background: var(--ok-soft); color: var(--ok); }
114
+ .qhead .tag.mid { background: var(--warn-soft); color: var(--warn); }
115
+ .qhead .tag.hard { background: var(--bad-soft); color: var(--bad); }
116
+ .qhead .idx { font-size: 12.5px; color: var(--muted); margin-left: auto; }
117
+ .stem { font-size: 15.5px; line-height: 1.75; }
118
+ .stem p { margin: .5em 0; }
119
+ .stem .katex { font-size: 1.04em; }
120
+
121
+ /* 选项 */
122
+ .opts { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
123
+ .opt {
124
+ display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
125
+ border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
126
+ background: transparent; transition: border-color .12s, background .12s;
127
+ }
128
+ .opt:hover { border-color: var(--accent); background: var(--accent-soft); }
129
+ .opt .key {
130
+ flex: none; width: 24px; height: 24px; border-radius: 50%;
131
+ border: 1.5px solid var(--line); display: grid; place-items: center;
132
+ font-size: 12.5px; font-weight: 700; color: var(--muted);
133
+ }
134
+ .opt.sel { border-color: var(--accent); background: var(--accent-soft); }
135
+ .opt.sel .key { background: var(--accent); border-color: var(--accent); color: #fff; }
136
+ .opt.right { border-color: var(--ok); background: var(--ok-soft); }
137
+ .opt.right .key { background: var(--ok); border-color: var(--ok); color: #fff; }
138
+ .opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
139
+ .opt.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
140
+ .opt .txt { flex: 1; min-width: 0; }
141
+ .opt[data-locked="1"] { cursor: default; }
142
+ .opt[data-locked="1"]:hover { border-color: var(--line); background: transparent; }
143
+ .opt.right[data-locked="1"]:hover { border-color: var(--ok); background: var(--ok-soft); }
144
+ .opt.wrong[data-locked="1"]:hover { border-color: var(--bad); background: var(--bad-soft); }
145
+ /* 网页自动补的「不知道」:虚线、弱化,别抢正经选项的注意力 */
146
+ .opt.dunno { border-style: dashed; }
147
+ .opt.dunno .key { border-style: dashed; }
148
+ .opt.dunno .txt { color: var(--muted); }
149
+ .opt.dunno.sel { border-color: var(--muted); background: transparent; }
150
+ .opt.dunno.sel .key { background: var(--muted); border-color: var(--muted); color: var(--bg); }
151
+
152
+ /* 选了「不知道」才出现:写清具体卡在哪,随答卷一起送批改 */
153
+ .note { display: none; margin-top: 10px; padding-left: 34px; }
154
+ .note.show { display: block; }
155
+ .note-lbl { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
156
+ .note-input {
157
+ width: 100%; box-sizing: border-box; resize: vertical; min-height: 52px;
158
+ font: inherit; font-size: 13.5px; line-height: 1.6; color: var(--text);
159
+ background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
160
+ padding: 8px 10px;
161
+ }
162
+ .note-input:focus { outline: none; border-color: var(--muted); }
163
+ .note-input::placeholder { color: var(--muted); opacity: .8; }
164
+ .note-show { margin-top: 10px; font-size: 13.5px; line-height: 1.7; color: var(--text); }
165
+ .note-show .lbl { font-weight: 700; color: var(--muted); margin-right: 4px; }
166
+
167
+ /* 解析 */
168
+ .explain {
169
+ margin-top: 14px; padding: 12px 14px; border-radius: 9px;
170
+ background: var(--accent-soft); font-size: 14px; line-height: 1.7;
171
+ border-left: 3px solid var(--accent);
172
+ }
173
+ .explain.bad { background: var(--bad-soft); border-left-color: var(--bad); }
174
+ .explain.ok { background: var(--ok-soft); border-left-color: var(--ok); }
175
+ .explain .lbl { font-weight: 700; margin-right: 4px; }
176
+
177
+ /* 结果页 */
178
+ .score { font-size: 34px; font-weight: 700; letter-spacing: .5px; }
179
+ .score small { font-size: 15px; color: var(--muted); font-weight: 400; }
180
+ .empty { text-align: center; color: var(--muted); padding: 48px 12px; font-size: 14px; }
181
+ .row { display: flex; gap: 8px; flex-wrap: wrap; }
182
+ .foot { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
183
+ .foot .grow { flex: 1; }
184
+ .hint { font-size: 12.5px; color: var(--muted); }
185
+ code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
186
+
187
+ /* 科目筛选 */
188
+ .tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
189
+ .tab {
190
+ font-size: 13px; padding: 4px 11px; border-radius: 999px; cursor: pointer;
191
+ border: 1px solid var(--line); background: transparent; color: var(--muted);
192
+ }
193
+ .tab.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
194
+
195
+ /* 记录表 */
196
+ .rec { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
197
+ .rec:last-child { border-bottom: 0; }
198
+ .rec .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
199
+ .rec .grow { flex: 1; min-width: 0; }
200
+
201
+ /* ---- 折叠区块:做题记录 / 成绩复盘 ----
202
+ * 只有标题行与折叠摘要行可点;正文里的按钮、链接、选项不受影响。 */
203
+ .fold {
204
+ background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
205
+ margin-bottom: 12px; overflow: hidden;
206
+ }
207
+ .fold-head {
208
+ display: flex; align-items: center; gap: 10px;
209
+ padding: 12px 14px; cursor: pointer; font-size: 13.5px; user-select: none;
210
+ }
211
+ .fold-head:hover { background: var(--accent-soft); }
212
+ .fold-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
213
+ .fold-head .caret { color: var(--muted); font-size: 11px; line-height: 1; transition: transform .12s; }
214
+ .fold[data-open="1"] .fold-head .caret { transform: rotate(180deg); }
215
+ .fold .fold-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
216
+ .fold-head .idx { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
217
+ .fold-head .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
218
+ .fold-peek { padding: 0 14px 11px; cursor: pointer; }
219
+ .fold[data-open="1"] .fold-peek { display: none; }
220
+ .fold-body { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
221
+ .fold-body .stem { font-size: 15px; }
222
+
223
+ /* 首页:按学科收纳。只展开一个学科,其余收起 */
224
+ .subject-fold { margin-bottom: 10px; }
225
+ .subject-fold .fold-head { padding: 14px; gap: 8px; }
226
+ .subject-fold .fold-title { font-size: 15px; letter-spacing: .2px; }
227
+ .subject-fold .fold-count { font-size: 12.5px; color: var(--accent); white-space: nowrap; }
228
+ .subject-fold .fold-body { padding: 10px 12px 12px; }
229
+ .subject-body .item { margin-bottom: 8px; }
230
+ .subject-body .item:last-child { margin-bottom: 0; }
231
+ .subject-fold[data-open="0"] { background: var(--panel); }
232
+
233
+ /* 记录页的批量开合 */
234
+ .fold-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
235
+ .fold-tools .hint { margin-left: auto; }
236
+
237
+ /* 记录里的逐题明细行 */
238
+ .qrow { padding: 9px 0; border-bottom: 1px solid var(--line); }
239
+ .qrow:last-child { border-bottom: 0; }
240
+ .qrow-head { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
241
+ .qrow-head .idx { color: var(--muted); min-width: 14px; font-size: 12.5px; }
242
+ .qrow-head .fold-title { font-weight: 500; }
243
+ .qrow-note { margin: 4px 0 0 22px; }
244
+
245
+ .toast {
246
+ position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
247
+ background: var(--text); color: var(--bg); font-size: 13px;
248
+ padding: 9px 16px; border-radius: 999px; opacity: 0; pointer-events: none;
249
+ transition: opacity .2s; z-index: 50; max-width: 80vw;
250
+ }
251
+ .toast.on { opacity: .95; }
252
+
253
+ /* ================= 手写作答(填空题 / 大题) =================
254
+ * 白板永远是白底黑墨:暗色主题下也保持浅色,否则导出的 PNG 到智能体那边
255
+ * 会变成「浅色字压深底」,读图时对比度不足、上下标更容易糊。
256
+ */
257
+ .tag.kind {
258
+ background: var(--panel); color: var(--muted);
259
+ border: 1px solid var(--line); font-weight: 600;
260
+ }
261
+ .tag.kind-essay { border-color: var(--accent); color: var(--accent); }
262
+
263
+ .ink-body { margin-top: 14px; }
264
+
265
+ .inkpad { user-select: none; }
266
+ .inkpad-tools {
267
+ display: flex; align-items: center; gap: 6px; margin-bottom: 7px; flex-wrap: wrap;
268
+ }
269
+ .inkpad-group { display: flex; gap: 2px; }
270
+ .inkpad-btn {
271
+ font: inherit; font-size: 12px; padding: 4px 9px; cursor: pointer;
272
+ background: var(--panel); color: var(--muted);
273
+ border: 1px solid var(--line); border-radius: 7px; line-height: 1.2;
274
+ }
275
+ .inkpad-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
276
+ .inkpad-btn:disabled { opacity: .4; cursor: not-allowed; }
277
+ .inkpad-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
278
+ .inkpad-size { padding: 5px 8px; display: grid; place-items: center; }
279
+ .inkpad-size i { display: block; border-radius: 50%; background: currentColor; }
280
+ .inkpad-sep { width: 1px; height: 16px; background: var(--line); margin: 0 3px; }
281
+ .inkpad-status { margin-left: auto; font-size: 12px; color: var(--muted); }
282
+
283
+ /* 橡皮擦:选中时给个明显的强调态(和笔一样是「工具」,不是一次性动作) */
284
+ .inkpad-eraser { padding: 4px 11px; }
285
+ .inkpad-eraser.on {
286
+ border-color: var(--accent); background: var(--accent-soft); color: var(--accent);
287
+ font-weight: 600;
288
+ }
289
+
290
+ /* 画板:白底 + 细边框 + 横向格线,方便对齐等号、分行写步骤 */
291
+ .inkpad-stage {
292
+ position: relative; border: 1px solid var(--line); border-radius: 9px;
293
+ background: #ffffff; overflow: hidden;
294
+ background-image: repeating-linear-gradient(
295
+ to bottom, transparent 0, transparent 39px,
296
+ #eef1f5 39px, #eef1f5 40px);
297
+ touch-action: none;
298
+ }
299
+ /* 光标由 ink.js 用 SVG 笔形设置(内联样式优先级高于这里),
300
+ 这里只留无 SVG 时的退化值。 */
301
+ .inkpad-stage canvas {
302
+ display: block; width: 100%; cursor: crosshair; touch-action: none;
303
+ }
304
+ /* 擦除模式下画板轻微变色,暗示「现在是擦,不是写」 */
305
+ .inkpad.eraser .inkpad-stage { box-shadow: inset 0 0 0 2px var(--accent-soft); }
306
+ .inkpad-hint {
307
+ position: absolute; left: 14px; top: 12px; pointer-events: none;
308
+ font-size: 13px; color: #9aa3ad; user-select: none;
309
+ }
310
+
311
+ .ink-note {
312
+ width: 100%; box-sizing: border-box; resize: vertical; min-height: 44px;
313
+ font: inherit; font-size: 13px; line-height: 1.6; color: var(--text);
314
+ background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
315
+ padding: 7px 10px; margin-top: 8px;
316
+ }
317
+ .ink-note:focus { outline: none; border-color: var(--muted); }
318
+ .ink-note::placeholder { color: var(--muted); opacity: .8; }
319
+
320
+ /* 成绩/记录页里的笔迹回看:白底不变,限制最大宽度 */
321
+ .ink-view {
322
+ margin-top: 12px; border: 1px solid var(--line); border-radius: 9px;
323
+ overflow: hidden; background: #fff; max-width: 100%;
324
+ }
325
+ .ink-view img { display: block; width: 100%; height: auto; }
326
+ .ink-view.small { max-width: 420px; margin-top: 8px; }
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={};r.d(o,{default:function(){return p}});var i=r(757),a=r.n(i);const l=function(e,t,n){let r=n,o=0;const i=e.length;for(;r<t.length;){const n=t[r];if(o<=0&&t.slice(r,r+i)===e)return r;"\\"===n?r++:"{"===n?o++:"}"===n&&o--,r++}return-1},s=/^\\begin{/;var d=function(e,t){let n;const r=[],o=new RegExp("("+t.map(e=>e.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;n=e.search(o),-1!==n;){n>0&&(r.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));const o=t.findIndex(t=>e.startsWith(t.left));if(n=l(t[o].right,e,t[o].left.length),-1===n)break;const i=e.slice(0,n+t[o].right.length),a=s.test(i)?i:e.slice(t[o].left.length,n);r.push({type:"math",data:a,rawData:i,display:t[o].display}),e=e.slice(n+t[o].right.length)}return""!==e&&r.push({type:"text",data:e}),r};const c=function(e,t){const n=d(e,t.delimiters);if(1===n.length&&"text"===n[0].type)return null;const r=document.createDocumentFragment();for(let e=0;e<n.length;e++)if("text"===n[e].type)r.appendChild(document.createTextNode(n[e].data));else{const o=document.createElement("span");let i=n[e].data;t.displayMode=n[e].display;try{t.preProcess&&(i=t.preProcess(i)),a().render(i,o,t)}catch(o){if(!(o instanceof a().ParseError))throw o;t.errorCallback("KaTeX auto-render: Failed to parse `"+n[e].data+"` with ",o),r.appendChild(document.createTextNode(n[e].rawData));continue}r.appendChild(o)}return r},f=function(e,t){for(let o=0;o<e.childNodes.length;o++){const i=e.childNodes[o];if(3===i.nodeType){var n;let a=null!=(n=i.textContent)?n:"",l=i.nextSibling,s=0;for(;l&&l.nodeType===Node.TEXT_NODE;){var r;a+=null!=(r=l.textContent)?r:"",l=l.nextSibling,s++}const d=c(a,t);if(d){for(let e=0;e<s;e++)i.nextSibling.remove();o+=d.childNodes.length-1,e.replaceChild(d,i)}else o+=s}else if(1===i.nodeType){const e=" "+i.className+" ";!t.ignoredTags.has(i.nodeName.toLowerCase())&&t.ignoredClasses.every(t=>!e.includes(" "+t+" "))&&f(i,t)}}};var p=function(e,t){if(!e)throw new Error("No element provided to render");const n={};Object.assign(n,t),n.delimiters=n.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],n.ignoredTags=new Set((null==t?void 0:t.ignoredTags)||["script","noscript","style","textarea","pre","code","option"]),n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},f(e,n)};return o=o.default}()});