dsh-sensenova-pool 0.1.3 → 0.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 +349 -284
- package/lib/client.js +297 -73
- package/lib/index.js +146 -31
- package/lib/routes.d.ts +16 -0
- package/lib/routes.js +26 -0
- package/lib/shim.d.ts +9 -0
- package/lib/shim.js +36 -9
- package/package.json +79 -78
package/lib/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 浏览器半:在 DSH
|
|
2
|
+
* 浏览器半:在 DSH 的「设置」与「插件」页里渲染本插件的管理卡片。
|
|
3
3
|
*
|
|
4
4
|
* 为什么是这个文件形态
|
|
5
5
|
* --------------------
|
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
*
|
|
16
16
|
* 槽位选择
|
|
17
17
|
* --------
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* 1. `settings.section`(**一级设置分区**)—— 主入口。用户要求「key 管理页面在
|
|
19
|
+
* DSH 的设置里」,这就是设置侧栏里与「通用 / 模型 / 插件」并列的那一类分区,
|
|
20
|
+
* 由 `@deepseek-ai/dsh-client-ui-settings` 声明,`ui-settings-general` 渲染。
|
|
21
|
+
* 2. `plugins.bundle.config`(keyed,键 = npm 包名)—— 「插件」页里本 bundle 的
|
|
22
|
+
* 详情卡片,保留原入口,用户不必猜。
|
|
23
|
+
* 3. `settings.plugins.tab` —— 「内置插件」分区里的标签页,第三个入口。
|
|
21
24
|
*
|
|
22
25
|
* 一个必须遵守的宿主约束
|
|
23
26
|
* ----------------------
|
|
@@ -83,6 +86,7 @@ window.__ModuleLoader__.load({
|
|
|
83
86
|
background: 'var(--dsw-alias-bg-module-platform)',
|
|
84
87
|
fontWeight: 500,
|
|
85
88
|
};
|
|
89
|
+
const smallButtonStyle = { ...buttonStyle, minHeight: 26, padding: '2px 10px', fontSize: 12 };
|
|
86
90
|
const rowStyle = {
|
|
87
91
|
display: 'flex',
|
|
88
92
|
alignItems: 'center',
|
|
@@ -98,6 +102,29 @@ window.__ModuleLoader__.load({
|
|
|
98
102
|
fontSize: 12,
|
|
99
103
|
color: labelSecondary,
|
|
100
104
|
};
|
|
105
|
+
/** 分区块:一条细分割线把「接口 / Key / 模型」三块隔开。 */
|
|
106
|
+
const blockStyle = {
|
|
107
|
+
display: 'flex',
|
|
108
|
+
flexDirection: 'column',
|
|
109
|
+
gap: 8,
|
|
110
|
+
paddingTop: 16,
|
|
111
|
+
borderTop: `1px solid ${borderL2}`,
|
|
112
|
+
};
|
|
113
|
+
const blockTitleStyle = { margin: 0, fontSize: 14, fontWeight: 500, lineHeight: '22px', color: labelPrimary };
|
|
114
|
+
/** 只读值框:可整段选中,方便手抄。 */
|
|
115
|
+
const valueStyle = {
|
|
116
|
+
...codeStyle,
|
|
117
|
+
flex: '1 1 260px',
|
|
118
|
+
minWidth: 0,
|
|
119
|
+
padding: '6px 8px',
|
|
120
|
+
border: `1px solid ${borderL2}`,
|
|
121
|
+
borderRadius: 6,
|
|
122
|
+
background: bgLayer1,
|
|
123
|
+
color: labelPrimary,
|
|
124
|
+
wordBreak: 'break-all',
|
|
125
|
+
userSelect: 'all',
|
|
126
|
+
};
|
|
127
|
+
const pageTitleStyle = { margin: 0, fontSize: 16, fontWeight: 500, lineHeight: '24px', color: labelPrimary };
|
|
101
128
|
|
|
102
129
|
/** 状态徽标:颜色区分健康 / 冷却 / 失效。 */
|
|
103
130
|
const badgeStyle = (status) => {
|
|
@@ -144,9 +171,48 @@ window.__ModuleLoader__.load({
|
|
|
144
171
|
return value;
|
|
145
172
|
}
|
|
146
173
|
|
|
174
|
+
/**
|
|
175
|
+
* 复制到剪贴板。
|
|
176
|
+
*
|
|
177
|
+
* `navigator.clipboard` 在 `dsh-app://` 这类自定义协议下不一定可用(安全上下文
|
|
178
|
+
* 判定因宿主而异),因此保留 `execCommand` 兜底 —— 它虽然过时,但在 Electron
|
|
179
|
+
* 渲染进程里一直有效。
|
|
180
|
+
*/
|
|
181
|
+
async function copyText(text) {
|
|
182
|
+
try {
|
|
183
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
184
|
+
await navigator.clipboard.writeText(text);
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
} catch {
|
|
188
|
+
// 落到下面的兜底。
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const area = document.createElement('textarea');
|
|
192
|
+
area.value = text;
|
|
193
|
+
area.style.position = 'fixed';
|
|
194
|
+
area.style.top = '-1000px';
|
|
195
|
+
area.style.opacity = '0';
|
|
196
|
+
document.body.appendChild(area);
|
|
197
|
+
area.focus();
|
|
198
|
+
area.select();
|
|
199
|
+
const ok = document.execCommand('copy');
|
|
200
|
+
document.body.removeChild(area);
|
|
201
|
+
return ok;
|
|
202
|
+
} catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
147
207
|
// ------------------------------------------------------------------ 卡片
|
|
148
208
|
|
|
149
|
-
|
|
209
|
+
/**
|
|
210
|
+
* 管理卡片:对外接口 + Key 池 + 模型可见性。
|
|
211
|
+
*
|
|
212
|
+
* @param props.t 文案读取器(宿主 locale 绑定)。
|
|
213
|
+
* @param props.variant 'section' 时渲染页面标题(设置分区里需要),'card' 时不渲染。
|
|
214
|
+
*/
|
|
215
|
+
function KeyCard({ t, variant }) {
|
|
150
216
|
const [draft, setDraft] = React.useState('');
|
|
151
217
|
const [busy, setBusy] = React.useState(false);
|
|
152
218
|
const [notice, setNotice] = React.useState(undefined);
|
|
@@ -154,8 +220,11 @@ window.__ModuleLoader__.load({
|
|
|
154
220
|
const [keys, setKeys] = React.useState([]);
|
|
155
221
|
const [summary, setSummary] = React.useState(undefined);
|
|
156
222
|
const [catalog, setCatalog] = React.useState(undefined);
|
|
223
|
+
const [models, setModels] = React.useState([]);
|
|
224
|
+
const [endpoint, setEndpoint] = React.useState(undefined);
|
|
157
225
|
const [adminKey, setAdminKey] = React.useState(undefined);
|
|
158
226
|
const [tested, setTested] = React.useState({});
|
|
227
|
+
const [copied, setCopied] = React.useState('');
|
|
159
228
|
|
|
160
229
|
const load = React.useCallback(async () => {
|
|
161
230
|
try {
|
|
@@ -164,6 +233,8 @@ window.__ModuleLoader__.load({
|
|
|
164
233
|
if (status) {
|
|
165
234
|
setSummary(status.summary);
|
|
166
235
|
setCatalog(status.catalog);
|
|
236
|
+
if (Array.isArray(status.models)) setModels(status.models);
|
|
237
|
+
if (status.endpoint) setEndpoint(status.endpoint);
|
|
167
238
|
if (typeof status.adminKey === 'string') setAdminKey(status.adminKey);
|
|
168
239
|
}
|
|
169
240
|
setError(undefined);
|
|
@@ -228,10 +299,25 @@ window.__ModuleLoader__.load({
|
|
|
228
299
|
return value.ok ? t('testOk', { ms: String(value.latencyMs) }) : t('testFail', { message: String(value.message).slice(0, 80) });
|
|
229
300
|
});
|
|
230
301
|
|
|
302
|
+
const toggleModel = (id, enabled) =>
|
|
303
|
+
run('model', async () => {
|
|
304
|
+
await postJson(`${BASE}/keys`, { action: 'set-model', id, enabled }, adminKey);
|
|
305
|
+
return enabled ? t('modelShown', { id }) : t('modelHidden', { id });
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const copy = async (field, text) => {
|
|
309
|
+
const ok = await copyText(text);
|
|
310
|
+
setCopied(ok ? field : '');
|
|
311
|
+
setNotice(ok ? t('copied') : undefined);
|
|
312
|
+
if (!ok) setError(t('copyFailed'));
|
|
313
|
+
};
|
|
314
|
+
|
|
231
315
|
const canSave = !busy && draft.trim() !== '';
|
|
316
|
+
const enabledCount = models.filter((model) => model.enabled).length;
|
|
317
|
+
const endpointReady = endpoint !== undefined && typeof endpoint.baseUrl === 'string' && endpoint.baseUrl !== '';
|
|
232
318
|
|
|
233
319
|
return h('div', { style: rootStyle }, [
|
|
234
|
-
|
|
320
|
+
variant === 'section' ? h('h2', { key: 'title', style: pageTitleStyle }, t('nav')) : null,
|
|
235
321
|
h('p', { key: 'hint', style: hintStyle }, t('hint')),
|
|
236
322
|
|
|
237
323
|
summary
|
|
@@ -250,72 +336,160 @@ window.__ModuleLoader__.load({
|
|
|
250
336
|
)
|
|
251
337
|
: null,
|
|
252
338
|
|
|
253
|
-
// ----
|
|
254
|
-
h('
|
|
255
|
-
key: '
|
|
256
|
-
style:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
339
|
+
// ---- 对外接口:地址 / 端口 / API Key ------------------------------
|
|
340
|
+
h('div', { key: 'endpoint', style: blockStyle }, [
|
|
341
|
+
h('h3', { key: 'title', style: blockTitleStyle }, t('endpointTitle')),
|
|
342
|
+
h('p', { key: 'hint', style: hintStyle }, t('endpointHint')),
|
|
343
|
+
|
|
344
|
+
endpointReady
|
|
345
|
+
? h('div', { key: 'rows', style: { display: 'flex', flexDirection: 'column', gap: 8 } }, [
|
|
346
|
+
h('div', { key: 'url', style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } }, [
|
|
347
|
+
h('span', { key: 'label', style: { ...codeStyle, flex: '0 0 84px', color: labelTertiary } }, t('endpointUrl')),
|
|
348
|
+
h('code', { key: 'value', style: valueStyle }, endpoint.baseUrl),
|
|
349
|
+
h(
|
|
350
|
+
'button',
|
|
351
|
+
{
|
|
352
|
+
key: 'copy',
|
|
353
|
+
type: 'button',
|
|
354
|
+
style: smallButtonStyle,
|
|
355
|
+
disabled: busy,
|
|
356
|
+
onClick: () => copy('url', endpoint.baseUrl),
|
|
357
|
+
},
|
|
358
|
+
copied === 'url' ? t('copied') : t('copy'),
|
|
359
|
+
),
|
|
360
|
+
]),
|
|
361
|
+
h('div', { key: 'key', style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } }, [
|
|
362
|
+
h('span', { key: 'label', style: { ...codeStyle, flex: '0 0 84px', color: labelTertiary } }, t('endpointKey')),
|
|
363
|
+
h('code', { key: 'value', style: valueStyle }, endpoint.apiKey || '—'),
|
|
364
|
+
h(
|
|
365
|
+
'button',
|
|
366
|
+
{
|
|
367
|
+
key: 'copy',
|
|
368
|
+
type: 'button',
|
|
369
|
+
style: smallButtonStyle,
|
|
370
|
+
disabled: busy || !endpoint.apiKey,
|
|
371
|
+
onClick: () => copy('key', endpoint.apiKey),
|
|
372
|
+
},
|
|
373
|
+
copied === 'key' ? t('copied') : t('copy'),
|
|
374
|
+
),
|
|
375
|
+
]),
|
|
376
|
+
])
|
|
377
|
+
: h('p', { key: 'down', style: { ...hintStyle, color: 'var(--dsw-alias-label-warning, #bf8700)' } }, t('endpointDown')),
|
|
282
378
|
]),
|
|
283
379
|
|
|
284
|
-
|
|
285
|
-
|
|
380
|
+
// ---- Key 池 -------------------------------------------------------
|
|
381
|
+
h('div', { key: 'pool', style: blockStyle }, [
|
|
382
|
+
h('h3', { key: 'title', style: blockTitleStyle }, t('keysTitle')),
|
|
383
|
+
h('textarea', {
|
|
384
|
+
key: 'draft',
|
|
385
|
+
style: areaStyle,
|
|
386
|
+
value: draft,
|
|
387
|
+
spellCheck: false,
|
|
388
|
+
rows: 3,
|
|
389
|
+
placeholder: t('placeholder'),
|
|
390
|
+
onChange: (event) => {
|
|
391
|
+
setDraft(event.target.value);
|
|
392
|
+
},
|
|
393
|
+
}),
|
|
394
|
+
h('div', { key: 'actions', style: { display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' } }, [
|
|
395
|
+
h(
|
|
396
|
+
'button',
|
|
397
|
+
{
|
|
398
|
+
key: 'save',
|
|
399
|
+
type: 'button',
|
|
400
|
+
style: canSave ? buttonPrimaryStyle : { ...buttonPrimaryStyle, opacity: 0.5, cursor: 'default' },
|
|
401
|
+
disabled: !canSave,
|
|
402
|
+
onClick: addKeys,
|
|
403
|
+
},
|
|
404
|
+
busy ? t('working') : t('save'),
|
|
405
|
+
),
|
|
406
|
+
h('button', { key: 'refresh', type: 'button', style: buttonStyle, disabled: busy, onClick: refreshCatalog }, t('refreshCatalog')),
|
|
407
|
+
keys.length > 0
|
|
408
|
+
? h('button', { key: 'clear', type: 'button', style: buttonStyle, disabled: busy, onClick: clearKeys }, t('clear'))
|
|
409
|
+
: null,
|
|
410
|
+
]),
|
|
411
|
+
|
|
412
|
+
keys.length === 0
|
|
413
|
+
? h('p', { key: 'empty', style: hintStyle }, t('empty'))
|
|
414
|
+
: h(
|
|
415
|
+
'ul',
|
|
416
|
+
{ key: 'list', style: listStyle },
|
|
417
|
+
keys.map((row) => {
|
|
418
|
+
const probe = tested[row.id];
|
|
419
|
+
return h('li', { key: row.id, style: rowStyle }, [
|
|
420
|
+
h('span', { key: 'mask', style: { ...codeStyle, flex: '1 1 auto', wordBreak: 'break-all' } }, row.key),
|
|
421
|
+
h('span', { key: 'status', style: badgeStyle(row.status) }, t(`status_${row.status}`)),
|
|
422
|
+
h(
|
|
423
|
+
'span',
|
|
424
|
+
{ key: 'stats', style: { ...codeStyle, flex: '0 0 auto' } },
|
|
425
|
+
t('stats', { ok: String(row.stats.successes), total: String(row.stats.requests), limited: String(row.stats.rateLimited) }),
|
|
426
|
+
),
|
|
427
|
+
row.status === 'cooldown' && row.cooldownRemaining > 0
|
|
428
|
+
? h('span', { key: 'cd', style: { ...codeStyle, flex: '0 0 auto' } }, t('cooldown', { s: String(row.cooldownRemaining) }))
|
|
429
|
+
: null,
|
|
430
|
+
probe
|
|
431
|
+
? h(
|
|
432
|
+
'span',
|
|
433
|
+
{
|
|
434
|
+
key: 'probe',
|
|
435
|
+
style: {
|
|
436
|
+
...codeStyle,
|
|
437
|
+
flex: '0 0 auto',
|
|
438
|
+
color: probe.ok ? 'var(--dsw-alias-label-success, #2ea043)' : 'var(--dsw-alias-label-danger, #cf222e)',
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
probe.ok ? `✓ ${probe.latencyMs}ms` : `✗ ${probe.status || 'err'}`,
|
|
442
|
+
)
|
|
443
|
+
: null,
|
|
444
|
+
h('button', { key: 'test', type: 'button', style: smallButtonStyle, disabled: busy, onClick: () => testKey(row.id) }, t('test')),
|
|
445
|
+
h('button', { key: 'del', type: 'button', style: smallButtonStyle, disabled: busy, onClick: () => removeKey(row.id) }, t('remove')),
|
|
446
|
+
]);
|
|
447
|
+
}),
|
|
448
|
+
),
|
|
449
|
+
]),
|
|
286
450
|
|
|
287
|
-
// ----
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
451
|
+
// ---- 模型可见性 ---------------------------------------------------
|
|
452
|
+
h('div', { key: 'models', style: blockStyle }, [
|
|
453
|
+
h('h3', { key: 'title', style: blockTitleStyle }, t('modelsTitle')),
|
|
454
|
+
h('p', { key: 'hint', style: hintStyle }, t('modelsHint', { count: String(enabledCount), total: String(models.length) })),
|
|
455
|
+
enabledCount === 0 && models.length > 0
|
|
456
|
+
? h('p', { key: 'warn', style: { ...hintStyle, color: 'var(--dsw-alias-label-warning, #bf8700)' } }, t('modelsAllHidden'))
|
|
457
|
+
: null,
|
|
458
|
+
models.length === 0
|
|
459
|
+
? h('p', { key: 'empty', style: hintStyle }, t('modelsEmpty'))
|
|
460
|
+
: h(
|
|
461
|
+
'ul',
|
|
462
|
+
{ key: 'list', style: listStyle },
|
|
463
|
+
models.map((model) =>
|
|
297
464
|
h(
|
|
298
|
-
'
|
|
299
|
-
{ key:
|
|
300
|
-
|
|
465
|
+
'li',
|
|
466
|
+
{ key: model.id, style: { ...rowStyle, padding: '6px 10px' } },
|
|
467
|
+
h(
|
|
468
|
+
'label',
|
|
469
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 10, flex: '1 1 auto', minWidth: 0, cursor: 'pointer' } },
|
|
470
|
+
[
|
|
471
|
+
h('input', {
|
|
472
|
+
key: 'box',
|
|
473
|
+
type: 'checkbox',
|
|
474
|
+
checked: model.enabled === true,
|
|
475
|
+
disabled: busy,
|
|
476
|
+
onChange: (event) => toggleModel(model.id, event.target.checked),
|
|
477
|
+
}),
|
|
478
|
+
h(
|
|
479
|
+
'span',
|
|
480
|
+
{ key: 'name', style: { fontSize: 13, color: model.enabled ? labelPrimary : labelTertiary, flex: '0 0 auto' } },
|
|
481
|
+
model.name,
|
|
482
|
+
),
|
|
483
|
+
h('span', { key: 'id', style: { ...codeStyle, flex: '1 1 auto', wordBreak: 'break-all' } }, model.id),
|
|
484
|
+
],
|
|
485
|
+
),
|
|
301
486
|
),
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
: null,
|
|
306
|
-
probe
|
|
307
|
-
? h('span', { key: 'probe', style: { ...codeStyle, flex: '0 0 auto', color: probe.ok ? 'var(--dsw-alias-label-success, #2ea043)' : 'var(--dsw-alias-label-danger, #cf222e)' } }, probe.ok ? `✓ ${probe.latencyMs}ms` : `✗ ${probe.status || 'err'}`)
|
|
308
|
-
: null,
|
|
309
|
-
h('button', { key: 'test', type: 'button', style: { ...buttonStyle, minHeight: 26, padding: '2px 10px', fontSize: 12 }, disabled: busy, onClick: () => testKey(row.id) }, t('test')),
|
|
310
|
-
h('button', { key: 'del', type: 'button', style: { ...buttonStyle, minHeight: 26, padding: '2px 10px', fontSize: 12 }, disabled: busy, onClick: () => removeKey(row.id) }, t('remove')),
|
|
311
|
-
]);
|
|
312
|
-
}),
|
|
313
|
-
),
|
|
487
|
+
),
|
|
488
|
+
),
|
|
489
|
+
]),
|
|
314
490
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
? h('p', { key: 'models', style: { ...hintStyle, fontSize: 12 } }, t('modelsHint', { count: String(catalog.count) }))
|
|
318
|
-
: null,
|
|
491
|
+
notice ? h('p', { key: 'notice', role: 'status', style: { ...hintStyle, color: labelSecondary } }, notice) : null,
|
|
492
|
+
error ? h('p', { key: 'error', role: 'alert', style: { ...hintStyle, color: 'var(--dsw-alias-label-danger, #cf222e)' } }, error) : null,
|
|
319
493
|
]);
|
|
320
494
|
}
|
|
321
495
|
|
|
@@ -349,7 +523,21 @@ window.__ModuleLoader__.load({
|
|
|
349
523
|
status_cooldown: 'cooling',
|
|
350
524
|
status_invalid: 'invalid',
|
|
351
525
|
cooldown: '{s}s',
|
|
352
|
-
|
|
526
|
+
endpointTitle: 'Local endpoint',
|
|
527
|
+
endpointHint: 'An OpenAI-compatible endpoint exposed for other agents. Put the URL and API key into any other agent and it works.',
|
|
528
|
+
endpointUrl: 'Base URL',
|
|
529
|
+
endpointKey: 'API key',
|
|
530
|
+
endpointDown: 'The local endpoint is not running; the keys are still usable inside DSH.',
|
|
531
|
+
copy: 'Copy',
|
|
532
|
+
copied: 'Copied',
|
|
533
|
+
copyFailed: 'Copy failed — select the text and copy manually.',
|
|
534
|
+
keysTitle: 'Key pool',
|
|
535
|
+
modelsTitle: 'Models in the picker',
|
|
536
|
+
modelsHint: '{count} of {total} models are shown in the model picker.',
|
|
537
|
+
modelsAllHidden: 'Every model is hidden — the picker will be empty until you re-enable one.',
|
|
538
|
+
modelsEmpty: 'No models yet. Add a key and refresh the list.',
|
|
539
|
+
modelShown: '{id} is now shown',
|
|
540
|
+
modelHidden: '{id} is hidden',
|
|
353
541
|
};
|
|
354
542
|
|
|
355
543
|
const zh = {
|
|
@@ -380,7 +568,21 @@ window.__ModuleLoader__.load({
|
|
|
380
568
|
status_cooldown: '冷却中',
|
|
381
569
|
status_invalid: '已失效',
|
|
382
570
|
cooldown: '{s}s',
|
|
383
|
-
|
|
571
|
+
endpointTitle: '本地接口',
|
|
572
|
+
endpointHint: '对外提供的 OpenAI 兼容接口。把 url 和 API Key 填进其他 Agent 即可直接使用。',
|
|
573
|
+
endpointUrl: '接口地址',
|
|
574
|
+
endpointKey: 'API Key',
|
|
575
|
+
endpointDown: '本地接口未启动;Key 在 DSH 内仍可正常使用。',
|
|
576
|
+
copy: '复制',
|
|
577
|
+
copied: '已复制',
|
|
578
|
+
copyFailed: '复制失败,请手动选中文本复制。',
|
|
579
|
+
keysTitle: 'Key 池',
|
|
580
|
+
modelsTitle: '下拉中的模型',
|
|
581
|
+
modelsHint: '共 {total} 个模型,当前展示 {count} 个。',
|
|
582
|
+
modelsAllHidden: '所有模型都被隐藏了,模型选择器会是空的 —— 至少勾回一个。',
|
|
583
|
+
modelsEmpty: '还没有模型,请先添加 key 并刷新列表。',
|
|
584
|
+
modelShown: '已展示 {id}',
|
|
585
|
+
modelHidden: '已隐藏 {id}',
|
|
384
586
|
};
|
|
385
587
|
|
|
386
588
|
// ------------------------------------------------------------ 错误隔离
|
|
@@ -414,7 +616,29 @@ window.__ModuleLoader__.load({
|
|
|
414
616
|
|
|
415
617
|
const t = ctx.locale.bind(NS);
|
|
416
618
|
|
|
417
|
-
//
|
|
619
|
+
// 槽位一(主入口):设置侧栏里的一级分区,与「通用 / 模型 / 插件」并列。
|
|
620
|
+
guardClientContribution('settings.section', () => {
|
|
621
|
+
ctx.slots.inject('settings.section', () =>
|
|
622
|
+
guardClientContribution('settings.section', () =>
|
|
623
|
+
ctx.slots.register(
|
|
624
|
+
{
|
|
625
|
+
name: 'settings.section',
|
|
626
|
+
id: 'sensenova-pool',
|
|
627
|
+
// 排在「通用(0) / 模型 / 账号 / 插件」之后,避免挤掉宿主自己的顺序。
|
|
628
|
+
order: 40,
|
|
629
|
+
// 侧栏栏目名用包名:设置里一眼能对上是哪个插件。
|
|
630
|
+
// 页内标题仍用中文名(见 t('nav')),两者刻意不同。
|
|
631
|
+
label: () => BUNDLE_NAME,
|
|
632
|
+
locale: NS,
|
|
633
|
+
inject: () => ({ t }),
|
|
634
|
+
},
|
|
635
|
+
({ t: seat }) => h(KeyCard, { t: seat, variant: 'section' }),
|
|
636
|
+
),
|
|
637
|
+
),
|
|
638
|
+
);
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// 槽位二:插件页里本 bundle 的配置区(0.1.6+ 的现行位置)。
|
|
418
642
|
guardClientContribution('plugins.bundle.config', () => {
|
|
419
643
|
ctx.slots.inject('plugins.bundle.config', () =>
|
|
420
644
|
guardClientContribution('plugins.bundle.config', () =>
|
|
@@ -425,13 +649,13 @@ window.__ModuleLoader__.load({
|
|
|
425
649
|
locale: NS,
|
|
426
650
|
inject: () => ({ t }),
|
|
427
651
|
},
|
|
428
|
-
({ view, t: seat }) => (view === 'summary' ? seat('hint') : h(KeyCard, { t: seat })),
|
|
652
|
+
({ view, t: seat }) => (view === 'summary' ? seat('hint') : h(KeyCard, { t: seat, variant: 'card' })),
|
|
429
653
|
),
|
|
430
654
|
),
|
|
431
655
|
);
|
|
432
656
|
});
|
|
433
657
|
|
|
434
|
-
//
|
|
658
|
+
// 槽位三:设置页的插件标签页,给用户第三个入口。
|
|
435
659
|
guardClientContribution('settings.plugins.tab', () => {
|
|
436
660
|
ctx.slots.inject('settings.plugins.tab', () =>
|
|
437
661
|
guardClientContribution('settings.plugins.tab', () =>
|
|
@@ -440,11 +664,11 @@ window.__ModuleLoader__.load({
|
|
|
440
664
|
name: 'settings.plugins.tab',
|
|
441
665
|
id: BUNDLE_NAME,
|
|
442
666
|
order: 40,
|
|
443
|
-
label: () =>
|
|
667
|
+
label: () => BUNDLE_NAME,
|
|
444
668
|
locale: NS,
|
|
445
669
|
inject: () => ({ t }),
|
|
446
670
|
},
|
|
447
|
-
({ t: seat }) => h(KeyCard, { t: seat }),
|
|
671
|
+
({ t: seat }) => h(KeyCard, { t: seat, variant: 'card' }),
|
|
448
672
|
),
|
|
449
673
|
),
|
|
450
674
|
);
|