dsh-learn-space 1.0.0 → 1.2.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/README.md +1 -0
- package/assets/katex/LICENSE +21 -0
- package/assets/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/assets/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/assets/katex/katex.min.css +1 -0
- package/assets/katex/katex.min.js +1 -0
- package/client.js +580 -59
- package/index.js +16 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1053,13 +1053,23 @@ export function apply(ctx, config) {
|
|
|
1053
1053
|
send(200, { ok: true })
|
|
1054
1054
|
return
|
|
1055
1055
|
}
|
|
1056
|
-
// 静态资产:mermaid
|
|
1057
|
-
if (req.method === 'GET' && url.pathname
|
|
1056
|
+
// 静态资产:mermaid / KaTeX(文件不可变,缓存一天;缺失 404 JSON 让客户端走降级)
|
|
1057
|
+
if (req.method === 'GET' && url.pathname.startsWith('/api/learning-space/assets/')) {
|
|
1058
|
+
const assetsDir = path.join(PLUGIN_DIR, 'assets')
|
|
1059
|
+
const rel = url.pathname.slice('/api/learning-space/assets/'.length)
|
|
1060
|
+
// 资产名全是 ASCII,用白名单字符挡住路径逃逸,免得 decodeURIComponent 抛错变 500
|
|
1061
|
+
const file = /^[\w./-]+$/.test(rel) ? path.normalize(path.join(assetsDir, rel)) : ''
|
|
1062
|
+
if (!file || !file.startsWith(assetsDir + path.sep)) { send(404, { ok: false, error: 'asset not found' }); return }
|
|
1058
1063
|
let buf
|
|
1059
|
-
try { buf = await readFile(
|
|
1060
|
-
catch { send(404, { ok: false, error: '
|
|
1064
|
+
try { buf = await readFile(file) }
|
|
1065
|
+
catch { send(404, { ok: false, error: 'asset missing' }); return }
|
|
1066
|
+
const ext = path.extname(file).toLowerCase()
|
|
1067
|
+
const type = ext === '.js' ? 'application/javascript; charset=utf-8'
|
|
1068
|
+
: ext === '.css' ? 'text/css; charset=utf-8'
|
|
1069
|
+
: ext === '.woff2' ? 'font/woff2'
|
|
1070
|
+
: 'application/octet-stream'
|
|
1061
1071
|
res.writeHead(200, {
|
|
1062
|
-
'content-type':
|
|
1072
|
+
'content-type': type,
|
|
1063
1073
|
'cache-control': 'public, max-age=86400',
|
|
1064
1074
|
})
|
|
1065
1075
|
res.end(buf)
|
|
@@ -1201,6 +1211,7 @@ export function apply(ctx, config) {
|
|
|
1201
1211
|
if (!args.topic || !args.summary) throw new Error('缺少 topic 或 summary')
|
|
1202
1212
|
const month = today.slice(0, 7)
|
|
1203
1213
|
const file = path.join(root, 'journal', `${month}.md`)
|
|
1214
|
+
await mkdir(path.dirname(file), { recursive: true })
|
|
1204
1215
|
let text = `# 学习日志(${month})\n`
|
|
1205
1216
|
try { text = await readFile(file, 'utf8') } catch { /* 新建 */ }
|
|
1206
1217
|
text += `- ${today} · ${args.topic} · ${args.node || '-'} · ${args.summary}\n`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-learn-space",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "学习空间:AI 辅导的个人学习面板。摸底定位 → 依赖图规划 → 逐节点教学 + quiz 确认,进度/笔记/错题/学习记录沉淀为 Markdown,支持导出自包含 HTML 学习报告。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"cordis.patch.yml",
|
|
35
35
|
"locale/*.json",
|
|
36
36
|
"icon.svg",
|
|
37
|
-
"assets
|
|
37
|
+
"assets",
|
|
38
38
|
"skills",
|
|
39
39
|
"LICENSE",
|
|
40
40
|
"README.md"
|