@louisultra/dsh-verymath 0.5.1 → 0.7.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/CHANGELOG.md +70 -8
- package/lib/client.js +620 -66
- package/lib/core/glossary.d.ts +18 -0
- package/lib/core/glossary.js +20 -0
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.js +1 -1
- package/lib/http.d.ts +29 -0
- package/lib/http.js +635 -0
- package/lib/index.d.ts +14 -11
- package/lib/index.js +50 -8
- package/package.json +4 -1
package/lib/client.js
CHANGED
|
@@ -8,94 +8,649 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 入口机制(读宿主包源码确认,不是猜):
|
|
10
10
|
* - `@deepseek-ai/dsh-client-ui-sidebar` 在 root 作用域声明 `sidebar.panellist`
|
|
11
|
-
* (kind: list
|
|
11
|
+
* (kind: list):注册 `{ id, order, label }` + 图标组件,左栏就多一行;
|
|
12
12
|
* - 点开时按**同一 id** 去 `@deepseek-ai/dsh-client-ui-layout` 的 `main`
|
|
13
|
-
* (kind: keyed,root 作用域)取组件,所以主面板注册必须带 `key: <同一 id
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* (kind: keyed,root 作用域)取组件,所以主面板注册必须带 `key: <同一 id>`。
|
|
14
|
+
*
|
|
15
|
+
* 面板只做「对话里做起来烦」的事,不做对话能一步完成的事:
|
|
16
|
+
* 环境 —— 本机工具链就绪度 + 可复制的修复命令 + 可导出报告
|
|
17
|
+
* 术语库 —— 可选可查可改可删(手改 JSON 的痛苦正是它存在的理由)
|
|
18
|
+
* 论文图 —— 依赖图可点节点看陈述/度数/依赖关系
|
|
19
|
+
* 技能 —— 随包 16 个技能与其说明
|
|
20
|
+
*
|
|
21
|
+
* 数据全部走宿主侧 `/api/verymath/*` 精确路由(`src/http.ts`),与工具共用同一份
|
|
22
|
+
* 核心实现:面板改了术语库,对话里的 `verymath_glossary_query` 立刻看到。
|
|
16
23
|
*/
|
|
17
24
|
window.__ModuleLoader__.load({
|
|
18
25
|
id: '@louisultra/dsh-verymath',
|
|
19
|
-
factory: (
|
|
26
|
+
factory: (platformRequire) => {
|
|
20
27
|
const module = { exports: {} }
|
|
21
28
|
const exports = module.exports
|
|
22
|
-
const react =
|
|
29
|
+
const react = platformRequire('react')
|
|
23
30
|
const h = react.createElement
|
|
31
|
+
const useState = react.useState
|
|
32
|
+
const useEffect = react.useEffect
|
|
33
|
+
const useMemo = react.useMemo
|
|
34
|
+
const useCallback = react.useCallback
|
|
24
35
|
|
|
25
36
|
const PANEL_ID = 'verymath'
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
// ------------------------------------------------------------ 取数
|
|
39
|
+
|
|
40
|
+
async function request(path, init) {
|
|
41
|
+
const response = await fetch(path, init)
|
|
42
|
+
const text = await response.text()
|
|
43
|
+
let body
|
|
44
|
+
try {
|
|
45
|
+
body = text.length > 0 ? JSON.parse(text) : {}
|
|
46
|
+
} catch {
|
|
47
|
+
throw new Error(`接口返回的不是 JSON(HTTP ${response.status}):${text.slice(0, 120)}`)
|
|
48
|
+
}
|
|
49
|
+
if (!response.ok || body.error) throw new Error(body.error || `HTTP ${response.status}`)
|
|
50
|
+
return body
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const api = (path) => request(path)
|
|
54
|
+
const postJson = (path, payload) => request(path, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: { 'content-type': 'application/json' },
|
|
57
|
+
body: JSON.stringify(payload),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
async function copyText(text) {
|
|
61
|
+
try {
|
|
62
|
+
await navigator.clipboard.writeText(text)
|
|
63
|
+
return true
|
|
64
|
+
} catch {
|
|
65
|
+
return false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ------------------------------------------------------------ 样式
|
|
70
|
+
|
|
71
|
+
const S = {
|
|
72
|
+
wrap: { display: 'flex', flexDirection: 'column', height: '100%', minHeight: 0, fontSize: 13, color: 'var(--dsh-text-primary, #111)' },
|
|
73
|
+
head: {
|
|
74
|
+
display: 'flex', alignItems: 'center', gap: 12, padding: '11px 16px',
|
|
75
|
+
borderBottom: '1px solid var(--dsh-border, rgba(120,120,120,.22))', flexShrink: 0,
|
|
76
|
+
},
|
|
77
|
+
title: { fontSize: 14, fontWeight: 600, letterSpacing: '.01em' },
|
|
78
|
+
tabs: { display: 'flex', gap: 2, marginLeft: 'auto', background: 'var(--dsh-fill-secondary, rgba(120,120,120,.1))', padding: 3, borderRadius: 9 },
|
|
79
|
+
tab: {
|
|
80
|
+
border: 'none', background: 'transparent', cursor: 'pointer', fontSize: 12.5,
|
|
81
|
+
padding: '5px 12px', borderRadius: 7, color: 'var(--dsh-text-secondary, #666)', transition: 'background .12s',
|
|
82
|
+
},
|
|
83
|
+
tabOn: { background: 'var(--dsh-surface, #fff)', color: 'var(--dsh-text-primary, #111)', fontWeight: 600, boxShadow: '0 1px 2px rgba(0,0,0,.12)' },
|
|
84
|
+
body: { overflow: 'auto', padding: '16px 18px 28px', minHeight: 0, flex: 1 },
|
|
85
|
+
toolbar: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginBottom: 12 },
|
|
86
|
+
btn: {
|
|
87
|
+
border: '1px solid var(--dsh-border, rgba(120,120,120,.3))', background: 'transparent', cursor: 'pointer',
|
|
88
|
+
fontSize: 12, padding: '4px 10px', borderRadius: 7, color: 'inherit',
|
|
89
|
+
},
|
|
90
|
+
btnPrimary: { border: '1px solid transparent', background: '#2563eb', color: '#fff', cursor: 'pointer', fontSize: 12, padding: '5px 12px', borderRadius: 7 },
|
|
91
|
+
btnDanger: { border: '1px solid rgba(220,38,38,.45)', background: 'transparent', color: '#dc2626', cursor: 'pointer', fontSize: 12, padding: '4px 9px', borderRadius: 7 },
|
|
92
|
+
hint: { color: 'var(--dsh-text-tertiary, #888)', fontSize: 12, lineHeight: 1.7 },
|
|
93
|
+
card: { border: '1px solid var(--dsh-border, rgba(120,120,120,.22))', borderRadius: 10, padding: '11px 13px', marginBottom: 9 },
|
|
94
|
+
code: { fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: 11.5, color: 'var(--dsh-text-secondary, #666)' },
|
|
95
|
+
select: { fontSize: 12, padding: '5px 8px', borderRadius: 7, maxWidth: 460, border: '1px solid var(--dsh-border, rgba(120,120,120,.3))', background: 'transparent', color: 'inherit' },
|
|
96
|
+
input: { fontSize: 12.5, padding: '6px 9px', borderRadius: 7, boxSizing: 'border-box', border: '1px solid var(--dsh-border, rgba(120,120,120,.3))', background: 'transparent', color: 'inherit', outline: 'none' },
|
|
97
|
+
stat: { display: 'flex', gap: 16, flexWrap: 'wrap', marginBottom: 12 },
|
|
98
|
+
statNum: { fontSize: 17, fontWeight: 650, lineHeight: 1.1 },
|
|
99
|
+
statLabel: { ...{ color: 'var(--dsh-text-tertiary, #888)' }, fontSize: 11.5 },
|
|
100
|
+
dot: (state) => ({ width: 8, height: 8, borderRadius: 4, flexShrink: 0, marginTop: 5, background: state === 'ready' ? '#16a34a' : state === 'partial' ? '#d97706' : '#dc2626' }),
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function Loading(props) {
|
|
104
|
+
return h('div', { style: { ...S.hint, display: 'flex', alignItems: 'center', gap: 8, padding: '10px 0' } },
|
|
105
|
+
h('span', {
|
|
106
|
+
style: {
|
|
107
|
+
width: 12, height: 12, borderRadius: 6, border: '1.5px solid rgba(120,120,120,.35)',
|
|
108
|
+
borderTopColor: '#2563eb', animation: 'verymath-spin .7s linear infinite', display: 'inline-block',
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
props.label || '读取中…')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function Failure(props) {
|
|
115
|
+
return h('div', { style: { ...S.card, borderColor: 'rgba(220,38,38,.45)', background: 'rgba(220,38,38,.06)' } },
|
|
116
|
+
h('div', { style: { fontWeight: 600, marginBottom: 3 } }, '读不到数据'),
|
|
117
|
+
h('div', { style: { ...S.hint, color: 'inherit' } }, props.message),
|
|
118
|
+
props.onRetry ? h('button', { onClick: props.onRetry, style: { ...S.btn, marginTop: 8 } }, '重试') : null)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function Empty(props) {
|
|
122
|
+
return h('div', { style: { padding: '22px 0', ...S.hint } }, props.children)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function useEndpoint(path) {
|
|
126
|
+
const [state, setState] = useState({ status: 'loading', data: undefined, error: '', tick: 0 })
|
|
127
|
+
const reload = useCallback(() => setState((prev) => ({ ...prev, tick: prev.tick + 1 })), [])
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (path === undefined || path === null) return undefined
|
|
130
|
+
let alive = true
|
|
131
|
+
setState((prev) => ({ ...prev, status: 'loading' }))
|
|
132
|
+
api(path)
|
|
133
|
+
.then((data) => { if (alive) setState((prev) => ({ ...prev, status: 'ready', data, error: '' })) })
|
|
134
|
+
.catch((error) => { if (alive) setState((prev) => ({ ...prev, status: 'failed', error: String(error && error.message ? error.message : error) })) })
|
|
135
|
+
return () => { alive = false }
|
|
136
|
+
}, [path, state.tick])
|
|
137
|
+
return { ...state, reload }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ---------------------------------------------------------- 环境页签
|
|
141
|
+
|
|
142
|
+
const ENV_ORDER = ['python', 'pyyaml', 'latexmk', 'xelatex', 'osqp', 'sage', 'lean']
|
|
143
|
+
|
|
144
|
+
function envReport(data) {
|
|
145
|
+
const lines = [`# VeryMath 环境报告`, ``, `工作区:${data.workspace || '(未知)'}`, `就绪:${data.ready}/${data.total}`, ``]
|
|
146
|
+
for (const row of data.rows || []) {
|
|
147
|
+
lines.push(`- ${row.state === 'ready' ? '✅' : '❌'} ${row.label}${row.detail ? ` — ${row.detail}` : ''}`)
|
|
148
|
+
if (row.state !== 'ready' && row.hint) lines.push(` - 安装:${row.hint}`)
|
|
149
|
+
}
|
|
150
|
+
return lines.join('\n')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function EnvTab() {
|
|
154
|
+
const { status, data, error, reload } = useEndpoint('/api/verymath/env')
|
|
155
|
+
const [copied, setCopied] = useState('')
|
|
156
|
+
const flash = useCallback((id) => { setCopied(id); setTimeout(() => setCopied(''), 1400) }, [])
|
|
157
|
+
|
|
158
|
+
if (status === 'loading' && data === undefined) return h(Loading, { label: '正在探测本机工具链(实际执行 --version / import)…' })
|
|
159
|
+
if (status === 'failed') return h(Failure, { message: error, onRetry: reload })
|
|
160
|
+
|
|
161
|
+
const rows = (data.rows || []).slice().sort((left, right) => {
|
|
162
|
+
const leftIndex = ENV_ORDER.indexOf(left.id)
|
|
163
|
+
const rightIndex = ENV_ORDER.indexOf(right.id)
|
|
164
|
+
return (leftIndex < 0 ? 99 : leftIndex) - (rightIndex < 0 ? 99 : rightIndex)
|
|
165
|
+
})
|
|
166
|
+
const ready = data.ready ?? 0
|
|
167
|
+
const total = data.total ?? rows.length
|
|
168
|
+
|
|
169
|
+
return h('div', null,
|
|
170
|
+
h('div', { style: S.stat },
|
|
171
|
+
h('div', null, h('div', { style: S.statNum }, `${ready}/${total}`), h('div', { style: S.statLabel }, '就绪')),
|
|
172
|
+
h('div', null, h('div', { style: S.statNum }, String(total - ready)), h('div', { style: S.statLabel }, '缺失')),
|
|
173
|
+
h('div', { style: { marginLeft: 'auto', display: 'flex', gap: 8, alignItems: 'flex-start' } },
|
|
174
|
+
h('button', { onClick: reload, style: S.btn }, '重新探测'),
|
|
175
|
+
h('button', {
|
|
176
|
+
onClick: async () => {
|
|
177
|
+
const ok = await copyText(envReport(data))
|
|
178
|
+
flash(ok ? 'report' : 'fail')
|
|
179
|
+
},
|
|
180
|
+
style: S.btn,
|
|
181
|
+
}, copied === 'report' ? '已复制' : copied === 'fail' ? '复制失败' : '复制报告'),
|
|
182
|
+
),
|
|
183
|
+
),
|
|
184
|
+
h('div', { style: { ...S.hint, marginBottom: 12 } }, `工作区:${data.workspace || '(未知)'}`),
|
|
185
|
+
...rows.map((row) => h('div', { key: row.id, style: { ...S.card, display: 'flex', gap: 10 } },
|
|
186
|
+
h('div', { style: S.dot(row.state) }),
|
|
187
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
188
|
+
h('div', { style: { display: 'flex', gap: 8, alignItems: 'baseline' } },
|
|
189
|
+
h('span', { style: { fontWeight: 600 } }, row.label),
|
|
190
|
+
row.detail ? h('span', { style: S.code }, row.detail) : null,
|
|
191
|
+
h('span', { style: { ...S.hint, marginLeft: 'auto' } }, row.state === 'ready' ? '可用' : '缺失'),
|
|
192
|
+
),
|
|
193
|
+
h('div', { style: S.hint }, row.enables),
|
|
194
|
+
row.hint
|
|
195
|
+
? h('div', { style: { display: 'flex', gap: 8, alignItems: 'baseline', marginTop: 4 } },
|
|
196
|
+
h('code', { style: { ...S.code, color: '#b45309', flex: 1 } }, row.hint),
|
|
197
|
+
h('button', {
|
|
198
|
+
onClick: async () => { await copyText(row.hint); flash(row.id) },
|
|
199
|
+
style: { ...S.btn, padding: '2px 8px' },
|
|
200
|
+
}, copied === row.id ? '已复制' : '复制'),
|
|
201
|
+
)
|
|
202
|
+
: null,
|
|
203
|
+
),
|
|
204
|
+
)),
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// -------------------------------------------------------- 术语库页签
|
|
209
|
+
|
|
210
|
+
function Stat(props) {
|
|
211
|
+
return h('div', null,
|
|
212
|
+
h('div', { style: S.statNum }, String(props.value)),
|
|
213
|
+
h('div', { style: S.statLabel }, props.label))
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function TermEditor(props) {
|
|
217
|
+
const draftFor = (term) => ({
|
|
218
|
+
term_id: term ? term.term_id : undefined,
|
|
219
|
+
en: term ? term.en : '',
|
|
220
|
+
cn: term ? term.cn : '',
|
|
221
|
+
pos: term && term.pos ? term.pos : '',
|
|
222
|
+
field: term && term.field ? term.field.join(', ') : '',
|
|
223
|
+
source: term && term.source ? term.source : '',
|
|
224
|
+
exampleEn: term && term.examples && term.examples[0] ? term.examples[0].en : '',
|
|
225
|
+
exampleCn: term && term.examples && term.examples[0] ? term.examples[0].cn : '',
|
|
226
|
+
})
|
|
227
|
+
const [draft, setDraft] = useState(() => draftFor(props.term))
|
|
228
|
+
const [busy, setBusy] = useState(false)
|
|
229
|
+
const [error, setError] = useState('')
|
|
230
|
+
|
|
231
|
+
useEffect(() => { setDraft(draftFor(props.term)) }, [props.term])
|
|
232
|
+
|
|
233
|
+
const field = (key) => (event) => setDraft((prev) => ({ ...prev, [key]: event.target.value }))
|
|
234
|
+
const input = (key, placeholder, extra) => h('input', {
|
|
235
|
+
value: draft[key], onChange: field(key), placeholder, style: { ...S.input, ...(extra || {}) },
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
const save = async () => {
|
|
239
|
+
setBusy(true); setError('')
|
|
240
|
+
try {
|
|
241
|
+
const payload = { en: draft.en.trim(), cn: draft.cn.trim() }
|
|
242
|
+
if (draft.term_id) payload.term_id = draft.term_id
|
|
243
|
+
if (draft.pos.trim()) payload.pos = draft.pos.trim()
|
|
244
|
+
if (draft.field.trim()) payload.field = draft.field.split(',').map((part) => part.trim()).filter(Boolean)
|
|
245
|
+
if (draft.source.trim()) payload.source = draft.source.trim()
|
|
246
|
+
if (draft.exampleEn.trim() && draft.exampleCn.trim()) payload.example = { en: draft.exampleEn.trim(), cn: draft.exampleCn.trim() }
|
|
247
|
+
await props.onSave(payload)
|
|
248
|
+
props.onDone()
|
|
249
|
+
} catch (cause) {
|
|
250
|
+
setError(String(cause && cause.message ? cause.message : cause))
|
|
251
|
+
} finally {
|
|
252
|
+
setBusy(false)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return h('div', { style: { ...S.card, background: 'var(--dsh-fill-secondary, rgba(120,120,120,.06))' } },
|
|
257
|
+
h('div', { style: { fontWeight: 600, marginBottom: 8 } },
|
|
258
|
+
draft.term_id ? `编辑 ${draft.term_id}` : '新增术语'),
|
|
259
|
+
h('div', { style: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8 } },
|
|
260
|
+
h('label', { style: S.hint }, '英文(en)', h('div', { style: { marginTop: 2 } }, input('en', 'manifold'))),
|
|
261
|
+
h('label', { style: S.hint }, '中文(cn)', h('div', { style: { marginTop: 2 } }, input('cn', '流形'))),
|
|
262
|
+
h('label', { style: S.hint }, '词性(可选)', h('div', { style: { marginTop: 2 } }, input('pos', '名词'))),
|
|
263
|
+
h('label', { style: S.hint }, '子领域(逗号分隔)', h('div', { style: { marginTop: 2 } }, input('field', '代数拓扑, 微分几何'))),
|
|
264
|
+
h('label', { style: S.hint }, '来源(可选)', h('div', { style: { marginTop: 2 } }, input('source', '新英汉数学词汇'))),
|
|
265
|
+
h('label', { style: S.hint }, '例句 英文(可选)', h('div', { style: { marginTop: 2 } }, input('exampleEn', 'a smooth manifold'))),
|
|
266
|
+
),
|
|
267
|
+
h('div', { style: { marginTop: 8 } },
|
|
268
|
+
h('label', { style: S.hint }, '例句 中文(可选)',
|
|
269
|
+
h('div', { style: { marginTop: 2 } }, input('exampleCn', '一个光滑流形', { width: '100%' })))),
|
|
270
|
+
draft.term_id
|
|
271
|
+
? h('div', { style: { ...S.hint, marginTop: 6 } },
|
|
272
|
+
'带 term_id 提交 = 纠正这一行的中文与可选字段;英文必须与该行一致(改名不支持)。')
|
|
273
|
+
: h('div', { style: { ...S.hint, marginTop: 6 } },
|
|
274
|
+
'不带 term_id = 新增;同一英文的另一种译法会存成 en__N 别名行,不会覆盖现有译名。'),
|
|
275
|
+
error ? h('div', { style: { ...S.hint, color: '#dc2626', marginTop: 6 } }, error) : null,
|
|
276
|
+
h('div', { style: { display: 'flex', gap: 8, marginTop: 10 } },
|
|
277
|
+
h('button', { onClick: save, disabled: busy, style: { ...S.btnPrimary, opacity: busy ? 0.6 : 1 } },
|
|
278
|
+
busy ? '保存中…' : '保存'),
|
|
279
|
+
h('button', { onClick: props.onDone, style: S.btn }, '取消'),
|
|
280
|
+
),
|
|
281
|
+
)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function TermRow(props) {
|
|
285
|
+
const term = props.term
|
|
286
|
+
const [editing, setEditing] = useState(false)
|
|
287
|
+
if (editing) {
|
|
288
|
+
return h(TermEditor, {
|
|
289
|
+
term,
|
|
290
|
+
onSave: props.onUpsert,
|
|
291
|
+
onDone: () => setEditing(false),
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
return h('div', { style: S.card },
|
|
295
|
+
h('div', { style: { display: 'flex', gap: 8, alignItems: 'baseline' } },
|
|
296
|
+
h('span', { style: { fontWeight: 600 } }, term.en),
|
|
297
|
+
h('span', { style: { color: 'var(--dsh-text-tertiary, #999)' } }, '→'),
|
|
298
|
+
h('span', null, term.cn),
|
|
299
|
+
h('span', { style: { ...S.code, marginLeft: 'auto' } }, term.term_id),
|
|
300
|
+
h('button', { onClick: () => setEditing(true), style: { ...S.btn, padding: '2px 8px' } }, '编辑'),
|
|
301
|
+
h('button', {
|
|
302
|
+
onClick: async () => {
|
|
303
|
+
if (!window.confirm(`删除 ${term.term_id}(${term.en} / ${term.cn})?此操作直接改 glossary.json。`)) return
|
|
304
|
+
try { await props.onDelete(term.term_id) } catch (cause) { window.alert(String(cause && cause.message ? cause.message : cause)) }
|
|
305
|
+
},
|
|
306
|
+
style: { ...S.deleteBtn },
|
|
307
|
+
}, '删除'),
|
|
308
|
+
),
|
|
309
|
+
h('div', { style: { ...S.hint, display: 'flex', gap: 10, flexWrap: 'wrap' } },
|
|
310
|
+
term.matchedBy ? h('span', null, `命中:${term.matchedBy}`) : null,
|
|
311
|
+
term.pos ? h('span', null, `词性:${term.pos}`) : null,
|
|
312
|
+
term.field && term.field.length > 0 ? h('span', null, `子领域:${term.field.join(' / ')}`) : null,
|
|
313
|
+
term.source ? h('span', null, `来源:${term.source}`) : null,
|
|
314
|
+
term.updatedAt ? h('span', null, `更新:${term.updatedAt}`) : null,
|
|
315
|
+
),
|
|
316
|
+
...(term.examples || []).map((example, index) => h('div', {
|
|
317
|
+
key: index,
|
|
318
|
+
style: { ...S.hint, marginTop: 5, paddingLeft: 9, borderLeft: '2px solid rgba(120,120,120,.3)' },
|
|
319
|
+
}, `${example.en} — ${example.cn}`)),
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function GlossaryTab() {
|
|
324
|
+
const list = useEndpoint('/api/verymath/glossaries')
|
|
325
|
+
const [selected, setSelected] = useState('')
|
|
326
|
+
const [query, setQuery] = useState('')
|
|
327
|
+
const [showGaps, setShowGaps] = useState(false)
|
|
328
|
+
const [adding, setAdding] = useState(false)
|
|
329
|
+
const [tick, setTick] = useState(0)
|
|
330
|
+
|
|
331
|
+
const glossaries = (list.data && list.data.glossaries) || []
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
if (selected === '' && glossaries.length > 0) setSelected(glossaries[0].path)
|
|
334
|
+
}, [glossaries.length, selected])
|
|
335
|
+
|
|
336
|
+
const endpoint = selected === ''
|
|
337
|
+
? undefined
|
|
338
|
+
: `/api/verymath/glossary?path=${encodeURIComponent(selected)}&q=${encodeURIComponent(query)}`
|
|
339
|
+
const result = useEndpoint(endpoint)
|
|
340
|
+
|
|
341
|
+
const refresh = useCallback(() => { setTick((value) => value + 1); list.reload(); result.reload() }, [list.reload, result.reload])
|
|
342
|
+
void tick
|
|
343
|
+
|
|
344
|
+
const upsert = useCallback(async (payload) => {
|
|
345
|
+
await postJson('/api/verymath/glossary/upsert', { path: selected, terms: [payload] })
|
|
346
|
+
refresh()
|
|
347
|
+
}, [selected, refresh])
|
|
348
|
+
|
|
349
|
+
const remove = useCallback(async (termId) => {
|
|
350
|
+
await postJson('/api/verymath/glossary/delete', { path: selected, term_id: termId })
|
|
351
|
+
refresh()
|
|
352
|
+
}, [selected, refresh])
|
|
353
|
+
|
|
354
|
+
if (list.status === 'loading' && list.data === undefined) return h(Loading, { label: '正在扫描工作区里的 glossary.json…' })
|
|
355
|
+
if (list.status === 'failed') return h(Failure, { message: list.error, onRetry: list.reload })
|
|
356
|
+
if (glossaries.length === 0) {
|
|
357
|
+
return h(Empty, null,
|
|
358
|
+
'工作区里没有 glossary.json(扫描深度 3 层,文件名含 glossary 或「术语」)。',
|
|
359
|
+
h('div', { style: { marginTop: 8 } },
|
|
360
|
+
'让 Agent 说一句「从 source.csv 构建一份中英数学术语表,输出 glossary/glossary.json」,回来这里就能编辑了。'))
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const stats = (result.data && result.data.stats) || {}
|
|
364
|
+
const terms = (result.data && result.data.terms) || []
|
|
365
|
+
const gaps = showGaps && stats.missingExampleCount + stats.missingFieldCount > 0
|
|
366
|
+
? { examples: stats.missingExamples || [], fields: stats.missingField || [] }
|
|
367
|
+
: undefined
|
|
368
|
+
|
|
369
|
+
return h('div', null,
|
|
370
|
+
h('div', { style: S.toolbar },
|
|
371
|
+
h('select', { value: selected, onChange: (event) => setSelected(event.target.value), style: S.select },
|
|
372
|
+
...glossaries.map((item) => h('option', { key: item.path, value: item.path }, `${item.path}(${item.terms} 条)`))),
|
|
373
|
+
h('button', { onClick: () => setAdding(true), style: S.btnPrimary }, '新增术语'),
|
|
374
|
+
h('button', { onClick: refresh, style: S.btn }, '刷新'),
|
|
375
|
+
),
|
|
376
|
+
h('div', { style: S.stat },
|
|
377
|
+
h(Stat, { value: stats.total ?? 0, label: '术语' }),
|
|
378
|
+
h(Stat, { value: stats.withExamples ?? 0, label: '带例句' }),
|
|
379
|
+
h(Stat, { value: stats.aliases ?? 0, label: '别名行' }),
|
|
380
|
+
h(Stat, { value: (stats.fields || []).length, label: '子领域' }),
|
|
381
|
+
h(Stat, { value: stats.missingExampleCount ?? 0, label: '缺例句' }),
|
|
382
|
+
),
|
|
383
|
+
(stats.missingExampleCount > 0 || stats.missingFieldCount > 0)
|
|
384
|
+
? h('div', { style: { marginBottom: 10 } },
|
|
385
|
+
h('button', { onClick: () => setShowGaps((value) => !value), style: S.btn },
|
|
386
|
+
showGaps ? '收起缺口清单' : `看缺口清单(缺例句 ${stats.missingExampleCount} / 缺子领域 ${stats.missingFieldCount})`),
|
|
387
|
+
gaps
|
|
388
|
+
? h('div', { style: { ...S.card, marginTop: 8 } },
|
|
389
|
+
gaps.examples.length > 0
|
|
390
|
+
? h('div', null,
|
|
391
|
+
h('div', { style: { fontWeight: 600, marginBottom: 3 } }, '缺例句'),
|
|
392
|
+
h('div', { style: S.code }, gaps.examples.join(', ')),
|
|
393
|
+
h('div', { style: { ...S.hint, marginTop: 4 } }, '技能脚本可补:glossary_enrich_examples.py(需显式 --model / --api-key)。'))
|
|
394
|
+
: null,
|
|
395
|
+
gaps.fields.length > 0
|
|
396
|
+
? h('div', { style: { marginTop: 8 } },
|
|
397
|
+
h('div', { style: { fontWeight: 600, marginBottom: 3 } }, '缺子领域'),
|
|
398
|
+
h('div', { style: S.code }, gaps.fields.join(', ')))
|
|
399
|
+
: null,
|
|
400
|
+
)
|
|
401
|
+
: null,
|
|
402
|
+
)
|
|
403
|
+
: null,
|
|
404
|
+
h('input', {
|
|
405
|
+
value: query, onChange: (event) => setQuery(event.target.value),
|
|
406
|
+
placeholder: '查术语:英文、中文、term_id 或子领域(留空只看统计)', style: { ...S.input, width: '100%' },
|
|
407
|
+
}),
|
|
408
|
+
adding ? h(TermEditor, { term: undefined, onSave: upsert, onDone: () => setAdding(false) }) : null,
|
|
409
|
+
h('div', { style: { marginTop: 12 } },
|
|
410
|
+
result.status === 'loading' ? h(Loading, null) : null,
|
|
411
|
+
result.status === 'failed' ? h(Failure, { message: result.error, onRetry: result.reload }) : null,
|
|
412
|
+
result.status === 'ready' && query.trim().length > 0 && terms.length === 0
|
|
413
|
+
? h(Empty, null, `没有匹配「${query}」。试试英文词根,或换个子领域名。`)
|
|
414
|
+
: null,
|
|
415
|
+
result.status === 'ready' && terms.length > 0
|
|
416
|
+
? h('div', null,
|
|
417
|
+
h('div', { style: { ...S.hint, marginBottom: 8 } },
|
|
418
|
+
`命中 ${result.data.matched} 条${result.data.truncated ? `,只显示前 ${terms.length} 条` : ''}`),
|
|
419
|
+
...terms.map((term) => h(TermRow, {
|
|
420
|
+
key: term.term_id, term, onUpsert: upsert, onDelete: remove,
|
|
421
|
+
})),
|
|
422
|
+
)
|
|
423
|
+
: null,
|
|
424
|
+
result.status === 'ready' && query.trim().length === 0 && terms.length === 0
|
|
425
|
+
? h('div', { style: { ...S.hint, marginTop: 8 } }, '输入关键词开始查;或点上面的「新增术语」。')
|
|
426
|
+
: null,
|
|
427
|
+
),
|
|
428
|
+
)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// -------------------------------------------------------- 论文图页签
|
|
432
|
+
|
|
433
|
+
const TYPE_COLOR = {
|
|
434
|
+
THEOREM: '#7c3aed', COROLLARY: '#7c3aed', LEMMA: '#2563eb', PROPOSITION: '#2563eb',
|
|
435
|
+
DEFINITION: '#0f766e', CONSTRUCTION: '#0f766e', CLAIM: '#b45309', OBSERVATION: '#b45309', REMARK: '#6b7280',
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function GraphView(props) {
|
|
439
|
+
const graph = props.graph
|
|
440
|
+
const [picked, setPicked] = useState('')
|
|
441
|
+
const nodes = graph.nodes || []
|
|
442
|
+
const byId = useMemo(() => {
|
|
443
|
+
const map = new Map()
|
|
444
|
+
for (const node of nodes) map.set(node.id, node)
|
|
445
|
+
return map
|
|
446
|
+
}, [nodes])
|
|
447
|
+
|
|
448
|
+
const pickedNode = picked === '' ? undefined : byId.get(picked)
|
|
449
|
+
const related = pickedNode === undefined ? [] : (graph.edges || [])
|
|
450
|
+
.filter((edge) => edge.from === picked || edge.to === picked)
|
|
451
|
+
.map((edge) => ({ edge, other: edge.from === picked ? edge.to : edge.from, outward: edge.from === picked }))
|
|
452
|
+
|
|
453
|
+
return h('div', null,
|
|
454
|
+
h('div', { style: { ...S.card, padding: 0, overflow: 'auto', maxHeight: 460, background: 'var(--dsh-surface, #fff)' } },
|
|
455
|
+
h('svg', {
|
|
456
|
+
width: graph.width, height: graph.height,
|
|
457
|
+
style: { display: 'block' },
|
|
458
|
+
viewBox: `0 0 ${graph.width} ${graph.height}`,
|
|
459
|
+
},
|
|
460
|
+
// 边先画,节点后画,避免线压在方块上
|
|
461
|
+
...(graph.edges || []).filter((edge) => byId.has(edge.from) && byId.has(edge.to)).map((edge, index) => {
|
|
462
|
+
const from = byId.get(edge.from)
|
|
463
|
+
const to = byId.get(edge.to)
|
|
464
|
+
const x1 = from.x + from.width / 2
|
|
465
|
+
const y1 = from.y + from.height
|
|
466
|
+
const x2 = to.x + to.width / 2
|
|
467
|
+
const y2 = to.y
|
|
468
|
+
const mid = (y1 + y2) / 2
|
|
469
|
+
const hot = picked !== '' && (edge.from === picked || edge.to === picked)
|
|
470
|
+
return h('path', {
|
|
471
|
+
key: `e${index}`,
|
|
472
|
+
d: `M${x1} ${y1} C${x1} ${mid} ${x2} ${mid} ${x2} ${y2}`,
|
|
473
|
+
fill: 'none',
|
|
474
|
+
stroke: hot ? '#2563eb' : edge.uncertain ? '#d97706' : '#b6c2d1',
|
|
475
|
+
strokeWidth: hot ? 1.8 : 1.2,
|
|
476
|
+
strokeDasharray: edge.uncertain ? '4 3' : undefined,
|
|
477
|
+
})
|
|
478
|
+
}),
|
|
479
|
+
...nodes.map((node) => {
|
|
480
|
+
const color = TYPE_COLOR[node.type] || '#6b7280'
|
|
481
|
+
const active = picked === node.id
|
|
482
|
+
return h('g', {
|
|
483
|
+
key: node.id,
|
|
484
|
+
onClick: () => setPicked(active ? '' : node.id),
|
|
485
|
+
style: { cursor: 'pointer' },
|
|
486
|
+
},
|
|
487
|
+
h('rect', {
|
|
488
|
+
x: node.x, y: node.y, width: node.width, height: node.height, rx: 8,
|
|
489
|
+
fill: active ? 'rgba(37,99,235,.1)' : 'var(--dsh-surface, #fff)',
|
|
490
|
+
stroke: color, strokeWidth: node.shared || active ? 2 : 1.1,
|
|
491
|
+
}),
|
|
492
|
+
h('text', { x: node.x + 10, y: node.y + 13, fontSize: 8.5, fill: color, fontFamily: 'ui-sans-serif' },
|
|
493
|
+
`${node.type}${node.shared ? ' · 枢纽' : ''}${node.supportsMainTheorem ? '' : ' · 孤立于主定理'}`),
|
|
494
|
+
h('text', { x: node.x + 10, y: node.y + 26, fontSize: 10.5, fill: 'var(--dsh-text-primary, #111)', fontFamily: 'ui-sans-serif' },
|
|
495
|
+
node.label.length > 24 ? `${node.label.slice(0, 23)}…` : node.label),
|
|
496
|
+
h('text', { x: node.x + 10, y: node.y + 35, fontSize: 8.5, fill: 'var(--dsh-text-tertiary, #999)', fontFamily: 'ui-sans-serif' },
|
|
497
|
+
`in ${node.inDegree} / out ${node.outDegree}`),
|
|
498
|
+
)
|
|
499
|
+
}),
|
|
500
|
+
),
|
|
501
|
+
),
|
|
502
|
+
h('div', { style: { ...S.hint, marginTop: 6 } }, '点节点看详情与依赖关系;再点一次取消选中。'),
|
|
503
|
+
pickedNode === undefined
|
|
504
|
+
? null
|
|
505
|
+
: h('div', { style: { ...S.card, marginTop: 8 } },
|
|
506
|
+
h('div', { style: { fontWeight: 600 } }, `${pickedNode.label} · ${pickedNode.type}`),
|
|
507
|
+
h('div', { style: { ...S.hint, marginTop: 3 } }, pickedNode.statement),
|
|
508
|
+
h('div', { style: { ...S.hint, marginTop: 6 } },
|
|
509
|
+
`被引用 ${pickedNode.inDegree} · 依赖 ${pickedNode.outDegree}` +
|
|
510
|
+
`${pickedNode.shared ? ' · 枢纽节点' : ''}` +
|
|
511
|
+
`${pickedNode.supportsMainTheorem ? ' · 支撑主定理' : ' · 不支撑任何主定理'}`),
|
|
512
|
+
related.length > 0
|
|
513
|
+
? h('div', { style: { marginTop: 8 } },
|
|
514
|
+
h('div', { style: { fontWeight: 600, marginBottom: 3 } }, '关系'),
|
|
515
|
+
...related.map((item, index) => h('div', { key: index, style: S.hint },
|
|
516
|
+
`${item.outward ? '依赖' : '被'} ${item.other}${item.edge.uncertain ? '(不确定)' : ''}`)))
|
|
517
|
+
: null,
|
|
518
|
+
),
|
|
519
|
+
)
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function PaperTab() {
|
|
523
|
+
const list = useEndpoint('/api/verymath/structures')
|
|
524
|
+
const [selected, setSelected] = useState('')
|
|
525
|
+
const [focus, setFocus] = useState('')
|
|
526
|
+
|
|
527
|
+
const structures = (list.data && list.data.structures) || []
|
|
528
|
+
useEffect(() => {
|
|
529
|
+
if (selected === '' && structures.length > 0) setSelected(structures[0].path)
|
|
530
|
+
}, [structures.length, selected])
|
|
531
|
+
|
|
532
|
+
const endpoint = selected === ''
|
|
533
|
+
? undefined
|
|
534
|
+
: `/api/verymath/paper?path=${encodeURIComponent(selected)}&focus=${encodeURIComponent(focus)}`
|
|
535
|
+
const result = useEndpoint(endpoint)
|
|
536
|
+
|
|
537
|
+
if (list.status === 'loading' && list.data === undefined) return h(Loading, { label: '正在扫描工作区里的 *_structure.json…' })
|
|
538
|
+
if (list.status === 'failed') return h(Failure, { message: list.error, onRetry: list.reload })
|
|
539
|
+
if (structures.length === 0) {
|
|
540
|
+
return h(Empty, null,
|
|
541
|
+
'工作区里没有 *_structure.json(math-paper-reading 的结构产物)。',
|
|
542
|
+
h('div', { style: { marginTop: 8 } },
|
|
543
|
+
'让 Agent 说一句「读 papers/xxx/fulltext.txt 的第 1 节,把定义提取成结构 JSON」,产物出现后这里会列出来。'))
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const data = result.data
|
|
547
|
+
return h('div', null,
|
|
548
|
+
h('div', { style: S.toolbar },
|
|
549
|
+
h('select', { value: selected, onChange: (event) => setSelected(event.target.value), style: S.select },
|
|
550
|
+
...structures.map((item) => h('option', { key: item.path, value: item.path }, `${item.title}(${item.entities} 实体)`))),
|
|
551
|
+
h('input', {
|
|
552
|
+
value: focus, onChange: (event) => setFocus(event.target.value),
|
|
553
|
+
placeholder: '聚焦某条定理看依赖闭包(可留空)', style: { ...S.input, width: 250 },
|
|
554
|
+
}),
|
|
555
|
+
),
|
|
556
|
+
result.status === 'loading' ? h(Loading, null) : null,
|
|
557
|
+
result.status === 'failed' ? h(Failure, { message: result.error, onRetry: result.reload }) : null,
|
|
558
|
+
result.status === 'ready' && data
|
|
559
|
+
? h('div', null,
|
|
560
|
+
h('div', { style: S.stat },
|
|
561
|
+
h(Stat, { value: data.entities ?? 0, label: '实体' }),
|
|
562
|
+
h(Stat, { value: (data.sharedNodes || []).length, label: '枢纽' }),
|
|
563
|
+
h(Stat, { value: (data.cycles || []).length, label: '环' }),
|
|
564
|
+
h(Stat, { value: (data.isolated || []).length, label: '孤立' }),
|
|
565
|
+
h(Stat, { value: (data.longestChain || []).length, label: '最长链' }),
|
|
566
|
+
),
|
|
567
|
+
(data.cycles || []).length > 0
|
|
568
|
+
? h('div', { style: { ...S.card, borderColor: 'rgba(217,119,6,.5)', background: 'rgba(217,119,6,.07)' } },
|
|
569
|
+
h('div', { style: { fontWeight: 600 } }, '⚠ 依赖图里有环(上游要求人工判断)'),
|
|
570
|
+
...data.cycles.map((cycle, index) => h('div', { key: index, style: S.hint }, cycle.join(' → '))))
|
|
571
|
+
: null,
|
|
572
|
+
data.focus
|
|
573
|
+
? h('div', { style: { ...S.card, borderColor: data.focus.found ? undefined : 'rgba(180,83,9,.5)' } },
|
|
574
|
+
h('div', { style: { fontWeight: 600, marginBottom: 3 } },
|
|
575
|
+
data.focus.found ? `聚焦 ${data.focus.label}` : `聚焦 ${data.focus.label}(未找到)`),
|
|
576
|
+
data.focus.found
|
|
577
|
+
? h('div', { style: S.hint }, '自底向上阅读层:' + data.focus.levels.map((level) => `[${level.join('、')}]`).join(' → '))
|
|
578
|
+
: h('div', { style: S.hint }, '这个标签不在合并后的实体里。'))
|
|
579
|
+
: null,
|
|
580
|
+
data.graph && data.graph.nodes
|
|
581
|
+
? h(GraphView, { graph: data.graph })
|
|
582
|
+
: null,
|
|
583
|
+
h('div', { style: { ...S.card, marginTop: 10 } },
|
|
584
|
+
h('div', { style: { ...S.hint, marginBottom: 4 } }, '复现顺序(自底向上)'),
|
|
585
|
+
h('div', { style: S.code }, (data.bottomUpLevels || []).map((level) => `[${level.join('、')}]`).join(' → ')),
|
|
586
|
+
h('div', { style: { ...S.hint, marginTop: 8, marginBottom: 4 } }, '阅读顺序(自顶向下)'),
|
|
587
|
+
h('div', { style: S.code }, (data.topDownOrder || []).join(' → ')),
|
|
588
|
+
),
|
|
589
|
+
)
|
|
590
|
+
: null,
|
|
591
|
+
)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// ------------------------------------------------------------ 技能页签
|
|
595
|
+
|
|
596
|
+
function SkillsTab() {
|
|
597
|
+
const { status, data, error, reload } = useEndpoint('/api/verymath/skills')
|
|
598
|
+
if (status === 'loading' && data === undefined) return h(Loading, { label: '读取随包技能…' })
|
|
599
|
+
if (status === 'failed') return h(Failure, { message: error, onRetry: reload })
|
|
600
|
+
const skills = (data && data.skills) || []
|
|
601
|
+
return h('div', null,
|
|
602
|
+
h('div', { style: S.toolbar },
|
|
603
|
+
h('div', { style: { fontSize: 14, fontWeight: 600 } }, `${skills.length} 个随包技能`),
|
|
604
|
+
h('div', { style: S.hint }, '与工具同版本发布'),
|
|
605
|
+
h('button', { onClick: reload, style: { ...S.btn, marginLeft: 'auto' } }, '刷新'),
|
|
606
|
+
),
|
|
607
|
+
...skills.map((skill) => h('div', { key: skill.name, style: S.card },
|
|
608
|
+
h('div', { style: { display: 'flex', gap: 8, alignItems: 'baseline' } },
|
|
609
|
+
h('span', { style: { fontWeight: 600 } }, skill.name),
|
|
610
|
+
h('span', { style: { ...S.code, marginLeft: 'auto' } }, `${skill.files} 个文件`)),
|
|
611
|
+
h('div', { style: { ...S.hint, marginTop: 3 } }, skill.description),
|
|
612
|
+
)),
|
|
613
|
+
)
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// -------------------------------------------------------------- 外壳
|
|
617
|
+
|
|
28
618
|
function VeryMathIcon(props) {
|
|
29
619
|
const size = (props && props.size) || 16
|
|
30
620
|
return h('svg', {
|
|
31
|
-
width: size,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
fill: 'none',
|
|
35
|
-
stroke: 'currentColor',
|
|
36
|
-
strokeWidth: 1.6,
|
|
37
|
-
strokeLinecap: 'round',
|
|
38
|
-
'aria-hidden': 'true',
|
|
39
|
-
},
|
|
40
|
-
h('path', { d: 'M12 3H4l4 5-4 5h8' }),
|
|
41
|
-
)
|
|
621
|
+
width: size, height: size, viewBox: '0 0 16 16', fill: 'none',
|
|
622
|
+
stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', 'aria-hidden': 'true',
|
|
623
|
+
}, h('path', { d: 'M12 3H4l4 5-4 5h8' }))
|
|
42
624
|
}
|
|
43
625
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
letterSpacing: '.08em',
|
|
50
|
-
textTransform: 'uppercase',
|
|
51
|
-
color: 'var(--dsh-text-tertiary, #888)',
|
|
52
|
-
margin: '14px 0 6px',
|
|
53
|
-
},
|
|
54
|
-
}, props.children)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const TOOLS = [
|
|
58
|
-
['verymath_glossary_query', '查双语术语库'],
|
|
59
|
-
['verymath_glossary_upsert', '存词 / 纠正译名'],
|
|
60
|
-
['verymath_glossary_build', '从 CSV 建库(Python)'],
|
|
61
|
-
['verymath_python_check', 'Python 可用性'],
|
|
62
|
-
['verymath_paper_validate', '论文结构 JSON 校验'],
|
|
63
|
-
['verymath_paper_graph', '定理依赖图'],
|
|
64
|
-
['verymath_ocr_scan', 'OCR 后错误定位'],
|
|
65
|
-
['verymath_osqp_check', 'OSQP 求解栈探测'],
|
|
66
|
-
['verymath_osqp_solve', '凸二次规划求解'],
|
|
67
|
-
['verymath_lean_detect_sorry', 'Lean 禁用词扫描'],
|
|
68
|
-
['verymath_sage_check', 'SageMath 探测'],
|
|
69
|
-
['verymath_sage_search', 'Sage 文档反幻觉查询'],
|
|
70
|
-
['verymath_research_gate', '研究工作区三道闸门'],
|
|
71
|
-
['verymath_beamer_check', 'Beamer TeX 工具链'],
|
|
626
|
+
const TABS = [
|
|
627
|
+
{ id: 'env', label: '环境' },
|
|
628
|
+
{ id: 'glossary', label: '术语库' },
|
|
629
|
+
{ id: 'paper', label: '论文图' },
|
|
630
|
+
{ id: 'skills', label: '技能' },
|
|
72
631
|
]
|
|
73
632
|
|
|
74
|
-
/** 主面板:能力清单与当前状态。 */
|
|
75
633
|
function VeryMathPanel() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
h('
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
)
|
|
634
|
+
const [tab, setTab] = useState('env')
|
|
635
|
+
return h('div', { style: S.wrap },
|
|
636
|
+
h('style', null, '@keyframes verymath-spin{to{transform:rotate(360deg)}}'),
|
|
637
|
+
h('div', { style: S.head },
|
|
638
|
+
h('div', { style: S.title }, 'VeryMath 数学科研'),
|
|
639
|
+
h('div', { style: S.tabs }, ...TABS.map((item) => h('button', {
|
|
640
|
+
key: item.id, onClick: () => setTab(item.id),
|
|
641
|
+
style: item.id === tab ? { ...S.tab, ...S.tabOn } : S.tab,
|
|
642
|
+
}, item.label))),
|
|
643
|
+
),
|
|
644
|
+
h('div', { style: S.body },
|
|
645
|
+
tab === 'env' ? h(EnvTab, null) : null,
|
|
646
|
+
tab === 'glossary' ? h(GlossaryTab, null) : null,
|
|
647
|
+
tab === 'paper' ? h(PaperTab, null) : null,
|
|
648
|
+
tab === 'skills' ? h(SkillsTab, null) : null,
|
|
89
649
|
),
|
|
90
|
-
h(Section, null, '怎么用'),
|
|
91
|
-
h('div', { style: { color: 'var(--dsh-text-secondary, #666)' } },
|
|
92
|
-
'全部能力都在对话里调用:「帮我查一下 manifold 的中文术语」「读这篇论文的定理依赖」。',
|
|
93
|
-
'这个面板只是入口与状态指示,不做计算——计算都在工具里,结果写进会话工作区。'),
|
|
94
650
|
)
|
|
95
651
|
}
|
|
96
652
|
|
|
97
653
|
function apply(ctx) {
|
|
98
|
-
// 左栏入口(list 槽,每个插件一行)
|
|
99
654
|
ctx.effect(() => ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
100
655
|
name: 'sidebar.panellist',
|
|
101
656
|
id: PANEL_ID,
|
|
@@ -103,7 +658,6 @@ window.__ModuleLoader__.load({
|
|
|
103
658
|
label: 'VeryMath 数学科研',
|
|
104
659
|
}, VeryMathIcon)), 'verymath: sidebar entry')
|
|
105
660
|
|
|
106
|
-
// 主面板(keyed 槽,键必须与上面 id 一致)
|
|
107
661
|
ctx.effect(() => ctx.slots.inject('main', () => ctx.slots.register({
|
|
108
662
|
name: 'main',
|
|
109
663
|
key: PANEL_ID,
|