dsh-aperture 0.3.1 → 0.3.2
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.en.md +8 -7
- package/README.md +8 -7
- package/lib/client.js +1463 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +2084 -131
- package/lib/{aperture.d.ts → types/aperture.d.ts} +12 -10
- package/lib/types/catalog.d.ts +25 -0
- package/lib/types/config.d.ts +204 -0
- package/lib/types/index.d.ts +37 -0
- package/lib/{metadata → types/metadata}/extract.d.ts +15 -24
- package/lib/types/metadata/modelsdev.d.ts +40 -0
- package/lib/{metadata → types/metadata}/utils.d.ts +2 -0
- package/lib/types/panel.d.ts +71 -0
- package/lib/types/profile.d.ts +55 -0
- package/lib/types/registry.d.ts +31 -0
- package/lib/{relay.d.ts → types/relay.d.ts} +2 -0
- package/lib/types/remote.d.ts +54 -0
- package/lib/types/report.d.ts +115 -0
- package/lib/types/runtime.d.ts +87 -0
- package/lib/{sync.d.ts → types/sync.d.ts} +12 -23
- package/lib/types/types.d.ts +118 -0
- package/lib/{url.d.ts → types/url.d.ts} +5 -3
- package/package.json +32 -13
- package/client/aperture.js +0 -1566
- package/lib/aperture.js +0 -107
- package/lib/catalog.d.ts +0 -35
- package/lib/catalog.js +0 -74
- package/lib/config.d.ts +0 -214
- package/lib/config.js +0 -168
- package/lib/index.d.ts +0 -70
- package/lib/metadata/extract.js +0 -217
- package/lib/metadata/modelsdev.d.ts +0 -53
- package/lib/metadata/modelsdev.js +0 -302
- package/lib/metadata/utils.js +0 -86
- package/lib/panel.d.ts +0 -86
- package/lib/panel.js +0 -263
- package/lib/profile.d.ts +0 -62
- package/lib/profile.js +0 -158
- package/lib/registry.d.ts +0 -48
- package/lib/registry.js +0 -234
- package/lib/relay.js +0 -63
- package/lib/remote.d.ts +0 -64
- package/lib/remote.js +0 -96
- package/lib/report.d.ts +0 -123
- package/lib/report.js +0 -109
- package/lib/runtime.d.ts +0 -97
- package/lib/runtime.js +0 -194
- package/lib/sync.js +0 -176
- package/lib/types.d.ts +0 -116
- package/lib/types.js +0 -10
- package/lib/url.js +0 -67
package/client/aperture.js
DELETED
|
@@ -1,1566 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dsh-aperture` 浏览器半边:**「插件」页里本插件那个包页上的配置页**。
|
|
3
|
-
*
|
|
4
|
-
* 注册在包级配置槽位 `plugins.bundle.config` 上,键是包名 `dsh-aperture`:点开插件列表里的本
|
|
5
|
-
* 插件就是这一页。页面只交内容,控件用官方原语,**没有卡片**,标题与面包屑由页主画。
|
|
6
|
-
*
|
|
7
|
-
* 地址与同步开关交给官方设置表单(`SettingsForm` / `SettingsValueField` / `SettingsFormModel`):
|
|
8
|
-
* 草稿与生效值的差分、`revision` 围栏写入、保存失败保留草稿、只读与「命名空间没在服务」都归它
|
|
9
|
-
* 管,本模块只声明每个字段怎么在「存下来的值」与「输入框文本」之间换算。
|
|
10
|
-
*
|
|
11
|
-
* 注入面是 `slots` / `locale` / `remote` / `configForms`:报告与「立刻刷新」经自己的
|
|
12
|
-
* `aperturePanel` Remote 往返;设置的读写面向 `configForms` 要——**包级**配置页页主只递
|
|
13
|
-
* `view: 'page'`、不递 `form`(递 `form` 的是行级与条目级),所以得按设置命名空间自己取。状态走
|
|
14
|
-
* 注入面里的 `hooks`(渲染器把它变成 `useApertureCard` 选择器钩子),动作走普通函数。
|
|
15
|
-
*
|
|
16
|
-
* 客户端模块系统把 `dsh.client.inject` 里列出的包注册成可 `require` 的模块,因此这里能直接
|
|
17
|
-
* require 官方客户端包,不必引入打包器。**这个文件就是构建产物**:模块系统只要求一个经典脚本,
|
|
18
|
-
* 用 `window.__ModuleLoader__.load({ id, factory })` 的握手报名,不要求打包器,因此这里直接写
|
|
19
|
-
* CJS 工厂体,用 `createElement` 而不是 JSX。
|
|
20
|
-
*
|
|
21
|
-
* @module dsh-aperture/client
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
window.__ModuleLoader__.load({
|
|
25
|
-
id: 'dsh-aperture',
|
|
26
|
-
factory: (require) => {
|
|
27
|
-
const React = require('react');
|
|
28
|
-
const {
|
|
29
|
-
SettingsForm,
|
|
30
|
-
SettingsValueField,
|
|
31
|
-
SettingsFormModel,
|
|
32
|
-
settingsTextField,
|
|
33
|
-
Button,
|
|
34
|
-
Checkbox,
|
|
35
|
-
IconChevronRightOutlineRegular,
|
|
36
|
-
IconRefreshOutlineRegular,
|
|
37
|
-
SegmentedControl,
|
|
38
|
-
StateDot,
|
|
39
|
-
Switch,
|
|
40
|
-
Tag,
|
|
41
|
-
} = require('@deepseek-ai/dsh-client-ui-primitives');
|
|
42
|
-
|
|
43
|
-
const h = React.createElement;
|
|
44
|
-
|
|
45
|
-
/** 字典命名空间(本插件拥有);配置页的 `locale` 声明与 `ctx.locale.bind` 都用它。 */
|
|
46
|
-
const NS = 'settings.aperturePanel';
|
|
47
|
-
/** 宿主半边的 Remote 命名空间(`src/remote.ts`)。 */
|
|
48
|
-
const PANEL = 'aperturePanel';
|
|
49
|
-
/** 包名,取自 package.json;它同时是包级配置页的键。 */
|
|
50
|
-
const PACKAGE = 'dsh-aperture';
|
|
51
|
-
/** 样式表的归属标记;卸载与热替换时按它回收。 */
|
|
52
|
-
const STYLE_OWNER = 'aperture/client.js';
|
|
53
|
-
/**
|
|
54
|
-
* 设置命名空间(宿主 `src/config.ts` 的 `APERTURE_NAMESPACE`,也是 `cordis.patch.yml` 里那一行
|
|
55
|
-
* 的 id)。包级配置页页主不递 `form`,这一份表单就是按它向 `configForms` 要来的。
|
|
56
|
-
*/
|
|
57
|
-
const SETTINGS_NS = 'aperture';
|
|
58
|
-
/** 这一页自己编辑的两个字段;其余配置键(`models` 除外)留给配置文件。 */
|
|
59
|
-
const FIELDS = Object.freeze(['baseUrl', 'sync']);
|
|
60
|
-
|
|
61
|
-
// ---------------------------------------------------------------- 端点契约
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 浏览器半边与宿主半边之间的线格式。
|
|
65
|
-
*
|
|
66
|
-
* 只有一个直通编解码器,因为浏览器侧从不解析这些值:注册表(`@deepseek-ai/dsh-typert-registry`)
|
|
67
|
-
* 只检查 `mode` 是 `strict`、`typeSymbol` 非空、`create` 是个函数,网关客户端只读参数上的
|
|
68
|
-
* `mode` 与结果上可选的 `decode`/`encode`,**没有一处调用 `create()`**,逐字段手写的 wire 校验
|
|
69
|
-
* 因此永远不会执行。曾经那 300 行文法还埋了个雷:注册表要的是 `create` 工厂,`schema` 字段不被
|
|
70
|
-
* 承认,于是 `$mount` 抛 `strict codec has no create() factory`,整份贡献被拒,界面安静地什么
|
|
71
|
-
* 都不出现。
|
|
72
|
-
*
|
|
73
|
-
* 端点名不能与命名空间服务自己的成员重名:api-gateway 为每个命名空间建的
|
|
74
|
-
* `RemoteNamespaceService` 会把端点收成自己的属性,撞上 `remove` / `has` / `install` / `name` /
|
|
75
|
-
* `ctx` 这类预置名字时校验会拒绝**整份**贡献。
|
|
76
|
-
*/
|
|
77
|
-
const SCHEMA = Object.freeze({ parse: (value) => value });
|
|
78
|
-
const CODEC = Object.freeze({
|
|
79
|
-
mode: 'strict',
|
|
80
|
-
typeSymbol: `${PACKAGE}/types#any`,
|
|
81
|
-
create: () => SCHEMA,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 一个端点的浏览器侧描述符。
|
|
86
|
-
*
|
|
87
|
-
* 参数按宿主方法的形参顺序给出;调用点按位置传参,网关按 `wire` 映射,并且**自动省掉
|
|
88
|
-
* `undefined` 实参**(`if (value !== void 0) args[parameter.wire] = value`),所以「没提到的
|
|
89
|
-
* 参数」天然就是「不碰」。
|
|
90
|
-
*
|
|
91
|
-
* @param {Array<string>} parameters - 参数名,顺序与宿主方法一致。
|
|
92
|
-
*/
|
|
93
|
-
function descriptor(method, parameters = []) {
|
|
94
|
-
return Object.freeze({
|
|
95
|
-
id: `${PACKAGE}#${PANEL}/${method}`,
|
|
96
|
-
service: PANEL,
|
|
97
|
-
namespace: PANEL,
|
|
98
|
-
method,
|
|
99
|
-
invocation: Object.freeze({ kind: 'direct' }),
|
|
100
|
-
parameters: Object.freeze(parameters.map((name) => Object.freeze({
|
|
101
|
-
name,
|
|
102
|
-
wire: name,
|
|
103
|
-
source: 'json',
|
|
104
|
-
codec: CODEC,
|
|
105
|
-
}))),
|
|
106
|
-
result: CODEC,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** 与宿主半边 `PANEL_INVOCATIONS` 一一对应的贡献。 */
|
|
111
|
-
const REMOTE = Object.freeze({
|
|
112
|
-
package: PACKAGE,
|
|
113
|
-
descriptors: Object.freeze([
|
|
114
|
-
descriptor('status'),
|
|
115
|
-
descriptor('refresh'),
|
|
116
|
-
descriptor('edit', ['id', 'patch']),
|
|
117
|
-
]),
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* 界面能编辑的覆盖键。
|
|
122
|
-
*
|
|
123
|
-
* 列表以外的键(例如 `reasoningEfforts`)一旦出现在用户层里,这一行就只能整条撤:只清认得
|
|
124
|
-
* 的那几项,它在报告里仍然是「已覆盖」,那颗标签会按不下去。
|
|
125
|
-
*/
|
|
126
|
-
const EDITABLE_KEYS = Object.freeze(['name', 'api', 'contextWindow', 'maxTokens', 'input', 'thinking', 'alias']);
|
|
127
|
-
|
|
128
|
-
/** 把 `RemoteResult` 拆成值,失败则抛人话。 */
|
|
129
|
-
function unwrap(result) {
|
|
130
|
-
if (result.ok) return result.value;
|
|
131
|
-
const detail = result.error && result.error.message ? result.error.message : '未知原因';
|
|
132
|
-
throw new Error(`面板暂时连不上后台(${detail});若反复出现请重启 dsh web。`);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// -------------------------------------------------------------------- 样式
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 配置页样式。
|
|
139
|
-
*
|
|
140
|
-
* 页面在独立 bundle 里,用不了仓库的 CSS module 管线,因此样式随包分发、按 effect 生命周期注入,
|
|
141
|
-
* 卸载时移除;元素按 `data-plugin-css` 认领,与自己重名的那份先删掉(热替换)。
|
|
142
|
-
*
|
|
143
|
-
* 选择器全部收在根节点的 `[data-dsh-aperture]` 之下,颜色只引用 dsh web 的主题 token
|
|
144
|
-
* (`--dsw-alias-*`,各带回落值),深浅色自动跟随。
|
|
145
|
-
*
|
|
146
|
-
* 排版照官方「模型」页:一个模型一张卡片(发丝描边 + 大圆角),展开的编辑器是卡片里一块内嵌面,
|
|
147
|
-
* 字段用官方 `SettingsValueField`,因此徽章、重置、提示这些细活与官方设置页逐像素一致。官方那些
|
|
148
|
-
* 类名是打包器哈希出来的私有产物,抄不到,能抄的只有配方(描边、圆角、内边距、字号)。
|
|
149
|
-
*
|
|
150
|
-
* 颜色只许用「这一页真的定义过」的 token:官方原语自己用的那几个(`bg-layer-3`、`border-l4`、
|
|
151
|
-
* `interactive-bg-hover`)与 Theme 检查面列出的那十几个。像 `--dsw-alias-settings-card-stroke`
|
|
152
|
-
* 这种只活在官方「模型」页自己那份组件 CSS 里的名字,在插件页上根本没定义——引用它等于引用一个
|
|
153
|
-
* 空值,回落值又是白色,于是亮色主题下卡片连边都看不见(暗色主题反而正常,因为回落值是白 16%)。
|
|
154
|
-
* 亮色主题下 `bg-layer-*` 全是白色(层与层靠阴影分开),所以卡片只能靠描边立住,底色只是给暗色
|
|
155
|
-
* 主题加一点抬起感。
|
|
156
|
-
*
|
|
157
|
-
* @returns {Function} 卸载时移除样式表的 disposer。
|
|
158
|
-
*/
|
|
159
|
-
function installStyles() {
|
|
160
|
-
const stale = document.querySelector(`style[data-plugin-css="${STYLE_OWNER}"]`);
|
|
161
|
-
if (stale !== null && stale.parentNode !== null) stale.parentNode.removeChild(stale);
|
|
162
|
-
|
|
163
|
-
const element = document.createElement('style');
|
|
164
|
-
element.dataset.plugin = PACKAGE;
|
|
165
|
-
element.dataset.pluginCss = STYLE_OWNER;
|
|
166
|
-
element.textContent = `
|
|
167
|
-
[data-dsh-aperture] {
|
|
168
|
-
display: flex;
|
|
169
|
-
flex-direction: column;
|
|
170
|
-
gap: 20px;
|
|
171
|
-
font-size: 13px;
|
|
172
|
-
color: var(--dsw-alias-label-primary, #e6e6e6);
|
|
173
|
-
}
|
|
174
|
-
[data-dsh-aperture] .dap-group {
|
|
175
|
-
display: flex;
|
|
176
|
-
flex-direction: column;
|
|
177
|
-
gap: 12px;
|
|
178
|
-
}
|
|
179
|
-
[data-dsh-aperture] .dap-groupHead {
|
|
180
|
-
display: flex;
|
|
181
|
-
align-items: center;
|
|
182
|
-
justify-content: space-between;
|
|
183
|
-
gap: 12px;
|
|
184
|
-
}
|
|
185
|
-
[data-dsh-aperture] .dap-titleWrap {
|
|
186
|
-
display: inline-flex;
|
|
187
|
-
align-items: baseline;
|
|
188
|
-
gap: 8px;
|
|
189
|
-
min-width: 0;
|
|
190
|
-
}
|
|
191
|
-
[data-dsh-aperture] .dap-groupTitle {
|
|
192
|
-
margin: 0;
|
|
193
|
-
font-size: 14px;
|
|
194
|
-
font-weight: 500;
|
|
195
|
-
line-height: 22px;
|
|
196
|
-
}
|
|
197
|
-
/* 数目跟在标题后面,用等宽数字,免得一轮刷新改写时宽度乱跳。 */
|
|
198
|
-
[data-dsh-aperture] .dap-count {
|
|
199
|
-
font-size: 14px;
|
|
200
|
-
line-height: 22px;
|
|
201
|
-
font-variant-numeric: tabular-nums;
|
|
202
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
203
|
-
}
|
|
204
|
-
/* 空状态是官方「模型」页那条虚线盒子:没有内容时给个形状,不留白。 */
|
|
205
|
-
[data-dsh-aperture] .dap-empty {
|
|
206
|
-
margin: 0;
|
|
207
|
-
padding: 12px;
|
|
208
|
-
border: 0.5px dashed var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));
|
|
209
|
-
border-radius: var(--dsw-radius-lg, 16px);
|
|
210
|
-
text-align: center;
|
|
211
|
-
font-size: 12px;
|
|
212
|
-
line-height: 18px;
|
|
213
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
214
|
-
}
|
|
215
|
-
[data-dsh-aperture] .dap-hint {
|
|
216
|
-
margin: 0;
|
|
217
|
-
font-size: 12px;
|
|
218
|
-
line-height: 1.6;
|
|
219
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
220
|
-
}
|
|
221
|
-
[data-dsh-aperture] .dap-banner {
|
|
222
|
-
margin: 0;
|
|
223
|
-
font-size: 12px;
|
|
224
|
-
line-height: 1.6;
|
|
225
|
-
color: var(--dsw-alias-label-secondary, #c9c9c9);
|
|
226
|
-
}
|
|
227
|
-
[data-dsh-aperture] .dap-banner[data-ok='false'] {
|
|
228
|
-
color: var(--dsw-alias-state-error-primary, #e06c75);
|
|
229
|
-
}
|
|
230
|
-
[data-dsh-aperture] .dap-toggleRow {
|
|
231
|
-
display: flex;
|
|
232
|
-
align-items: flex-start;
|
|
233
|
-
justify-content: space-between;
|
|
234
|
-
gap: 16px;
|
|
235
|
-
font-size: 13px;
|
|
236
|
-
line-height: 1.5;
|
|
237
|
-
}
|
|
238
|
-
[data-dsh-aperture] .dap-toggleText {
|
|
239
|
-
display: flex;
|
|
240
|
-
flex-direction: column;
|
|
241
|
-
gap: 2px;
|
|
242
|
-
min-width: 0;
|
|
243
|
-
}
|
|
244
|
-
/* 一个模型一张卡片:发丝描边立形状(官方输入框用的就是这一档描边),底色只在暗色主题下抬起一层。 */
|
|
245
|
-
[data-dsh-aperture] .dap-rows {
|
|
246
|
-
display: flex;
|
|
247
|
-
flex-direction: column;
|
|
248
|
-
gap: 8px;
|
|
249
|
-
margin: 0;
|
|
250
|
-
padding: 0;
|
|
251
|
-
list-style: none;
|
|
252
|
-
}
|
|
253
|
-
[data-dsh-aperture] .dap-card {
|
|
254
|
-
display: flex;
|
|
255
|
-
flex-direction: column;
|
|
256
|
-
border: 0.5px solid var(--dsw-alias-border-l4, rgba(128, 128, 128, 0.36));
|
|
257
|
-
border-radius: var(--dsw-radius-xl, 20px);
|
|
258
|
-
background: var(--dsw-alias-bg-layer-2, transparent);
|
|
259
|
-
}
|
|
260
|
-
/* 行首是一条盖满整行的按钮:点哪儿都能展开这一行。 */
|
|
261
|
-
[data-dsh-aperture] .dap-cardHead {
|
|
262
|
-
display: flex;
|
|
263
|
-
/* 顶着第一行走,不居中:这一行有两行身份(名字 + 事实),居中的话状态点会落在两行中间。 */
|
|
264
|
-
align-items: flex-start;
|
|
265
|
-
gap: 10px;
|
|
266
|
-
width: 100%;
|
|
267
|
-
padding: 12px 14px;
|
|
268
|
-
border: 0;
|
|
269
|
-
border-radius: inherit;
|
|
270
|
-
background: none;
|
|
271
|
-
color: inherit;
|
|
272
|
-
font: inherit;
|
|
273
|
-
text-align: left;
|
|
274
|
-
cursor: pointer;
|
|
275
|
-
}
|
|
276
|
-
[data-dsh-aperture] .dap-cardHead:hover {
|
|
277
|
-
background: var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, 0.06));
|
|
278
|
-
}
|
|
279
|
-
[data-dsh-aperture] .dap-cardHead[aria-expanded='true'] {
|
|
280
|
-
border-bottom: 0.5px solid var(--dsw-alias-border-l2, rgba(255, 255, 255, 0.12));
|
|
281
|
-
border-radius: var(--dsw-radius-xl, 20px) var(--dsw-radius-xl, 20px) 0 0;
|
|
282
|
-
}
|
|
283
|
-
[data-dsh-aperture] .dap-cardHead:focus-visible {
|
|
284
|
-
outline: 2px solid var(--dsw-alias-brand-primary, #7aaaff);
|
|
285
|
-
outline-offset: 1px;
|
|
286
|
-
}
|
|
287
|
-
/* 状态点:写入与否这一列永远在同一处,扫一眼就能比。22px 就是名字那一行的高度,点因此落在名字中间。 */
|
|
288
|
-
[data-dsh-aperture] .dap-status {
|
|
289
|
-
display: inline-flex;
|
|
290
|
-
align-items: center;
|
|
291
|
-
flex: none;
|
|
292
|
-
height: 22px;
|
|
293
|
-
}
|
|
294
|
-
[data-dsh-aperture] .dap-identity {
|
|
295
|
-
display: flex;
|
|
296
|
-
flex-direction: column;
|
|
297
|
-
gap: 2px;
|
|
298
|
-
flex: 1;
|
|
299
|
-
min-width: 0;
|
|
300
|
-
}
|
|
301
|
-
[data-dsh-aperture] .dap-identityTop {
|
|
302
|
-
display: flex;
|
|
303
|
-
align-items: center;
|
|
304
|
-
flex-wrap: wrap;
|
|
305
|
-
gap: 6px;
|
|
306
|
-
min-width: 0;
|
|
307
|
-
}
|
|
308
|
-
[data-dsh-aperture] .dap-name {
|
|
309
|
-
overflow: hidden;
|
|
310
|
-
font-size: 14px;
|
|
311
|
-
font-weight: 500;
|
|
312
|
-
line-height: 22px;
|
|
313
|
-
text-overflow: ellipsis;
|
|
314
|
-
white-space: nowrap;
|
|
315
|
-
}
|
|
316
|
-
/* 事实一项一句(「路由 x」「上下文 1M」),之间用小圆点分开:比一串空格好认,也不抢字号。
|
|
317
|
-
名字必须是 .dap-factRow 而不是 .dap-facts:报告那张 dl 已经占了 .dap-facts,而且它的规则在后面,
|
|
318
|
-
同名的话会把这里压成竖排(一条一行)。 */
|
|
319
|
-
[data-dsh-aperture] .dap-factRow {
|
|
320
|
-
display: flex;
|
|
321
|
-
align-items: baseline;
|
|
322
|
-
flex-wrap: wrap;
|
|
323
|
-
column-gap: 6px;
|
|
324
|
-
min-width: 0;
|
|
325
|
-
font-size: 12px;
|
|
326
|
-
line-height: 18px;
|
|
327
|
-
font-variant-numeric: tabular-nums;
|
|
328
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
329
|
-
}
|
|
330
|
-
[data-dsh-aperture] .dap-factItem + .dap-factItem::before {
|
|
331
|
-
content: '·';
|
|
332
|
-
margin-right: 6px;
|
|
333
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
334
|
-
}
|
|
335
|
-
[data-dsh-aperture] .dap-chevron {
|
|
336
|
-
display: inline-flex;
|
|
337
|
-
align-items: center;
|
|
338
|
-
flex: none;
|
|
339
|
-
height: 22px;
|
|
340
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
341
|
-
transition: transform 160ms ease;
|
|
342
|
-
}
|
|
343
|
-
[data-dsh-aperture] .dap-chevron[data-open='true'] {
|
|
344
|
-
transform: rotate(90deg);
|
|
345
|
-
}
|
|
346
|
-
/* 展开区是卡片里的一块内嵌面:暗色主题下比卡片再亮一层,亮色主题下靠这圈描边立住(底色也是白的)。 */
|
|
347
|
-
[data-dsh-aperture] .dap-editor {
|
|
348
|
-
display: flex;
|
|
349
|
-
flex-direction: column;
|
|
350
|
-
gap: 14px;
|
|
351
|
-
margin: 0 14px 14px;
|
|
352
|
-
padding: 14px 16px;
|
|
353
|
-
border: 0.5px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));
|
|
354
|
-
border-radius: var(--dsw-radius-lg, 16px);
|
|
355
|
-
background: var(--dsw-alias-bg-layer-3, transparent);
|
|
356
|
-
}
|
|
357
|
-
[data-dsh-aperture] .dap-editorHead {
|
|
358
|
-
display: flex;
|
|
359
|
-
align-items: center;
|
|
360
|
-
gap: 8px;
|
|
361
|
-
min-width: 0;
|
|
362
|
-
}
|
|
363
|
-
[data-dsh-aperture] .dap-editorId {
|
|
364
|
-
overflow: hidden;
|
|
365
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
366
|
-
font-size: 12px;
|
|
367
|
-
line-height: 18px;
|
|
368
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
369
|
-
text-overflow: ellipsis;
|
|
370
|
-
white-space: nowrap;
|
|
371
|
-
}
|
|
372
|
-
[data-dsh-aperture] .dap-editorDirty {
|
|
373
|
-
margin-left: auto;
|
|
374
|
-
}
|
|
375
|
-
[data-dsh-aperture] .dap-warnNote {
|
|
376
|
-
font-size: 12px;
|
|
377
|
-
line-height: 18px;
|
|
378
|
-
color: var(--dsw-alias-state-warn-primary, #dd8629);
|
|
379
|
-
}
|
|
380
|
-
[data-dsh-aperture] .dap-editGroup {
|
|
381
|
-
display: flex;
|
|
382
|
-
flex-direction: column;
|
|
383
|
-
gap: 4px;
|
|
384
|
-
}
|
|
385
|
-
[data-dsh-aperture] .dap-editGroupTitle {
|
|
386
|
-
font-size: 12px;
|
|
387
|
-
font-weight: 500;
|
|
388
|
-
line-height: 18px;
|
|
389
|
-
color: var(--dsw-alias-label-secondary, #c9c9c9);
|
|
390
|
-
}
|
|
391
|
-
/* 字段用网格排,格子自带一层壳:官方那条「相邻字段加一条上边框」在网格里会错开半格。 */
|
|
392
|
-
[data-dsh-aperture] .dap-fields {
|
|
393
|
-
display: grid;
|
|
394
|
-
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
|
|
395
|
-
gap: 2px 16px;
|
|
396
|
-
}
|
|
397
|
-
[data-dsh-aperture] .dap-fieldCell {
|
|
398
|
-
min-width: 0;
|
|
399
|
-
}
|
|
400
|
-
[data-dsh-aperture] .dap-grid2 {
|
|
401
|
-
display: grid;
|
|
402
|
-
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
|
403
|
-
gap: 14px 16px;
|
|
404
|
-
align-items: start;
|
|
405
|
-
}
|
|
406
|
-
[data-dsh-aperture] .dap-endpoints {
|
|
407
|
-
display: flex;
|
|
408
|
-
flex-direction: column;
|
|
409
|
-
gap: 4px;
|
|
410
|
-
}
|
|
411
|
-
[data-dsh-aperture] .dap-endpointList {
|
|
412
|
-
display: flex;
|
|
413
|
-
flex-direction: column;
|
|
414
|
-
gap: 2px;
|
|
415
|
-
margin: 0;
|
|
416
|
-
padding: 0;
|
|
417
|
-
list-style: none;
|
|
418
|
-
}
|
|
419
|
-
[data-dsh-aperture] .dap-endpoint {
|
|
420
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
421
|
-
font-size: 12px;
|
|
422
|
-
line-height: 18px;
|
|
423
|
-
color: var(--dsw-alias-label-secondary, #c9c9c9);
|
|
424
|
-
overflow-wrap: anywhere;
|
|
425
|
-
}
|
|
426
|
-
[data-dsh-aperture] .dap-inline {
|
|
427
|
-
display: flex;
|
|
428
|
-
align-items: center;
|
|
429
|
-
flex-wrap: wrap;
|
|
430
|
-
gap: 16px;
|
|
431
|
-
}
|
|
432
|
-
[data-dsh-aperture] .dap-control {
|
|
433
|
-
display: flex;
|
|
434
|
-
align-items: center;
|
|
435
|
-
gap: 8px;
|
|
436
|
-
font-size: 13px;
|
|
437
|
-
line-height: 1.5;
|
|
438
|
-
}
|
|
439
|
-
[data-dsh-aperture] .dap-actions {
|
|
440
|
-
display: flex;
|
|
441
|
-
align-items: center;
|
|
442
|
-
gap: 8px;
|
|
443
|
-
padding-top: 2px;
|
|
444
|
-
}
|
|
445
|
-
/* 左边那句「还有几项没写下去」,按钮一律靠右,主按钮在最右。 */
|
|
446
|
-
[data-dsh-aperture] .dap-actionsNote {
|
|
447
|
-
margin-right: auto;
|
|
448
|
-
font-size: 12px;
|
|
449
|
-
line-height: 18px;
|
|
450
|
-
color: var(--dsw-alias-label-tertiary, #8b8b8b);
|
|
451
|
-
}
|
|
452
|
-
`;
|
|
453
|
-
document.head.appendChild(element);
|
|
454
|
-
return () => {
|
|
455
|
-
if (element.parentNode !== null) element.parentNode.removeChild(element);
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// -------------------------------------------------------------------- 字典
|
|
460
|
-
|
|
461
|
-
const zh = {
|
|
462
|
-
save: '保存',
|
|
463
|
-
saving: '保存中…',
|
|
464
|
-
saveFailed: '没被接受:文档可能只读,或刚被别处改过',
|
|
465
|
-
readOnly: '这份设置是只读的,改不动。',
|
|
466
|
-
unavailable: '这一份设置现在读不到:宿主没有把 aperture 段服务给这个页面。',
|
|
467
|
-
|
|
468
|
-
addressLabel: '实例地址',
|
|
469
|
-
addressHint: '填 Aperture 的地址;留空即休眠,不再发现模型。',
|
|
470
|
-
addressPlaceholder: 'http://127.0.0.1:54117',
|
|
471
|
-
syncLabel: '自动同步',
|
|
472
|
-
syncHint: '每轮发现之后,把模型与参数写进 dsh 的 llm-pi-ai 路由。',
|
|
473
|
-
|
|
474
|
-
overridden: '已覆盖',
|
|
475
|
-
overriddenCount: '已覆盖 {count} 项',
|
|
476
|
-
resetField: '恢复默认',
|
|
477
|
-
invalidField: '要填不小于 1 的整数,或留空',
|
|
478
|
-
|
|
479
|
-
refresh: '立刻刷新',
|
|
480
|
-
refreshHint: '立刻重新发现并发布一次,清单与每一行的状态都按这一轮刷新。',
|
|
481
|
-
refreshing: '刷新中…',
|
|
482
|
-
loading: '读取中…',
|
|
483
|
-
|
|
484
|
-
configRefused: '设置已被别处改过,这次改动没有写入:刷新页面后再改一遍。',
|
|
485
|
-
savedResult: '已保存:{result}',
|
|
486
|
-
noChanges: '没有改动,因此没有写入。',
|
|
487
|
-
invalidNumber: '{field} 只能填不小于 1 的整数。',
|
|
488
|
-
|
|
489
|
-
// 「发现报告」那一块删掉之后留下的三句:没有地址时的空状态,以及这一轮两处可能出问题的地方。
|
|
490
|
-
dormantHint: '还没有实例地址:填上并保存之后才会去发现模型。',
|
|
491
|
-
catalogUnavailable: '清单不可用({reason})',
|
|
492
|
-
syncSkipped: '没写({reason})',
|
|
493
|
-
|
|
494
|
-
modelsTitle: '模型',
|
|
495
|
-
modelsHint: '一行一个模型;展开改这一行的覆盖,「保存」只写这一行。顺序来自发现顺序,没有路由可服务的排在最后。',
|
|
496
|
-
modelsCount: '{count} 个',
|
|
497
|
-
noModels: '还没有发现任何模型。',
|
|
498
|
-
unservedTag: '未服务',
|
|
499
|
-
dirtyTag: '有未保存的改动',
|
|
500
|
-
statusUnserved: '没有路由能服务这个模型',
|
|
501
|
-
statusUnknown: '这一轮没有同步,写没写进去看不出来',
|
|
502
|
-
statusPublished: '已写入 dsh 的路由',
|
|
503
|
-
statusNotPublished: '还没写进 dsh 的路由',
|
|
504
|
-
|
|
505
|
-
factContextWindow: '上下文 {count}',
|
|
506
|
-
factMaxTokens: '输出 {count}',
|
|
507
|
-
factRoute: '路由 {route}',
|
|
508
|
-
factProtocol: '协议 {protocol}',
|
|
509
|
-
factInput: '模态 {value}',
|
|
510
|
-
factReasoning: '推理 {value}',
|
|
511
|
-
factAlias: '别名 {alias}',
|
|
512
|
-
factEndpoints: '网关通告的端点:',
|
|
513
|
-
factSource: '来源:{source}',
|
|
514
|
-
|
|
515
|
-
modalityText: '文本',
|
|
516
|
-
modalityImage: '图片',
|
|
517
|
-
modalityNone: '无',
|
|
518
|
-
reasoningFollow: '跟随发现',
|
|
519
|
-
reasoningOn: '开',
|
|
520
|
-
reasoningOff: '关',
|
|
521
|
-
|
|
522
|
-
sourceAperture: 'Aperture',
|
|
523
|
-
sourceModelsDev: 'models.dev',
|
|
524
|
-
sourceConfig: '配置',
|
|
525
|
-
sourceDefault: '默认值',
|
|
526
|
-
|
|
527
|
-
editName: '显示名',
|
|
528
|
-
editApi: '协议',
|
|
529
|
-
editContextWindow: '上下文容量',
|
|
530
|
-
editMaxTokens: '最大输出',
|
|
531
|
-
editInput: '请求模态',
|
|
532
|
-
editReasoning: '推理',
|
|
533
|
-
editAlias: '清单别名',
|
|
534
|
-
editNameHint: '留空即用发现到的名字。',
|
|
535
|
-
editApiHint: '未服务的模型只有这里能救:填上协议它才有路由;留空即用网关通告的协议。',
|
|
536
|
-
editCapacityHint: '可以写 1M、384K;留空即用发现到的容量。',
|
|
537
|
-
editAliasHint: '写进 llm-pi-ai 清单的别名。',
|
|
538
|
-
editInputHint: '这里能覆盖报告说它接收的模态。',
|
|
539
|
-
editReasoningHint: '「跟随发现」就是这一项不写。',
|
|
540
|
-
fieldHelp: '{field}的说明',
|
|
541
|
-
editGroupIdentity: '名称与协议',
|
|
542
|
-
editGroupCapacity: '容量',
|
|
543
|
-
editUnknownOverrides: '这一行还有界面改不动的覆盖({keys}):清空覆盖会整条删掉。',
|
|
544
|
-
pendingChanges: '有 {count} 项改动还没写下去',
|
|
545
|
-
noPendingChanges: '和已保存的值相同',
|
|
546
|
-
saveRow: '保存',
|
|
547
|
-
clearOverrides: '清空覆盖',
|
|
548
|
-
cancelRow: '取消',
|
|
549
|
-
keyReasoningEfforts: '推理档位',
|
|
550
|
-
listSeparator: '、',
|
|
551
|
-
};
|
|
552
|
-
|
|
553
|
-
const en = {
|
|
554
|
-
save: 'Save',
|
|
555
|
-
saving: 'Saving…',
|
|
556
|
-
saveFailed: 'not accepted: the document may be read-only, or just changed elsewhere',
|
|
557
|
-
readOnly: 'These settings are read-only, so nothing can be changed here.',
|
|
558
|
-
unavailable: 'These settings cannot be read right now: the Host does not serve the aperture section to this page.',
|
|
559
|
-
|
|
560
|
-
addressLabel: 'Instance address',
|
|
561
|
-
addressHint: 'Where Aperture listens; leave it empty to go dormant and stop discovering models.',
|
|
562
|
-
addressPlaceholder: 'http://127.0.0.1:54117',
|
|
563
|
-
syncLabel: 'Sync automatically',
|
|
564
|
-
syncHint: 'After each discovery round, write the models and their parameters into dsh\u2019s llm-pi-ai routes.',
|
|
565
|
-
|
|
566
|
-
overridden: 'overridden',
|
|
567
|
-
overriddenCount: '{count} overridden',
|
|
568
|
-
resetField: 'Reset to default',
|
|
569
|
-
invalidField: 'Enter an integer of at least 1, or leave it empty',
|
|
570
|
-
|
|
571
|
-
refresh: 'Refresh now',
|
|
572
|
-
refreshHint: 'Discover and republish once; the list and every row’s status follow this round.',
|
|
573
|
-
refreshing: 'Refreshing…',
|
|
574
|
-
loading: 'Loading…',
|
|
575
|
-
|
|
576
|
-
configRefused: 'These settings changed elsewhere, so this edit was not written. Reload the page and try again.',
|
|
577
|
-
savedResult: 'Saved: {result}',
|
|
578
|
-
noChanges: 'Nothing changed, so nothing was written.',
|
|
579
|
-
invalidNumber: '{field} takes an integer of at least 1.',
|
|
580
|
-
|
|
581
|
-
// What is left of the deleted discovery report: the empty state without an address, plus the two
|
|
582
|
-
// things that can go wrong in a round.
|
|
583
|
-
dormantHint: 'No instance address yet: models are discovered once you set and save one.',
|
|
584
|
-
catalogUnavailable: 'catalog unavailable ({reason})',
|
|
585
|
-
syncSkipped: 'skipped ({reason})',
|
|
586
|
-
|
|
587
|
-
modelsTitle: 'Models',
|
|
588
|
-
modelsHint: 'One model per row; expand a row to edit its overrides, and Save writes only that row. The order comes from discovery, with anything no route can serve last.',
|
|
589
|
-
modelsCount: '{count} models',
|
|
590
|
-
noModels: 'No models discovered yet.',
|
|
591
|
-
unservedTag: 'unserved',
|
|
592
|
-
dirtyTag: 'unsaved edits',
|
|
593
|
-
statusUnserved: 'No route can serve this model',
|
|
594
|
-
statusUnknown: 'This round synced nothing, so whether it was written is unknown',
|
|
595
|
-
statusPublished: 'Written into the dsh routes',
|
|
596
|
-
statusNotPublished: 'Not written into the dsh routes yet',
|
|
597
|
-
|
|
598
|
-
factContextWindow: '{count} context',
|
|
599
|
-
factMaxTokens: 'output {count}',
|
|
600
|
-
factRoute: 'route {route}',
|
|
601
|
-
factProtocol: 'protocol {protocol}',
|
|
602
|
-
factInput: 'modalities {value}',
|
|
603
|
-
factReasoning: 'reasoning {value}',
|
|
604
|
-
factAlias: 'alias {alias}',
|
|
605
|
-
factEndpoints: 'Endpoints the gateway advertises:',
|
|
606
|
-
factSource: 'Source: {source}',
|
|
607
|
-
|
|
608
|
-
modalityText: 'text',
|
|
609
|
-
modalityImage: 'image',
|
|
610
|
-
modalityNone: 'none',
|
|
611
|
-
reasoningFollow: 'Follow discovery',
|
|
612
|
-
reasoningOn: 'On',
|
|
613
|
-
reasoningOff: 'Off',
|
|
614
|
-
|
|
615
|
-
sourceAperture: 'Aperture',
|
|
616
|
-
sourceModelsDev: 'models.dev',
|
|
617
|
-
sourceConfig: 'config',
|
|
618
|
-
sourceDefault: 'default',
|
|
619
|
-
|
|
620
|
-
editName: 'Display name',
|
|
621
|
-
editApi: 'Protocol',
|
|
622
|
-
editContextWindow: 'Context window',
|
|
623
|
-
editMaxTokens: 'Max output',
|
|
624
|
-
editInput: 'Request modalities',
|
|
625
|
-
editReasoning: 'Reasoning',
|
|
626
|
-
editAlias: 'Catalog alias',
|
|
627
|
-
editNameHint: 'Leave it empty to use the discovered name.',
|
|
628
|
-
editApiHint: 'The only way an unserved model gets a route is a protocol here; leave it empty to use the advertised one.',
|
|
629
|
-
editCapacityHint: 'Write 1M or 384K; leave it empty to use the discovered capacity.',
|
|
630
|
-
editAliasHint: 'The alias written into the llm-pi-ai catalog.',
|
|
631
|
-
editInputHint: 'This overrides the modalities the report says it accepts.',
|
|
632
|
-
editReasoningHint: '\u201cFollow discovery\u201d leaves this key unwritten.',
|
|
633
|
-
fieldHelp: 'About {field}',
|
|
634
|
-
editGroupIdentity: 'Name and protocol',
|
|
635
|
-
editGroupCapacity: 'Capacity',
|
|
636
|
-
editUnknownOverrides: 'This row also carries overrides this page cannot edit ({keys}); clearing overrides removes the whole entry.',
|
|
637
|
-
pendingChanges: '{count} edits not written yet',
|
|
638
|
-
noPendingChanges: 'Matches the saved values',
|
|
639
|
-
saveRow: 'Save',
|
|
640
|
-
clearOverrides: 'Clear overrides',
|
|
641
|
-
cancelRow: 'Cancel',
|
|
642
|
-
keyReasoningEfforts: 'reasoning efforts',
|
|
643
|
-
listSeparator: ', ',
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
// ------------------------------------------------------------------ 小工具
|
|
647
|
-
|
|
648
|
-
/** 一个错误的人话形式。 */
|
|
649
|
-
function textOf(error) {
|
|
650
|
-
return error instanceof Error ? error.message : String(error);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/** token 计数的千位分隔符;跟随浏览器语言。 */
|
|
654
|
-
function formatCount(value) {
|
|
655
|
-
return value.toLocaleString();
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
/** 容量能写成的样子:十进制数加一个可选的 K/M 后缀。 */
|
|
659
|
-
const CAPACITY_PATTERN = /^(\d+(?:\.\d+)?)([km])?$/i;
|
|
660
|
-
/** 后缀是十进制的:`1M` 就是 1000K,跟容量平时的说法一致。 */
|
|
661
|
-
const CAPACITY_SCALE = { k: 1e3, m: 1e6 };
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* 读输入框里的容量,好让人写 `1M`、`100K` 而不必去数零。与官方「模型」页同一套写法(它的
|
|
665
|
-
* `parseCapacity`):空串是「这一项不覆盖」,读不出来的返回 `NaN`,由调用方在本地挡下来。
|
|
666
|
-
*
|
|
667
|
-
* @returns {number|undefined} token 数;空串给 `undefined`,读不出来给 `NaN`。
|
|
668
|
-
*/
|
|
669
|
-
function parseCapacity(text) {
|
|
670
|
-
const trimmed = text.trim();
|
|
671
|
-
if (trimmed.length === 0) return undefined;
|
|
672
|
-
const match = CAPACITY_PATTERN.exec(trimmed);
|
|
673
|
-
if (match === null) return NaN;
|
|
674
|
-
const suffix = match[2] === undefined ? '' : match[2].toLowerCase();
|
|
675
|
-
const scale = suffix === 'k' || suffix === 'm' ? CAPACITY_SCALE[suffix] : 1;
|
|
676
|
-
const scaled = Number(match[1]) * scale;
|
|
677
|
-
const rounded = Math.round(scaled);
|
|
678
|
-
// 浮点误差落在整数边上的(`1.0000001M`)吃掉;真不是整数的(`0.5`)原样返回,交给
|
|
679
|
-
// 调用方按「必须是不小于 1 的整数」拒绝。
|
|
680
|
-
return Math.abs(scaled - rounded) < 1e-6 ? rounded : scaled;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* 把存下来的 token 数写回输入框,取能原样读回来的最短写法:`1000000` 写成 `1M`、`384000`
|
|
685
|
-
* 写成 `384K`,`1048576` 不是整千就照原样写——官方 `formatCapacity` 同此,两边是一套词汇。
|
|
686
|
-
*
|
|
687
|
-
* @returns {string} 输入框文本;没有值时是空串。
|
|
688
|
-
*/
|
|
689
|
-
function formatCapacity(value) {
|
|
690
|
-
if (value === undefined) return '';
|
|
691
|
-
if (!Number.isInteger(value) || value <= 0) return String(value);
|
|
692
|
-
if (value % CAPACITY_SCALE.m === 0) return `${String(value / CAPACITY_SCALE.m)}M`;
|
|
693
|
-
if (value % CAPACITY_SCALE.k === 0) return `${String(value / CAPACITY_SCALE.k)}K`;
|
|
694
|
-
return String(value);
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
/** 事实来源 → 字典键;未知来源原样显示。 */
|
|
698
|
-
const SOURCE_KEYS = {
|
|
699
|
-
aperture: 'sourceAperture',
|
|
700
|
-
'models.dev': 'sourceModelsDev',
|
|
701
|
-
config: 'sourceConfig',
|
|
702
|
-
default: 'sourceDefault',
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
/** 一个键在不在用户层里——这就是「有没有被覆盖」的判据:写了与默认值相同的值也算覆盖。 */
|
|
706
|
-
function hasKey(layer, key) {
|
|
707
|
-
return typeof layer === 'object' && layer !== null && Object.prototype.hasOwnProperty.call(layer, key);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* 把 `{name}` 占位符换成实参。locale 服务自己做这件事,这里只是没有注入 `t` 时(测试、以及
|
|
712
|
-
* 渲染器还没绑定字典时)用同一套规则兜底——否则字典里的模板会原样漏到界面上。
|
|
713
|
-
*
|
|
714
|
-
* @returns {string} 填好的字符串。
|
|
715
|
-
*/
|
|
716
|
-
function interpolate(template, params) {
|
|
717
|
-
if (params === undefined) return template;
|
|
718
|
-
return template.replace(/\{(\w+)\}/gu, (match, name) => (
|
|
719
|
-
Object.prototype.hasOwnProperty.call(params, name) ? String(params[name]) : match
|
|
720
|
-
));
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
// ------------------------------------------------------------ 设置表单模型
|
|
724
|
-
|
|
725
|
-
/**
|
|
726
|
-
* 布尔字段的换算规格。
|
|
727
|
-
*
|
|
728
|
-
* 官方设置表单按「草稿文本」组织,规格只要求两个方向:值怎么写进文本、文本怎么变成一次写入。
|
|
729
|
-
* 开关用 `'true'` / `'false'` 当草稿,空串是「这一项不写」,值回落到组合层与 schema 默认。
|
|
730
|
-
*
|
|
731
|
-
* @returns {object} 字段规格。
|
|
732
|
-
*/
|
|
733
|
-
function booleanField(field) {
|
|
734
|
-
return {
|
|
735
|
-
field,
|
|
736
|
-
format: (value) => (value === true ? 'true' : value === false ? 'false' : ''),
|
|
737
|
-
parse: (text) => {
|
|
738
|
-
if (text === '') return { kind: 'clear' };
|
|
739
|
-
if (text === 'true') return { kind: 'set', value: true };
|
|
740
|
-
if (text === 'false') return { kind: 'set', value: false };
|
|
741
|
-
return undefined;
|
|
742
|
-
},
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* 这份设置没有服务时用的替身:`configForms` 缺席时(注入表保证不会,但这一页不该因此整页消失)
|
|
748
|
-
* 让 `SettingsFormModel` 读到 `unavailable` 快照,官方表单自己会画那句「读不到」,模型那一段
|
|
749
|
-
* 照旧。写入一律回绝——没有服务时没有任何东西能接受它。
|
|
750
|
-
*/
|
|
751
|
-
const UNSERVED = Object.freeze({
|
|
752
|
-
getSnapshot: () => ({
|
|
753
|
-
status: 'unavailable',
|
|
754
|
-
value: undefined,
|
|
755
|
-
base: undefined,
|
|
756
|
-
user: undefined,
|
|
757
|
-
writable: false,
|
|
758
|
-
revision: undefined,
|
|
759
|
-
}),
|
|
760
|
-
subscribe: () => () => {},
|
|
761
|
-
mutate: async () => false,
|
|
762
|
-
});
|
|
763
|
-
|
|
764
|
-
// ------------------------------------------------------------------ 配置页
|
|
765
|
-
|
|
766
|
-
/**
|
|
767
|
-
* 一个模型此刻在表单里长什么样。
|
|
768
|
-
*
|
|
769
|
-
* 取的都是**生效值**,输入框里显示的永远是此刻真正在用的东西;提交时逐字段与这份快照比较,
|
|
770
|
-
* 只有改动过的字段才会发出去,因此界面不编辑的 `reasoningEfforts` 之类不会被顺手抹掉。
|
|
771
|
-
*/
|
|
772
|
-
function initialOf(model) {
|
|
773
|
-
return {
|
|
774
|
-
name: model.name,
|
|
775
|
-
alias: model.alias ?? '',
|
|
776
|
-
// 容量回写成能原样读回来的最短写法(`1M`、`384K`),与官方「模型」页同一套词汇。
|
|
777
|
-
contextWindow: formatCapacity(model.contextWindow),
|
|
778
|
-
maxTokens: formatCapacity(model.maxTokens),
|
|
779
|
-
text: model.input.includes('text'),
|
|
780
|
-
image: model.input.includes('image'),
|
|
781
|
-
// 「跟随发现」= 用户层里没写过这个键。写过了,生效值就是用户写的那个值。
|
|
782
|
-
reasoning: declaredIn(model, 'thinking') ? (model.reasoning ? 'on' : 'off') : 'auto',
|
|
783
|
-
api: declaredIn(model, 'api') ? (model.protocol ?? '') : '',
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* 用户层里写没写过这个键——这就是「覆盖」的判据。
|
|
789
|
-
*
|
|
790
|
-
* 报告里的 `overrideKeys` 直接来自用户层,不必拿生效值和默认值比:比出来的答案既会漏(写了与
|
|
791
|
-
* 默认相同的值),也会多(schema 补出来的空值)。
|
|
792
|
-
*/
|
|
793
|
-
function declaredIn(model, key) {
|
|
794
|
-
return (model.overrideKeys ?? []).includes(key);
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
/** 覆盖键在界面上的名字;界面不编辑的键(`reasoningEfforts`)另给一个词条。 */
|
|
798
|
-
const OVERRIDE_NAMES = {
|
|
799
|
-
name: 'editName',
|
|
800
|
-
api: 'editApi',
|
|
801
|
-
contextWindow: 'editContextWindow',
|
|
802
|
-
maxTokens: 'editMaxTokens',
|
|
803
|
-
input: 'editInput',
|
|
804
|
-
thinking: 'editReasoning',
|
|
805
|
-
alias: 'editAlias',
|
|
806
|
-
reasoningEfforts: 'keyReasoningEfforts',
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* 配置页:实例(地址、同步开关)与模型清单。
|
|
811
|
-
*
|
|
812
|
-
* 表单状态读注入面里的 `useApertureCard`(官方 SettingsFormModel 的投影),报告、提示语与每行
|
|
813
|
-
* 草稿是局部状态——它们是这一页的视图状态,不是设置文档的一部分。报告本身(`panel.status` 那一份
|
|
814
|
-
* 结构化数据)仍然要读:每一行的事实、覆盖与状态点都长在它上面,只是不再整块摊开给用户看。
|
|
815
|
-
*
|
|
816
|
-
* **effect 的依赖里刻意不放注入面**:`inject` 面由渲染器每次渲染重新组装,把它的身份放进依赖会
|
|
817
|
-
* 让 effect 每渲染一次就重跑一次。因此报告用一个自增计数器当重读信号(依赖里只有那个数),注入
|
|
818
|
-
* 面里的函数只在事件处理里调用,拿到的永远是当轮的那份。
|
|
819
|
-
*
|
|
820
|
-
* @param {object} props - 注入面:`useApertureCard`、`panel`(报告端点)、`save` / `edit` /
|
|
821
|
-
* `resetField` / `discard` / `failed`(设置表单)与 `t`(字典,注册时声明了 `locale`)。
|
|
822
|
-
* @returns {object} 页面元素。
|
|
823
|
-
*/
|
|
824
|
-
function AperturePanel(props) {
|
|
825
|
-
const t = typeof props.t === 'function' ? props.t : (key, params) => interpolate(zh[key] ?? key, params);
|
|
826
|
-
const state = props.useApertureCard((snapshot) => snapshot);
|
|
827
|
-
|
|
828
|
-
const [report, setReport] = React.useState(null);
|
|
829
|
-
const [banner, setBanner] = React.useState(null);
|
|
830
|
-
const [busy, setBusy] = React.useState('');
|
|
831
|
-
const [drafts, setDrafts] = React.useState({});
|
|
832
|
-
const [opened, setOpened] = React.useState({});
|
|
833
|
-
const [revision, setRevision] = React.useState(0);
|
|
834
|
-
|
|
835
|
-
React.useEffect(() => {
|
|
836
|
-
let cancelled = false;
|
|
837
|
-
props.panel.status().then(
|
|
838
|
-
(next) => {
|
|
839
|
-
if (!cancelled) setReport(next);
|
|
840
|
-
},
|
|
841
|
-
(error) => {
|
|
842
|
-
if (!cancelled) setBanner({ ok: false, text: textOf(error) });
|
|
843
|
-
},
|
|
844
|
-
);
|
|
845
|
-
return () => {
|
|
846
|
-
cancelled = true;
|
|
847
|
-
};
|
|
848
|
-
}, [revision]);
|
|
849
|
-
|
|
850
|
-
/** 跑一个动作:期间禁用控件,结束后把结果贴出来并按需重读报告。 */
|
|
851
|
-
const run = (key, action, after) => {
|
|
852
|
-
setBusy(key);
|
|
853
|
-
setBanner(null);
|
|
854
|
-
void (async () => {
|
|
855
|
-
try {
|
|
856
|
-
const result = await action();
|
|
857
|
-
setBanner({ ok: result.ok, text: result.summary });
|
|
858
|
-
} catch (error) {
|
|
859
|
-
setBanner({ ok: false, text: textOf(error) });
|
|
860
|
-
} finally {
|
|
861
|
-
setBusy('');
|
|
862
|
-
if (after !== undefined) after();
|
|
863
|
-
}
|
|
864
|
-
})();
|
|
865
|
-
};
|
|
866
|
-
|
|
867
|
-
/**
|
|
868
|
-
* 保存设置里那两个字段,然后等一轮重新发现落地再说话。
|
|
869
|
-
*
|
|
870
|
-
* 写入走官方表单模型的 `save()`:它自带 `revision` 围栏(期间别处改过就拒绝,而不是覆盖别人的
|
|
871
|
-
* 改动)并从宿主接受的那份重新播种,因此写完不重读设置——投影会自己变新。报告里的模型事实
|
|
872
|
-
* 与状态点来自最近一次刷新,写完必须等一轮,否则就是「保存了却没变」。设置变更自己也会唤起同一轮
|
|
873
|
-
* 刷新(单飞判定按配置版本合并),因此这里通常并进那一轮。
|
|
874
|
-
*/
|
|
875
|
-
const saveSettings = () => run('save', async () => {
|
|
876
|
-
await props.save();
|
|
877
|
-
if (props.failed()) return { ok: false, summary: t('configRefused') };
|
|
878
|
-
const round = await props.panel.refresh();
|
|
879
|
-
// 写入成功了,但重新发现可能失败——两件事不能混成一句话说,因此后半句照抄那一轮的说法。
|
|
880
|
-
return { ok: round.ok, summary: t('savedResult', { result: round.summary }) };
|
|
881
|
-
}, () => setRevision((value) => value + 1));
|
|
882
|
-
|
|
883
|
-
/** 一个模型此刻的草稿;没改过就是生效值本身。 */
|
|
884
|
-
const draftOf = (model) => drafts[model.id] ?? initialOf(model);
|
|
885
|
-
|
|
886
|
-
/** 改这一行的几个字段;用函数式更新,同一个 tick 里连着改几项也不会互相覆盖。 */
|
|
887
|
-
const stage = (model, changes) => {
|
|
888
|
-
setDrafts((current) => ({
|
|
889
|
-
...current,
|
|
890
|
-
[model.id]: { ...(current[model.id] ?? initialOf(model)), ...changes },
|
|
891
|
-
}));
|
|
892
|
-
};
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* 改动的字段 → 补丁;没变的不进补丁,非法值只报字段名。补丁里的空值就是「这一项不覆盖」:
|
|
896
|
-
* 文本字段用空串或 `null`(别名用空串),模态用 `null`,推理用 `null` 表示回落到发现。
|
|
897
|
-
*/
|
|
898
|
-
const patchOf = (draft, initial) => {
|
|
899
|
-
const patch = {};
|
|
900
|
-
const bad = [];
|
|
901
|
-
|
|
902
|
-
// 前后空白不算改动:只把 ` 名字 ` 的空格去掉不算换过值,否则会凭空写下一笔覆盖。
|
|
903
|
-
const name = draft.name.trim();
|
|
904
|
-
if (name !== initial.name) patch.name = name === '' ? null : name;
|
|
905
|
-
|
|
906
|
-
const alias = draft.alias.trim();
|
|
907
|
-
if (alias !== initial.alias) patch.alias = alias;
|
|
908
|
-
|
|
909
|
-
for (const [field, label] of [['contextWindow', 'editContextWindow'], ['maxTokens', 'editMaxTokens']]) {
|
|
910
|
-
if (draft[field] === initial[field]) continue;
|
|
911
|
-
// 容量认 `1M`、`100K` 这种写法(官方「模型」页同一套);空串是「这一项不覆盖」。
|
|
912
|
-
const value = parseCapacity(draft[field]);
|
|
913
|
-
if (capacityBad(draft[field])) bad.push(t(label));
|
|
914
|
-
else if (value === undefined) patch[field] = null;
|
|
915
|
-
// 换一种写法写同一个数(`100k` 对 `100K`)不是改动:写下去只会多一笔没人改过的覆盖。
|
|
916
|
-
else if (value !== parseCapacity(initial[field])) patch[field] = value;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
if (draft.api !== initial.api) patch.api = draft.api === '' ? null : draft.api;
|
|
920
|
-
if (draft.reasoning !== initial.reasoning) {
|
|
921
|
-
patch.thinking = draft.reasoning === 'auto' ? null : draft.reasoning === 'on';
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
const wanted = [draft.text ? 'text' : undefined, draft.image ? 'image' : undefined].filter(Boolean);
|
|
925
|
-
const before = [initial.text ? 'text' : undefined, initial.image ? 'image' : undefined].filter(Boolean);
|
|
926
|
-
if (wanted.join('+') !== before.join('+')) patch.input = wanted.length === 0 ? null : wanted;
|
|
927
|
-
|
|
928
|
-
return { patch, bad };
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
* 容量那一项的本地判定,输入框与保存走同一条规矩:空串不是非法,是「这一项不覆盖」;其余必须
|
|
933
|
-
* 是不小于 1 的整数——面板只收这种值,放过去只会换来一次没必要的往返。`1G`、`1.5`、`0` 都在
|
|
934
|
-
* 这里被挡下。
|
|
935
|
-
*/
|
|
936
|
-
const capacityBad = (text) => {
|
|
937
|
-
const value = parseCapacity(text);
|
|
938
|
-
return value !== undefined && (!Number.isInteger(value) || value < 1);
|
|
939
|
-
};
|
|
940
|
-
|
|
941
|
-
/** 这一行有没有还没写下去的改动。 */
|
|
942
|
-
const dirtyOf = (model) => Object.keys(patchOf(draftOf(model), initialOf(model)).patch).length > 0;
|
|
943
|
-
|
|
944
|
-
/** 丢掉一行的草稿:输入框回到生效值。 */
|
|
945
|
-
const dropDraft = (id) => {
|
|
946
|
-
setDrafts((current) => {
|
|
947
|
-
const { [id]: _dropped, ...kept } = current;
|
|
948
|
-
return kept;
|
|
949
|
-
});
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
/** 展开或收起一行;收起不动草稿——收起来不等于放弃,标签会写着还有未保存的改动。 */
|
|
953
|
-
const toggleRow = (model) => setOpened((current) => ({ ...current, [model.id]: current[model.id] !== true }));
|
|
954
|
-
|
|
955
|
-
/**
|
|
956
|
-
* 写下这一行(一个模型)的改动。
|
|
957
|
-
*
|
|
958
|
-
* 一行一个保存按钮,写下去的就只有这一行,宿主那边的版本校验也只管这一次写入。成功后收起面板
|
|
959
|
-
* ——这一行的覆盖标签与事实都会跟着变,收起才看得见。
|
|
960
|
-
*
|
|
961
|
-
* @param {object} model - 报告里的一个模型。
|
|
962
|
-
*/
|
|
963
|
-
const submitRow = (model) => {
|
|
964
|
-
const { patch, bad } = patchOf(draftOf(model), initialOf(model));
|
|
965
|
-
if (bad.length > 0) {
|
|
966
|
-
setBanner({ ok: false, text: t('invalidNumber', { field: bad.join(t('listSeparator')) }) });
|
|
967
|
-
return;
|
|
968
|
-
}
|
|
969
|
-
if (Object.keys(patch).length === 0) {
|
|
970
|
-
setBanner({ ok: true, text: t('noChanges') });
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
run('edit', () => props.panel.writeModel(model.id, patch), () => {
|
|
974
|
-
dropDraft(model.id);
|
|
975
|
-
setOpened((current) => ({ ...current, [model.id]: false }));
|
|
976
|
-
setRevision((value) => value + 1);
|
|
977
|
-
});
|
|
978
|
-
};
|
|
979
|
-
|
|
980
|
-
/** 取消这一行的编辑:草稿丢掉、面板收起,什么都不写。 */
|
|
981
|
-
const cancelRow = (model) => {
|
|
982
|
-
dropDraft(model.id);
|
|
983
|
-
setOpened((current) => ({ ...current, [model.id]: false }));
|
|
984
|
-
setBanner(null);
|
|
985
|
-
};
|
|
986
|
-
|
|
987
|
-
/**
|
|
988
|
-
* 撤销这一行的覆盖:只把**报告里写着确实被覆盖过**的字段清掉。
|
|
989
|
-
*
|
|
990
|
-
* 不是整条删掉:`aperture.models` 里那条可能还有界面根本不编辑的键(例如 `reasoningEfforts`),
|
|
991
|
-
* 整条删掉等于把用户手写的东西一起扔掉,因此只把已知被覆盖的字段逐个置空。万一报告里出现了
|
|
992
|
-
* 界面不认识的键(宿主以后加了字段),整条删掉是唯一能让这一行真的回落到发现值的做法。
|
|
993
|
-
*
|
|
994
|
-
* @param {object} model - 报告里的一个模型。
|
|
995
|
-
*/
|
|
996
|
-
const clearOverrides = (model) => {
|
|
997
|
-
const keys = model.overrideKeys ?? [];
|
|
998
|
-
const known = keys.filter((key) => EDITABLE_KEYS.includes(key));
|
|
999
|
-
const unknown = keys.filter((key) => !EDITABLE_KEYS.includes(key));
|
|
1000
|
-
// 别名用空串表示「不要再覆盖」;其余字段 `null` 就是「不覆盖这一项」。
|
|
1001
|
-
const patch = Object.fromEntries(known.map((key) => [key, key === 'alias' ? '' : null]));
|
|
1002
|
-
const payload = unknown.length > 0 || known.length === 0 ? null : patch;
|
|
1003
|
-
run('revert', () => props.panel.writeModel(model.id, payload), () => {
|
|
1004
|
-
dropDraft(model.id);
|
|
1005
|
-
setOpened((current) => ({ ...current, [model.id]: false }));
|
|
1006
|
-
setRevision((value) => value + 1);
|
|
1007
|
-
});
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
const refreshReport = () => run('refresh', () => props.panel.refresh(), () => setRevision((value) => value + 1));
|
|
1011
|
-
|
|
1012
|
-
/** 来源那句:报告里的事实都有出处,界面按语言渲染它。 */
|
|
1013
|
-
const sourceOf = (fact) => t('factSource', {
|
|
1014
|
-
source: SOURCE_KEYS[fact] === undefined ? fact : t(SOURCE_KEYS[fact]),
|
|
1015
|
-
});
|
|
1016
|
-
|
|
1017
|
-
/** 最近一轮写入过的路由名;`undefined` 是「这一轮没同步」,不是「没写」——同步关着的时候报告里
|
|
1018
|
-
* 根本没有这一项,界面不能把「不知道」说成「没写」。
|
|
1019
|
-
*/
|
|
1020
|
-
const writtenRoutes = report === null || report.refresh === undefined || report.refresh.sync === undefined
|
|
1021
|
-
? undefined
|
|
1022
|
-
: report.refresh.sync.routes;
|
|
1023
|
-
|
|
1024
|
-
/** 一行模型那几项生效的事实,一项一句;缺哪项就不提哪项。 */
|
|
1025
|
-
const factItems = (model) => {
|
|
1026
|
-
const facts = [];
|
|
1027
|
-
if (model.route !== undefined) facts.push(t('factRoute', { route: model.route }));
|
|
1028
|
-
if (model.protocol !== undefined) facts.push(t('factProtocol', { protocol: model.protocol }));
|
|
1029
|
-
if (model.contextWindow !== undefined) {
|
|
1030
|
-
facts.push(t('factContextWindow', { count: formatCount(model.contextWindow) }));
|
|
1031
|
-
}
|
|
1032
|
-
if (model.maxTokens !== undefined) facts.push(t('factMaxTokens', { count: formatCount(model.maxTokens) }));
|
|
1033
|
-
facts.push(t('factInput', {
|
|
1034
|
-
value: model.input.length === 0
|
|
1035
|
-
? t('modalityNone')
|
|
1036
|
-
: model.input.map((item) => t(item === 'image' ? 'modalityImage' : 'modalityText')).join('+'),
|
|
1037
|
-
}));
|
|
1038
|
-
facts.push(t('factReasoning', { value: model.reasoning ? t('reasoningOn') : t('reasoningOff') }));
|
|
1039
|
-
if (model.alias !== undefined && model.alias !== '') facts.push(t('factAlias', { alias: model.alias }));
|
|
1040
|
-
return facts;
|
|
1041
|
-
};
|
|
1042
|
-
|
|
1043
|
-
/**
|
|
1044
|
-
* 这一行的状态点:绿是写进去了、灰是没写进去、黄是根本没有路由能服务它。
|
|
1045
|
-
*
|
|
1046
|
-
* 点旁边那句 `title` 就是它的说法——官方 `StateDot` 自己是 `aria-hidden`,说给谁听得由这里给。
|
|
1047
|
-
*/
|
|
1048
|
-
const publishState = (model) => {
|
|
1049
|
-
if (model.route === undefined) return { state: 'warning', title: t('statusUnserved') };
|
|
1050
|
-
if (writtenRoutes === undefined) return { state: 'idle', title: t('statusUnknown') };
|
|
1051
|
-
return writtenRoutes.includes(model.route)
|
|
1052
|
-
? { state: 'done', title: t('statusPublished') }
|
|
1053
|
-
: { state: 'idle', title: t('statusNotPublished') };
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
/** 把覆盖键翻成给人看的一句话:界面认得的键都有字段,认不得的只有这里说得出名字。 */
|
|
1057
|
-
const overrideKeyNames = (keys) => keys
|
|
1058
|
-
.map((key) => (OVERRIDE_NAMES[key] === undefined ? key : t(OVERRIDE_NAMES[key])))
|
|
1059
|
-
.join(t('listSeparator'));
|
|
1060
|
-
|
|
1061
|
-
/**
|
|
1062
|
-
* 一个文本类覆盖字段。
|
|
1063
|
-
*
|
|
1064
|
-
* 官方 `SettingsValueField` 的语义正好对得上:「已覆盖」= 用户层里有这个键(报告给的
|
|
1065
|
-
* `overrideKeys`),「恢复默认」= 把草稿改回「不覆盖」,非法草稿只标出来、由保存拦住。
|
|
1066
|
-
*
|
|
1067
|
-
* 长解释进 `help`(官方那个「i」按钮),输入框下面只留一句来源;外面再套一层格子,官方字段行
|
|
1068
|
-
* 那条「相邻就加上边框」在网格里会错开半格,隔开一层壳就不碰它了。
|
|
1069
|
-
*/
|
|
1070
|
-
const textField = (model, key, copy) => h(
|
|
1071
|
-
'div',
|
|
1072
|
-
{ className: 'dap-fieldCell' },
|
|
1073
|
-
h(SettingsValueField, {
|
|
1074
|
-
id: `dap-${model.id}-${key}`,
|
|
1075
|
-
label: t(copy.label),
|
|
1076
|
-
help: { label: t('fieldHelp', { field: t(copy.label) }), content: t(copy.hint) },
|
|
1077
|
-
hint: sourceOf(copy.source(model)),
|
|
1078
|
-
...(copy.placeholder === undefined ? {} : { placeholder: copy.placeholder(model) }),
|
|
1079
|
-
...(copy.numeric === true ? { numeric: true } : {}),
|
|
1080
|
-
text: draftOf(model)[key],
|
|
1081
|
-
overridden: declaredIn(model, key),
|
|
1082
|
-
// 只有容量那两项用 `1M`/`384K` 的词汇,因此也只有它们会「读不出来」;文本字段写什么都算数。
|
|
1083
|
-
invalid: copy.numeric === true && capacityBad(draftOf(model)[key]),
|
|
1084
|
-
overriddenLabel: t('overridden'),
|
|
1085
|
-
resetLabel: t('resetField'),
|
|
1086
|
-
invalidLabel: t('invalidField'),
|
|
1087
|
-
disabled: busy !== '',
|
|
1088
|
-
onEdit: (text) => stage(model, { [key]: text }),
|
|
1089
|
-
onReset: () => stage(model, { [key]: copy.cleared }),
|
|
1090
|
-
}),
|
|
1091
|
-
);
|
|
1092
|
-
|
|
1093
|
-
/** 一行模型的覆盖编辑器:只写这一行。 */
|
|
1094
|
-
const editor = (model) => {
|
|
1095
|
-
const draft = draftOf(model);
|
|
1096
|
-
const overrides = model.overrideKeys ?? [];
|
|
1097
|
-
const changed = Object.keys(patchOf(draft, initialOf(model)).patch).length;
|
|
1098
|
-
// 界面认不得的键(`reasoningEfforts` 之类)只有「清空覆盖」撤得掉,而那是整条删,得先说清楚。
|
|
1099
|
-
const unknown = overrides.filter((key) => !EDITABLE_KEYS.includes(key));
|
|
1100
|
-
return h(
|
|
1101
|
-
'div',
|
|
1102
|
-
{ className: 'dap-editor' },
|
|
1103
|
-
h(
|
|
1104
|
-
'div',
|
|
1105
|
-
{ className: 'dap-editorHead' },
|
|
1106
|
-
h('span', { className: 'dap-editorId', title: model.id }, model.id),
|
|
1107
|
-
unknown.length === 0
|
|
1108
|
-
? null
|
|
1109
|
-
: h(
|
|
1110
|
-
'span',
|
|
1111
|
-
{ className: 'dap-warnNote' },
|
|
1112
|
-
t('editUnknownOverrides', { keys: overrideKeyNames(unknown) }),
|
|
1113
|
-
),
|
|
1114
|
-
dirtyOf(model)
|
|
1115
|
-
? h(Tag, { tone: 'warning', className: 'dap-editorDirty' }, t('dirtyTag'))
|
|
1116
|
-
: null,
|
|
1117
|
-
),
|
|
1118
|
-
h(
|
|
1119
|
-
'div',
|
|
1120
|
-
{ className: 'dap-editGroup' },
|
|
1121
|
-
h('span', { className: 'dap-editGroupTitle' }, t('editGroupIdentity')),
|
|
1122
|
-
h(
|
|
1123
|
-
'div',
|
|
1124
|
-
{ className: 'dap-fields' },
|
|
1125
|
-
textField(model, 'name', {
|
|
1126
|
-
label: 'editName',
|
|
1127
|
-
hint: 'editNameHint',
|
|
1128
|
-
source: (item) => item.provenance.name,
|
|
1129
|
-
cleared: '',
|
|
1130
|
-
}),
|
|
1131
|
-
textField(model, 'alias', {
|
|
1132
|
-
label: 'editAlias',
|
|
1133
|
-
hint: 'editAliasHint',
|
|
1134
|
-
source: () => 'config',
|
|
1135
|
-
cleared: '',
|
|
1136
|
-
}),
|
|
1137
|
-
textField(model, 'api', {
|
|
1138
|
-
label: 'editApi',
|
|
1139
|
-
hint: 'editApiHint',
|
|
1140
|
-
// 协议没有单独一项来源:写过就是配置,没写过就是从通告的端点推导出来的。
|
|
1141
|
-
source: (item) => (declaredIn(item, 'api') ? 'config' : 'aperture'),
|
|
1142
|
-
cleared: '',
|
|
1143
|
-
placeholder: (item) => item.protocol ?? '',
|
|
1144
|
-
}),
|
|
1145
|
-
),
|
|
1146
|
-
),
|
|
1147
|
-
h(
|
|
1148
|
-
'div',
|
|
1149
|
-
{ className: 'dap-editGroup' },
|
|
1150
|
-
h('span', { className: 'dap-editGroupTitle' }, t('editGroupCapacity')),
|
|
1151
|
-
h(
|
|
1152
|
-
'div',
|
|
1153
|
-
{ className: 'dap-fields' },
|
|
1154
|
-
textField(model, 'contextWindow', {
|
|
1155
|
-
label: 'editContextWindow',
|
|
1156
|
-
hint: 'editCapacityHint',
|
|
1157
|
-
source: (item) => item.provenance.limits,
|
|
1158
|
-
cleared: '',
|
|
1159
|
-
numeric: true,
|
|
1160
|
-
// 清空之后回落到的就是发现到的那个数,摆在占位符里最省事。
|
|
1161
|
-
placeholder: (item) => formatCapacity(item.contextWindow),
|
|
1162
|
-
}),
|
|
1163
|
-
textField(model, 'maxTokens', {
|
|
1164
|
-
label: 'editMaxTokens',
|
|
1165
|
-
hint: 'editCapacityHint',
|
|
1166
|
-
source: (item) => item.provenance.limits,
|
|
1167
|
-
cleared: '',
|
|
1168
|
-
numeric: true,
|
|
1169
|
-
placeholder: (item) => formatCapacity(item.maxTokens),
|
|
1170
|
-
}),
|
|
1171
|
-
),
|
|
1172
|
-
),
|
|
1173
|
-
// 模态与推理并排:它们都是「一个开关加一句话」,横着放比竖着叠省一半高度。
|
|
1174
|
-
h(
|
|
1175
|
-
'div',
|
|
1176
|
-
{ className: 'dap-grid2' },
|
|
1177
|
-
h(
|
|
1178
|
-
'div',
|
|
1179
|
-
{ className: 'dap-editGroup' },
|
|
1180
|
-
h('span', { className: 'dap-editGroupTitle' }, t('editInput')),
|
|
1181
|
-
h(
|
|
1182
|
-
'div',
|
|
1183
|
-
{ className: 'dap-control' },
|
|
1184
|
-
h(Checkbox, {
|
|
1185
|
-
checked: draft.text,
|
|
1186
|
-
onChange: (next) => stage(model, { text: next }),
|
|
1187
|
-
label: t('modalityText'),
|
|
1188
|
-
disabled: busy !== '',
|
|
1189
|
-
}),
|
|
1190
|
-
h(Checkbox, {
|
|
1191
|
-
checked: draft.image,
|
|
1192
|
-
onChange: (next) => stage(model, { image: next }),
|
|
1193
|
-
label: t('modalityImage'),
|
|
1194
|
-
disabled: busy !== '',
|
|
1195
|
-
}),
|
|
1196
|
-
overrides.includes('input') ? h(Tag, { tone: 'neutral' }, t('overridden')) : null,
|
|
1197
|
-
),
|
|
1198
|
-
h('span', { className: 'dap-hint' }, sourceOf(model.provenance.input)),
|
|
1199
|
-
),
|
|
1200
|
-
h(
|
|
1201
|
-
'div',
|
|
1202
|
-
{ className: 'dap-editGroup' },
|
|
1203
|
-
h('span', { className: 'dap-editGroupTitle' }, t('editReasoning')),
|
|
1204
|
-
h(SegmentedControl, {
|
|
1205
|
-
id: `dap-${model.id}-reasoning`,
|
|
1206
|
-
label: t('editReasoning'),
|
|
1207
|
-
value: draft.reasoning,
|
|
1208
|
-
options: [
|
|
1209
|
-
{ value: 'auto', label: t('reasoningFollow') },
|
|
1210
|
-
{ value: 'on', label: t('reasoningOn') },
|
|
1211
|
-
{ value: 'off', label: t('reasoningOff') },
|
|
1212
|
-
],
|
|
1213
|
-
onChange: (next) => stage(model, { reasoning: next }),
|
|
1214
|
-
disabled: busy !== '',
|
|
1215
|
-
}),
|
|
1216
|
-
h('span', { className: 'dap-hint' }, sourceOf(model.provenance.reasoning)),
|
|
1217
|
-
),
|
|
1218
|
-
),
|
|
1219
|
-
model.endpoints.length === 0
|
|
1220
|
-
? null
|
|
1221
|
-
: h(
|
|
1222
|
-
'div',
|
|
1223
|
-
{ className: 'dap-endpoints' },
|
|
1224
|
-
h('span', { className: 'dap-editGroupTitle' }, t('factEndpoints')),
|
|
1225
|
-
h(
|
|
1226
|
-
'ul',
|
|
1227
|
-
{ className: 'dap-endpointList' },
|
|
1228
|
-
model.endpoints.map((endpoint) => h(
|
|
1229
|
-
'li',
|
|
1230
|
-
{ className: 'dap-endpoint', key: endpoint },
|
|
1231
|
-
endpoint,
|
|
1232
|
-
)),
|
|
1233
|
-
),
|
|
1234
|
-
),
|
|
1235
|
-
h(
|
|
1236
|
-
'div',
|
|
1237
|
-
{ className: 'dap-actions' },
|
|
1238
|
-
h('span', { className: 'dap-actionsNote' }, changed === 0
|
|
1239
|
-
? t('noPendingChanges')
|
|
1240
|
-
: t('pendingChanges', { count: changed })),
|
|
1241
|
-
h(Button, {
|
|
1242
|
-
variant: 'ghost',
|
|
1243
|
-
size: 'sm',
|
|
1244
|
-
onClick: () => cancelRow(model),
|
|
1245
|
-
disabled: busy !== '',
|
|
1246
|
-
}, t('cancelRow')),
|
|
1247
|
-
overrides.length === 0
|
|
1248
|
-
? null
|
|
1249
|
-
: h(Button, {
|
|
1250
|
-
variant: 'outline',
|
|
1251
|
-
size: 'sm',
|
|
1252
|
-
onClick: () => clearOverrides(model),
|
|
1253
|
-
disabled: busy !== '',
|
|
1254
|
-
}, t('clearOverrides')),
|
|
1255
|
-
h(Button, {
|
|
1256
|
-
variant: 'primary',
|
|
1257
|
-
size: 'sm',
|
|
1258
|
-
onClick: () => submitRow(model),
|
|
1259
|
-
disabled: busy !== '',
|
|
1260
|
-
}, busy === 'edit' ? t('saving') : t('saveRow')),
|
|
1261
|
-
),
|
|
1262
|
-
);
|
|
1263
|
-
};
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
* 一行模型:折起来是身份与状态,展开是这一行的覆盖编辑器。
|
|
1267
|
-
*
|
|
1268
|
-
* 行首那条按钮盖满整行(官方 `DisclosureRow` 是一根 24px 高、`overflow:hidden` 的横条,标题又
|
|
1269
|
-
* 不许收缩,名字一长就把右边的事实和标签挤没了)。这里名字自己一行、过长省略,事实另起一行随
|
|
1270
|
-
* 宽度换行,标签跟在名字后面。
|
|
1271
|
-
*/
|
|
1272
|
-
const modelRow = (model) => {
|
|
1273
|
-
const open = opened[model.id] === true;
|
|
1274
|
-
const overrides = model.overrideKeys ?? [];
|
|
1275
|
-
const status = publishState(model);
|
|
1276
|
-
return h(
|
|
1277
|
-
'li',
|
|
1278
|
-
{ key: model.id, className: 'dap-card' },
|
|
1279
|
-
h(
|
|
1280
|
-
'button',
|
|
1281
|
-
{
|
|
1282
|
-
type: 'button',
|
|
1283
|
-
className: 'dap-cardHead',
|
|
1284
|
-
'aria-expanded': open ? 'true' : 'false',
|
|
1285
|
-
onClick: () => toggleRow(model),
|
|
1286
|
-
},
|
|
1287
|
-
h(
|
|
1288
|
-
'span',
|
|
1289
|
-
{ className: 'dap-status', role: 'img', 'aria-label': status.title, title: status.title },
|
|
1290
|
-
h(StateDot, { state: status.state, size: 10 }),
|
|
1291
|
-
),
|
|
1292
|
-
h(
|
|
1293
|
-
'span',
|
|
1294
|
-
{ className: 'dap-identity' },
|
|
1295
|
-
h(
|
|
1296
|
-
'span',
|
|
1297
|
-
{ className: 'dap-identityTop' },
|
|
1298
|
-
h('span', { className: 'dap-name', title: model.name }, model.name),
|
|
1299
|
-
model.route === undefined ? h(Tag, { tone: 'warning' }, t('unservedTag')) : null,
|
|
1300
|
-
overrides.length === 0
|
|
1301
|
-
? null
|
|
1302
|
-
: h(
|
|
1303
|
-
// 这一层只为挂 `title`:官方 `Tag` 除了 tone/className/children 什么都不透传,
|
|
1304
|
-
// 想让人 hover 看出「覆盖的是哪几项」就得自己在外面套一层。
|
|
1305
|
-
'span',
|
|
1306
|
-
{ className: 'dap-tagWrap', title: overrideKeyNames(overrides) },
|
|
1307
|
-
h(Tag, { tone: 'neutral' }, t('overriddenCount', { count: overrides.length })),
|
|
1308
|
-
),
|
|
1309
|
-
dirtyOf(model) ? h(Tag, { tone: 'warning' }, t('dirtyTag')) : null,
|
|
1310
|
-
),
|
|
1311
|
-
h(
|
|
1312
|
-
'span',
|
|
1313
|
-
{ className: 'dap-factRow' },
|
|
1314
|
-
factItems(model).map((item, index) => h(
|
|
1315
|
-
'span',
|
|
1316
|
-
{ className: 'dap-factItem', key: `${model.id}-fact-${String(index)}` },
|
|
1317
|
-
item,
|
|
1318
|
-
)),
|
|
1319
|
-
),
|
|
1320
|
-
),
|
|
1321
|
-
h(
|
|
1322
|
-
'span',
|
|
1323
|
-
{ className: 'dap-chevron', 'data-open': open ? 'true' : 'false' },
|
|
1324
|
-
h(IconChevronRightOutlineRegular, { size: 14 }),
|
|
1325
|
-
),
|
|
1326
|
-
),
|
|
1327
|
-
open ? editor(model) : null,
|
|
1328
|
-
);
|
|
1329
|
-
};
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* 这一轮哪里不对:清单读不到、或者该写的东西没写进去。
|
|
1333
|
-
*
|
|
1334
|
-
* 「发现报告」那一块删掉之后,这些原本只写在报告事实表里的话得有地方落脚——否则清单挂了的时候,
|
|
1335
|
-
* 用户看到的就只是「还没有发现任何模型」,没有任何理由。刷新整个失败(`ok: false`)不在这里说:
|
|
1336
|
-
* 那句话由 `run()` 贴到提示语上,比这里更显眼。正常的一轮(同步关着 / 同步成功)什么都不说。
|
|
1337
|
-
*/
|
|
1338
|
-
const roundProblem = (current) => {
|
|
1339
|
-
const refresh = current === null ? undefined : current.refresh;
|
|
1340
|
-
if (refresh === undefined) return null;
|
|
1341
|
-
if (!refresh.catalog.available) {
|
|
1342
|
-
return t('catalogUnavailable', { reason: refresh.catalog.reason ?? '—' });
|
|
1343
|
-
}
|
|
1344
|
-
if (refresh.sync !== undefined && !refresh.sync.applied) {
|
|
1345
|
-
return t('syncSkipped', { reason: refresh.sync.reason ?? '—' });
|
|
1346
|
-
}
|
|
1347
|
-
return null;
|
|
1348
|
-
};
|
|
1349
|
-
|
|
1350
|
-
const controlsDisabled = !state.available || !state.writable;
|
|
1351
|
-
const problem = roundProblem(report);
|
|
1352
|
-
|
|
1353
|
-
return h(
|
|
1354
|
-
'div',
|
|
1355
|
-
{ 'data-dsh-aperture': '' },
|
|
1356
|
-
h(
|
|
1357
|
-
SettingsForm,
|
|
1358
|
-
{
|
|
1359
|
-
labels: {
|
|
1360
|
-
unavailable: t('unavailable'),
|
|
1361
|
-
readOnly: t('readOnly'),
|
|
1362
|
-
saveFailed: t('saveFailed'),
|
|
1363
|
-
save: t('save'),
|
|
1364
|
-
saving: t('saving'),
|
|
1365
|
-
},
|
|
1366
|
-
state,
|
|
1367
|
-
onSave: saveSettings,
|
|
1368
|
-
onDiscard: props.discard,
|
|
1369
|
-
},
|
|
1370
|
-
h(SettingsValueField, {
|
|
1371
|
-
id: 'dap-base-url',
|
|
1372
|
-
label: t('addressLabel'),
|
|
1373
|
-
hint: t('addressHint'),
|
|
1374
|
-
placeholder: t('addressPlaceholder'),
|
|
1375
|
-
text: state.baseUrl.text,
|
|
1376
|
-
overridden: state.baseUrl.overridden,
|
|
1377
|
-
invalid: state.baseUrl.invalid,
|
|
1378
|
-
overriddenLabel: t('overridden'),
|
|
1379
|
-
resetLabel: t('resetField'),
|
|
1380
|
-
invalidLabel: t('invalidField'),
|
|
1381
|
-
disabled: controlsDisabled || state.saving,
|
|
1382
|
-
onEdit: (text) => props.edit('baseUrl', text),
|
|
1383
|
-
onReset: () => props.resetField('baseUrl'),
|
|
1384
|
-
}),
|
|
1385
|
-
h(
|
|
1386
|
-
'div',
|
|
1387
|
-
{ className: 'dap-toggleRow' },
|
|
1388
|
-
h(
|
|
1389
|
-
'div',
|
|
1390
|
-
{ className: 'dap-toggleText' },
|
|
1391
|
-
h('span', null, t('syncLabel')),
|
|
1392
|
-
h('span', { className: 'dap-hint' }, t('syncHint')),
|
|
1393
|
-
),
|
|
1394
|
-
h(
|
|
1395
|
-
'div',
|
|
1396
|
-
{ className: 'dap-inline' },
|
|
1397
|
-
state.sync.overridden
|
|
1398
|
-
? h(Tag, { tone: 'info' }, t('overridden'))
|
|
1399
|
-
: null,
|
|
1400
|
-
state.sync.overridden
|
|
1401
|
-
? h(Button, {
|
|
1402
|
-
variant: 'ghost',
|
|
1403
|
-
size: 'sm',
|
|
1404
|
-
onClick: () => props.resetField('sync'),
|
|
1405
|
-
disabled: controlsDisabled || state.saving,
|
|
1406
|
-
}, t('resetField'))
|
|
1407
|
-
: null,
|
|
1408
|
-
h(Switch, {
|
|
1409
|
-
checked: state.sync.text === 'true',
|
|
1410
|
-
onChange: (next) => props.edit('sync', next ? 'true' : 'false'),
|
|
1411
|
-
label: t('syncLabel'),
|
|
1412
|
-
disabled: controlsDisabled || state.saving,
|
|
1413
|
-
}),
|
|
1414
|
-
),
|
|
1415
|
-
),
|
|
1416
|
-
),
|
|
1417
|
-
banner === null
|
|
1418
|
-
? null
|
|
1419
|
-
: h('p', {
|
|
1420
|
-
className: 'dap-banner',
|
|
1421
|
-
'data-ok': banner.ok ? 'true' : 'false',
|
|
1422
|
-
role: 'status',
|
|
1423
|
-
'aria-live': 'polite',
|
|
1424
|
-
}, banner.text),
|
|
1425
|
-
h(
|
|
1426
|
-
'section',
|
|
1427
|
-
{ className: 'dap-group' },
|
|
1428
|
-
h(
|
|
1429
|
-
'div',
|
|
1430
|
-
{ className: 'dap-groupHead' },
|
|
1431
|
-
h(
|
|
1432
|
-
'span',
|
|
1433
|
-
{ className: 'dap-titleWrap' },
|
|
1434
|
-
h('h3', { className: 'dap-groupTitle' }, t('modelsTitle')),
|
|
1435
|
-
report === null
|
|
1436
|
-
? null
|
|
1437
|
-
: h('span', { className: 'dap-count' }, t('modelsCount', { count: report.models.length })),
|
|
1438
|
-
),
|
|
1439
|
-
h(Button, {
|
|
1440
|
-
variant: 'ghost',
|
|
1441
|
-
size: 'sm',
|
|
1442
|
-
icon: h(IconRefreshOutlineRegular, { size: 14 }),
|
|
1443
|
-
onClick: refreshReport,
|
|
1444
|
-
disabled: busy !== '',
|
|
1445
|
-
title: t('refreshHint'),
|
|
1446
|
-
}, busy === 'refresh' ? t('refreshing') : t('refresh')),
|
|
1447
|
-
),
|
|
1448
|
-
h('p', { className: 'dap-hint' }, t('modelsHint')),
|
|
1449
|
-
problem === null ? null : h('p', { className: 'dap-warnNote' }, problem),
|
|
1450
|
-
report === null
|
|
1451
|
-
? h('p', { className: 'dap-hint' }, t('loading'))
|
|
1452
|
-
: report.models.length === 0
|
|
1453
|
-
// 没有实例地址时发现根本不会跑,这时说「还没发现到模型」等于没说——那句话要说清为什么。
|
|
1454
|
-
// 只在设置读得到的时候这么说:读不到时地址存不存在都不知道,那是另一件事(表单自己会说)。
|
|
1455
|
-
? h(
|
|
1456
|
-
'p',
|
|
1457
|
-
{ className: 'dap-empty' },
|
|
1458
|
-
state.available && state.baseUrl.text === '' ? t('dormantHint') : t('noModels'),
|
|
1459
|
-
)
|
|
1460
|
-
: h('ul', { className: 'dap-rows' }, report.models.map(modelRow)),
|
|
1461
|
-
),
|
|
1462
|
-
);
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
// ---------------------------------------------------------------- 插件本体
|
|
1466
|
-
|
|
1467
|
-
/**
|
|
1468
|
-
* 把 `aperturePanel` 贡献挂到客户端的 Remote 服务上。
|
|
1469
|
-
*
|
|
1470
|
-
* `apply` 必须保持同步:宿主 Cordis 会卸载 async apply 里 `await` 之后注册的 `ctx.effect`。
|
|
1471
|
-
* 因此异步的 `$mount` 在一个**同步注册**的 effect 工厂内部完成,失败落 console.error。
|
|
1472
|
-
*
|
|
1473
|
-
* @param {object} ctx - 客户端根上下文。
|
|
1474
|
-
*/
|
|
1475
|
-
function mountRemote(ctx) {
|
|
1476
|
-
ctx.effect(() => {
|
|
1477
|
-
let mounted = null;
|
|
1478
|
-
let pending = true;
|
|
1479
|
-
let unloaded = false;
|
|
1480
|
-
void (async () => {
|
|
1481
|
-
try {
|
|
1482
|
-
mounted = await ctx.remote.$mount(REMOTE);
|
|
1483
|
-
} catch (error) {
|
|
1484
|
-
console.error('dsh-aperture: aperturePanel 贡献挂载失败', error);
|
|
1485
|
-
}
|
|
1486
|
-
pending = false;
|
|
1487
|
-
if (unloaded) void mounted?.();
|
|
1488
|
-
})();
|
|
1489
|
-
return () => {
|
|
1490
|
-
unloaded = true;
|
|
1491
|
-
if (!pending) void mounted?.();
|
|
1492
|
-
};
|
|
1493
|
-
}, 'dsh-aperture: remote contribution');
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
/**
|
|
1497
|
-
* 浏览器插件主体:字典、样式、Remote 贡献,以及「插件」页里本插件那个包页的配置页。
|
|
1498
|
-
*
|
|
1499
|
-
* `ctx.slots.inject` 是必需的,不是可选的:`plugins.bundle.config` 由插件管理页自己声明,那个
|
|
1500
|
-
* 声明完全可能在本插件 `apply` 之后才发生,直接 register 会撞上「槽位尚未声明」。
|
|
1501
|
-
*
|
|
1502
|
-
* 注册的键是**包名**:键控槽位按它找贡献,点开插件列表里的本插件就是这一页。设置那一份表单也
|
|
1503
|
-
* 在这里取——页主只递 `view`,`configForms.get(命名空间)` 才是这一页的配置读写面;服务按命名
|
|
1504
|
-
* 空间缓存控制器,因此它与插件页自己取到的是同一份。
|
|
1505
|
-
*
|
|
1506
|
-
* @param {object} ctx - 客户端根上下文。
|
|
1507
|
-
*/
|
|
1508
|
-
function apply(ctx) {
|
|
1509
|
-
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-aperture: dictionaries');
|
|
1510
|
-
ctx.effect(() => installStyles(), 'dsh-aperture: stylesheet');
|
|
1511
|
-
mountRemote(ctx);
|
|
1512
|
-
|
|
1513
|
-
ctx.inject(['remote.aperturePanel'], (scope) => {
|
|
1514
|
-
const t = scope.locale.bind(NS);
|
|
1515
|
-
const namespace = () => scope.remote.aperturePanel;
|
|
1516
|
-
const panel = {
|
|
1517
|
-
status: async () => unwrap(await namespace().status()),
|
|
1518
|
-
refresh: async () => unwrap(await namespace().refresh()),
|
|
1519
|
-
writeModel: async (id, patch) => unwrap(await namespace().edit(id, patch)),
|
|
1520
|
-
};
|
|
1521
|
-
|
|
1522
|
-
// 官方设置表单那一套:这一份模型负责草稿、`revision` 围栏与「哪些字段已覆盖」,页面只读
|
|
1523
|
-
// 它的投影。表单自己订阅控制器,因此设置一变,投影就会变新。
|
|
1524
|
-
const controller = ctx.configForms === undefined ? UNSERVED : ctx.configForms.get(SETTINGS_NS);
|
|
1525
|
-
const form = new SettingsFormModel(controller, [settingsTextField('baseUrl'), booleanField('sync')]);
|
|
1526
|
-
const actions = form.actions();
|
|
1527
|
-
const card = form.bind(() => ({
|
|
1528
|
-
...form.shell(),
|
|
1529
|
-
baseUrl: form.field('baseUrl'),
|
|
1530
|
-
sync: form.field('sync'),
|
|
1531
|
-
}));
|
|
1532
|
-
scope.effect(() => () => form.dispose(), 'dsh-aperture: settings form');
|
|
1533
|
-
|
|
1534
|
-
scope.slots.inject('plugins.bundle.config', () => scope.slots.register({
|
|
1535
|
-
name: 'plugins.bundle.config',
|
|
1536
|
-
key: PACKAGE,
|
|
1537
|
-
locale: NS,
|
|
1538
|
-
inject: () => ({
|
|
1539
|
-
hooks: { apertureCard: card },
|
|
1540
|
-
panel,
|
|
1541
|
-
edit: actions.edit,
|
|
1542
|
-
resetField: actions.resetField,
|
|
1543
|
-
discard: actions.discard,
|
|
1544
|
-
save: () => form.save(),
|
|
1545
|
-
failed: () => form.shell().failed,
|
|
1546
|
-
}),
|
|
1547
|
-
}, AperturePanel));
|
|
1548
|
-
});
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
const module = { exports: {} };
|
|
1552
|
-
module.exports.name = PACKAGE;
|
|
1553
|
-
/** 本插件依赖的客户端服务:槽位、字典、Remote 调用面,以及设置接缝的配置表单。 */
|
|
1554
|
-
module.exports.inject = ['slots', 'locale', 'remote', 'configForms'];
|
|
1555
|
-
module.exports.apply = apply;
|
|
1556
|
-
/** 字典命名空间(测试与排查用)。 */
|
|
1557
|
-
module.exports.NS = NS;
|
|
1558
|
-
/** 设置命名空间,也是包级配置页这一份表单的键(测试与排查用)。 */
|
|
1559
|
-
module.exports.SETTINGS_NS = SETTINGS_NS;
|
|
1560
|
-
/** 这一页自己编辑的字段(测试与排查用)。 */
|
|
1561
|
-
module.exports.FIELDS = FIELDS;
|
|
1562
|
-
/** 上报给 Remote 注册表的贡献(测试与排查用)。 */
|
|
1563
|
-
module.exports.REMOTE = REMOTE;
|
|
1564
|
-
return module.exports;
|
|
1565
|
-
},
|
|
1566
|
-
});
|