dsh-sendcomfy 0.0.0-stage → 0.5.1
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/CONTRACT.md +586 -0
- package/FEATURES.zh.md +244 -0
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/bin/sendcomfy.mjs +74 -0
- package/client.js +2851 -0
- package/cordis.patch.yml +6 -0
- package/icon.svg +22 -0
- package/index.js +449 -0
- package/lib/actions.mjs +1193 -0
- package/lib/capabilities.mjs +476 -0
- package/lib/comfy.mjs +968 -0
- package/lib/http.mjs +302 -0
- package/lib/state.mjs +384 -0
- package/lib/workflow.mjs +1572 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +66 -4
package/client.js
ADDED
|
@@ -0,0 +1,2851 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-sendcomfy —— 浏览器半端(侧边栏图标 + 主栏 ComfyUI 面板)
|
|
3
|
+
* ============================================================================
|
|
4
|
+
* 自注册脚本(不是 ESM):window.__ModuleLoader__.load({ id, factory(require) }),只 require('react')。
|
|
5
|
+
* 注册两个入口(id/key 都是 'dsh-sendcomfy'):
|
|
6
|
+
* - slots.inject('sidebar.panellist') —— 侧栏内联 SVG 图标(props: size / active)
|
|
7
|
+
* - slots.inject('main') —— 主栏面板(root scope,无 Session 也能打开)
|
|
8
|
+
* 所有数据走同源 /api/sendcomfy/*(CONTRACT §6),不直连 ComfyUI、不碰其他插件 DOM。
|
|
9
|
+
* 文案全部走 ctx.locale(zh 默认 / en),缺 locale 服务时降级到内置 zh 字典。
|
|
10
|
+
*/
|
|
11
|
+
window.__ModuleLoader__.load({
|
|
12
|
+
id: 'dsh-sendcomfy',
|
|
13
|
+
factory(require) {
|
|
14
|
+
const React = require('react')
|
|
15
|
+
const h = React.createElement
|
|
16
|
+
const { useState, useEffect, useRef } = React
|
|
17
|
+
|
|
18
|
+
const NS = 'dsh-sendcomfy'
|
|
19
|
+
const PANEL_ID = 'dsh-sendcomfy'
|
|
20
|
+
const API = '/api/sendcomfy'
|
|
21
|
+
const IMAGE_PATH = '/api/sendcomfy/image'
|
|
22
|
+
const RUN_ROWS = 8
|
|
23
|
+
const IMPORT_LIMIT_BYTES = 4 * 1024 * 1024
|
|
24
|
+
|
|
25
|
+
/* ── locale 字典(key 至少覆盖 CONTRACT §7.3) ───────────────────────── */
|
|
26
|
+
const ZH = {
|
|
27
|
+
'panel.title': 'ComfyUI 桥接',
|
|
28
|
+
'panel.subtitle': '配置 ComfyUI 服务器、浏览模型、导入并运行工作流',
|
|
29
|
+
'common.refresh': '刷新',
|
|
30
|
+
'common.retry': '重试',
|
|
31
|
+
'common.cancel': '取消',
|
|
32
|
+
'common.close': '关闭',
|
|
33
|
+
'common.loading': '加载中…',
|
|
34
|
+
'conn.title': '连接配置',
|
|
35
|
+
'conn.url': 'ComfyUI 地址',
|
|
36
|
+
'conn.urlHint': '可填 IP、IP:端口或 http URL;Host 会自动规范化(默认 127.0.0.1:8188)',
|
|
37
|
+
'conn.timeout': '运行超时(秒)',
|
|
38
|
+
'conn.timeoutHint': '留空使用默认 300;范围 5–3600',
|
|
39
|
+
'conn.timeoutInvalid': '超时需为 5–3600 的整数秒',
|
|
40
|
+
'conn.urlRequired': '请填写 ComfyUI 地址',
|
|
41
|
+
'conn.saveTest': '保存并测试',
|
|
42
|
+
'conn.saving': '保存中…',
|
|
43
|
+
'conn.testing': '连接中…',
|
|
44
|
+
'conn.connected': '已连接',
|
|
45
|
+
'conn.disconnected': '未连接',
|
|
46
|
+
'conn.unknown': '未检测',
|
|
47
|
+
'conn.unconfigured': '未配置',
|
|
48
|
+
'conn.unsaved': '有未保存修改',
|
|
49
|
+
'conn.saved': '配置已保存',
|
|
50
|
+
'conn.latency': '延迟',
|
|
51
|
+
'conn.version': '版本',
|
|
52
|
+
'conn.device': '设备',
|
|
53
|
+
'conn.testFailed': '测试连接失败',
|
|
54
|
+
'models.title': '模型库',
|
|
55
|
+
'models.refresh': '刷新',
|
|
56
|
+
'models.empty': 'ComfyUI 没有返回任何模型文件',
|
|
57
|
+
'models.loading': '正在读取模型…',
|
|
58
|
+
'models.error': '模型读取失败',
|
|
59
|
+
'models.copy': '复制文件名',
|
|
60
|
+
'models.copied': '已复制',
|
|
61
|
+
'models.total': '共 {n} 个文件',
|
|
62
|
+
'models.files': '{n} 个',
|
|
63
|
+
'models.expand': '展开分类',
|
|
64
|
+
'models.collapse': '收起分类',
|
|
65
|
+
'wf.title': '工作流',
|
|
66
|
+
'wf.import': '导入 JSON',
|
|
67
|
+
'wf.importPlaceholder': '粘贴 ComfyUI 导出的工作流 JSON…',
|
|
68
|
+
'wf.importFromFile': '选择 .json 文件',
|
|
69
|
+
'wf.importName': '工作流名称(可选)',
|
|
70
|
+
'wf.importNamePlaceholder': '留空时用文件名或自动命名',
|
|
71
|
+
'wf.importDropHint': '也可以把 .json 文件拖到上面的输入框里。',
|
|
72
|
+
'wf.importNeedJson': '请先粘贴工作流 JSON 或选择文件',
|
|
73
|
+
'wf.importFileError': '文件读取失败',
|
|
74
|
+
'wf.importFileTooBig': '文件过大(上限 4MB)',
|
|
75
|
+
'wf.importing': '导入中…',
|
|
76
|
+
'wf.importedAs': '已导入:{name}',
|
|
77
|
+
'panel.version': 'v0.5.0',
|
|
78
|
+
'tab.workflows': '工作流',
|
|
79
|
+
'conn.configureCta': '去配置连接',
|
|
80
|
+
'tab.models': '模型',
|
|
81
|
+
'tab.runs': '记录',
|
|
82
|
+
'tab.connection': '连接',
|
|
83
|
+
'wf.emptyTitle': '还没有工作流',
|
|
84
|
+
'wf.emptyHint': '导入一个 ComfyUI 工作流后,会话里的 AI 就能用它出图',
|
|
85
|
+
'wf.importWorkflow': '导入工作流',
|
|
86
|
+
'models.search': '搜索模型名…',
|
|
87
|
+
'models.noMatch': '没有匹配的模型',
|
|
88
|
+
'wf.serverHint': '先在「连接」页填好 ComfyUI 地址并保存,这里会直接列出 ComfyUI 服务器上的工作流,不需要导入。',
|
|
89
|
+
'wf.serverEmptyTitle': 'ComfyUI 服务器上没有工作流',
|
|
90
|
+
'wf.serverEmptyHint': '在 ComfyUI 里保存工作流(Workflows 面板)后,点刷新即可看到。',
|
|
91
|
+
'wf.serverLoadError': '读取 ComfyUI 服务器工作流失败',
|
|
92
|
+
'wf.searchServer': '搜索工作流名或路径…',
|
|
93
|
+
'wf.serverCount': '共 {n} 个',
|
|
94
|
+
'wf.use': '使用',
|
|
95
|
+
'wf.useHint': '点击任意工作流即可打开并运行;运行时自动从 ComfyUI 加载,不需要导入。',
|
|
96
|
+
'wf.serverNoMatch': '没有匹配的工作流',
|
|
97
|
+
'wf.serverReadonly': '服务器工作流:每次运行前自动从 ComfyUI 加载(无需导入)。用途说明/标签只对本地库工作流可用。',
|
|
98
|
+
'wf.copyPath': '复制路径',
|
|
99
|
+
'wf.copiedPath': '已复制路径',
|
|
100
|
+
'wf.importOk': '导入成功',
|
|
101
|
+
'wf.importWarnings': '导入提示',
|
|
102
|
+
'wf.capabilities': '能力',
|
|
103
|
+
'wf.description': '用途说明(AI 选型会用)',
|
|
104
|
+
'wf.descriptionHint': '一句话讲清什么时候该用它、需要什么输入、输出什么',
|
|
105
|
+
'wf.tags': '标签',
|
|
106
|
+
'wf.tagsHint': '用逗号分隔,最多 12 个',
|
|
107
|
+
'wf.saveMeta': '保存说明',
|
|
108
|
+
'wf.savedMeta': '已保存',
|
|
109
|
+
'wf.metaInvalid': '说明 ≤500 字;标签 ≤12 个、每个 ≤40 字',
|
|
110
|
+
'wf.needsInput': '需输入文件 {n}',
|
|
111
|
+
'wf.needsInputTitle': '需要的输入文件',
|
|
112
|
+
'common.save': '保存',
|
|
113
|
+
'common.saving': '保存中…',
|
|
114
|
+
'wf.kind.txt2img': '文生图',
|
|
115
|
+
'wf.kind.img2img': '图生图',
|
|
116
|
+
'wf.kind.inpaint': '局部重绘',
|
|
117
|
+
'wf.kind.upscale': '放大',
|
|
118
|
+
'wf.kind.controlnet': 'ControlNet',
|
|
119
|
+
'wf.kind.lora': 'LoRA',
|
|
120
|
+
'wf.kind.video': '视频',
|
|
121
|
+
'wf.kind.audio': '音频',
|
|
122
|
+
'wf.kind.other': '其他',
|
|
123
|
+
'wf.fromServer': '从 ComfyUI 服务器导入',
|
|
124
|
+
'wf.listEmpty': '还没有工作流,先导入一个 ComfyUI 的 JSON',
|
|
125
|
+
'wf.open': '打开',
|
|
126
|
+
'wf.rename': '重命名',
|
|
127
|
+
'wf.renamePrompt': '新名称',
|
|
128
|
+
'wf.renameSave': '保存',
|
|
129
|
+
'wf.renameEmpty': '名称不能为空',
|
|
130
|
+
'wf.renamedOk': '已重命名',
|
|
131
|
+
'wf.deletedOk': '已删除',
|
|
132
|
+
'wf.delete': '删除',
|
|
133
|
+
'wf.deleteConfirm': '删除这个工作流?此操作不可撤销。',
|
|
134
|
+
'wf.nodes': '{n} 个节点',
|
|
135
|
+
'wf.params': '{n} 个参数',
|
|
136
|
+
'wf.source': '来源',
|
|
137
|
+
'wf.sourceUi': '网页导出',
|
|
138
|
+
'wf.sourceApi': 'API 格式',
|
|
139
|
+
'wf.sourceServer': '服务器',
|
|
140
|
+
'wf.detailBack': '返回列表',
|
|
141
|
+
'wf.prompt': '提示词',
|
|
142
|
+
'wf.negativePrompt': '负向提示词',
|
|
143
|
+
'wf.promptNone': '没有检测到提示词输入节点,可以直接在下方参数里编辑文本。',
|
|
144
|
+
'wf.promptTargets': '目标',
|
|
145
|
+
'wf.paramsTitle': '参数',
|
|
146
|
+
'wf.paramsEmpty': '这个工作流没有可调参数',
|
|
147
|
+
'wf.paramPath': '参数路径',
|
|
148
|
+
'wf.nodesTitle': '节点摘要',
|
|
149
|
+
'wf.run': '运行',
|
|
150
|
+
'wf.running': '运行中…',
|
|
151
|
+
'wf.resetDefaults': '重置为默认值',
|
|
152
|
+
'wf.result': '运行结果',
|
|
153
|
+
'wf.resultEmpty': '还没有运行结果',
|
|
154
|
+
'wf.noImages': '本次运行没有输出图片',
|
|
155
|
+
'wf.elapsed': '耗时 {v}',
|
|
156
|
+
'wf.failed': '运行失败',
|
|
157
|
+
'wf.nodeErrors': '节点错误',
|
|
158
|
+
'wf.runWarnings': '运行提示',
|
|
159
|
+
'wf.applied': '生效参数',
|
|
160
|
+
'wf.promptId': '任务 ID',
|
|
161
|
+
'wf.loading': '正在读取工作流…',
|
|
162
|
+
'wf.loadError': '工作流详情读取失败',
|
|
163
|
+
'wf.serverListTitle': '服务器上的工作流',
|
|
164
|
+
'wf.serverLoading': '正在读取服务器工作流…',
|
|
165
|
+
'wf.serverEmpty': '服务器上没有可导入的工作流',
|
|
166
|
+
'wf.serverError': '读取服务器工作流失败',
|
|
167
|
+
'wf.serverUnsupported': 'ComfyUI 未提供服务器工作流接口,可以改用粘贴 JSON 导入。',
|
|
168
|
+
'runs.title': '运行记录',
|
|
169
|
+
'runs.count': '最近 {n} 条',
|
|
170
|
+
'runs.empty': '最近还没有运行过',
|
|
171
|
+
'runs.stateQueued': '排队中',
|
|
172
|
+
'runs.stateDone': '已完成',
|
|
173
|
+
'runs.stateError': '失败',
|
|
174
|
+
'runs.stateTimeout': '超时',
|
|
175
|
+
'error.network': '网络请求失败,请确认 Host 正在运行',
|
|
176
|
+
'error.http': '请求失败(HTTP {status})',
|
|
177
|
+
'error.timeout': '请求超时:ComfyUI 可能不可达;若导入的是很大的 JSON 请换小一点的文件',
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const EN = {
|
|
181
|
+
'panel.title': 'ComfyUI bridge',
|
|
182
|
+
'panel.subtitle': 'Configure a ComfyUI server, browse its models, import and run workflows',
|
|
183
|
+
'common.refresh': 'Refresh',
|
|
184
|
+
'common.retry': 'Retry',
|
|
185
|
+
'common.cancel': 'Cancel',
|
|
186
|
+
'common.close': 'Close',
|
|
187
|
+
'common.loading': 'Loading…',
|
|
188
|
+
'conn.title': 'Connection',
|
|
189
|
+
'conn.url': 'ComfyUI address',
|
|
190
|
+
'conn.urlHint': 'IP, IP:port or an http URL; the Host normalizes it (default 127.0.0.1:8188)',
|
|
191
|
+
'conn.timeout': 'Run timeout (seconds)',
|
|
192
|
+
'conn.timeoutHint': 'Leave empty to use the default 300; range 5–3600',
|
|
193
|
+
'conn.timeoutInvalid': 'Timeout must be an integer between 5 and 3600 seconds',
|
|
194
|
+
'conn.urlRequired': 'Enter the ComfyUI address',
|
|
195
|
+
'conn.saveTest': 'Save and test',
|
|
196
|
+
'conn.saving': 'Saving…',
|
|
197
|
+
'conn.testing': 'Connecting…',
|
|
198
|
+
'conn.connected': 'Connected',
|
|
199
|
+
'conn.disconnected': 'Disconnected',
|
|
200
|
+
'conn.unknown': 'Not tested',
|
|
201
|
+
'conn.unconfigured': 'Not configured',
|
|
202
|
+
'conn.unsaved': 'Unsaved changes',
|
|
203
|
+
'conn.saved': 'Configuration saved',
|
|
204
|
+
'conn.latency': 'Latency',
|
|
205
|
+
'conn.version': 'Version',
|
|
206
|
+
'conn.device': 'Device',
|
|
207
|
+
'conn.testFailed': 'Connection test failed',
|
|
208
|
+
'models.title': 'Models',
|
|
209
|
+
'models.refresh': 'Refresh',
|
|
210
|
+
'models.empty': 'ComfyUI returned no model files',
|
|
211
|
+
'models.loading': 'Loading models…',
|
|
212
|
+
'models.error': 'Could not load models',
|
|
213
|
+
'models.copy': 'Copy file name',
|
|
214
|
+
'models.copied': 'Copied',
|
|
215
|
+
'models.total': '{n} files in total',
|
|
216
|
+
'models.files': '{n}',
|
|
217
|
+
'models.expand': 'Expand category',
|
|
218
|
+
'models.collapse': 'Collapse category',
|
|
219
|
+
'wf.title': 'Workflows',
|
|
220
|
+
'wf.import': 'Import JSON',
|
|
221
|
+
'wf.importPlaceholder': 'Paste the workflow JSON exported by ComfyUI…',
|
|
222
|
+
'wf.importFromFile': 'Choose a .json file',
|
|
223
|
+
'wf.importName': 'Workflow name (optional)',
|
|
224
|
+
'wf.importNamePlaceholder': 'Defaults to the file name or an automatic name',
|
|
225
|
+
'wf.importDropHint': 'You can also drop a .json file onto the box above.',
|
|
226
|
+
'wf.importNeedJson': 'Paste the workflow JSON or choose a file first',
|
|
227
|
+
'wf.importFileError': 'Could not read the file',
|
|
228
|
+
'wf.importFileTooBig': 'File is too large (4MB limit)',
|
|
229
|
+
'wf.importing': 'Importing…',
|
|
230
|
+
'wf.importedAs': 'Imported: {name}',
|
|
231
|
+
'panel.version': 'v0.5.0',
|
|
232
|
+
'tab.workflows': 'Workflows',
|
|
233
|
+
'conn.configureCta': 'Configure connection',
|
|
234
|
+
'tab.models': 'Models',
|
|
235
|
+
'tab.runs': 'Runs',
|
|
236
|
+
'tab.connection': 'Connection',
|
|
237
|
+
'wf.emptyTitle': 'No workflows yet',
|
|
238
|
+
'wf.emptyHint': 'Import a ComfyUI workflow so the session AI can run it',
|
|
239
|
+
'wf.importWorkflow': 'Import workflow',
|
|
240
|
+
'models.search': 'Search model names…',
|
|
241
|
+
'models.noMatch': 'No matching models',
|
|
242
|
+
'wf.serverHint': 'Set your ComfyUI address on the Connection tab first. Workflows stored on the server will be listed here — no import needed.',
|
|
243
|
+
'wf.serverEmptyTitle': 'No workflows on the ComfyUI server',
|
|
244
|
+
'wf.serverEmptyHint': 'Save a workflow in ComfyUI (Workflows panel), then hit Refresh.',
|
|
245
|
+
'wf.serverLoadError': 'Failed to read server workflows',
|
|
246
|
+
'wf.searchServer': 'Search workflow name or path…',
|
|
247
|
+
'wf.serverCount': '{n} total',
|
|
248
|
+
'wf.use': 'Use',
|
|
249
|
+
'wf.useHint': 'Click a workflow to open and run it. It is loaded from ComfyUI on demand — no import step.',
|
|
250
|
+
'wf.serverNoMatch': 'No matching workflows',
|
|
251
|
+
'wf.serverReadonly': 'Server workflow: loaded from ComfyUI before every run (no import). Purpose notes/tags only apply to saved local workflows.',
|
|
252
|
+
'wf.copyPath': 'Copy path',
|
|
253
|
+
'wf.copiedPath': 'Path copied',
|
|
254
|
+
'wf.importOk': 'Imported',
|
|
255
|
+
'wf.importWarnings': 'Import notices',
|
|
256
|
+
'wf.capabilities': 'Capabilities',
|
|
257
|
+
'wf.description': 'Purpose note (used by the AI to pick workflows)',
|
|
258
|
+
'wf.descriptionHint': 'One line: when to use it, what input it needs, what it outputs',
|
|
259
|
+
'wf.tags': 'Tags',
|
|
260
|
+
'wf.tagsHint': 'Comma-separated, up to 12',
|
|
261
|
+
'wf.saveMeta': 'Save note',
|
|
262
|
+
'wf.savedMeta': 'Saved',
|
|
263
|
+
'wf.metaInvalid': 'Note ≤500 chars; tags ≤12, each ≤40 chars',
|
|
264
|
+
'wf.needsInput': 'Needs {n} input file(s)',
|
|
265
|
+
'wf.needsInputTitle': 'Required input files',
|
|
266
|
+
'common.save': 'Save',
|
|
267
|
+
'common.saving': 'Saving…',
|
|
268
|
+
'wf.kind.txt2img': 'Text to image',
|
|
269
|
+
'wf.kind.img2img': 'Image to image',
|
|
270
|
+
'wf.kind.inpaint': 'Inpaint',
|
|
271
|
+
'wf.kind.upscale': 'Upscale',
|
|
272
|
+
'wf.kind.controlnet': 'ControlNet',
|
|
273
|
+
'wf.kind.lora': 'LoRA',
|
|
274
|
+
'wf.kind.video': 'Video',
|
|
275
|
+
'wf.kind.audio': 'Audio',
|
|
276
|
+
'wf.kind.other': 'Other',
|
|
277
|
+
'wf.fromServer': 'Import from ComfyUI server',
|
|
278
|
+
'wf.listEmpty': 'No workflows yet. Import a ComfyUI JSON to start.',
|
|
279
|
+
'wf.open': 'Open',
|
|
280
|
+
'wf.rename': 'Rename',
|
|
281
|
+
'wf.renamePrompt': 'New name',
|
|
282
|
+
'wf.renameSave': 'Save',
|
|
283
|
+
'wf.renameEmpty': 'Name cannot be empty',
|
|
284
|
+
'wf.renamedOk': 'Renamed',
|
|
285
|
+
'wf.deletedOk': 'Deleted',
|
|
286
|
+
'wf.delete': 'Delete',
|
|
287
|
+
'wf.deleteConfirm': 'Delete this workflow? This cannot be undone.',
|
|
288
|
+
'wf.nodes': '{n} nodes',
|
|
289
|
+
'wf.params': '{n} parameters',
|
|
290
|
+
'wf.source': 'Source',
|
|
291
|
+
'wf.sourceUi': 'UI export',
|
|
292
|
+
'wf.sourceApi': 'API format',
|
|
293
|
+
'wf.sourceServer': 'Server',
|
|
294
|
+
'wf.detailBack': 'Back to list',
|
|
295
|
+
'wf.prompt': 'Prompt',
|
|
296
|
+
'wf.negativePrompt': 'Negative prompt',
|
|
297
|
+
'wf.promptNone': 'No prompt input node was detected; edit the text in the parameters below.',
|
|
298
|
+
'wf.promptTargets': 'Target',
|
|
299
|
+
'wf.paramsTitle': 'Parameters',
|
|
300
|
+
'wf.paramsEmpty': 'This workflow has no editable parameters',
|
|
301
|
+
'wf.paramPath': 'Parameter path',
|
|
302
|
+
'wf.nodesTitle': 'Node summary',
|
|
303
|
+
'wf.run': 'Run',
|
|
304
|
+
'wf.running': 'Running…',
|
|
305
|
+
'wf.resetDefaults': 'Reset to defaults',
|
|
306
|
+
'wf.result': 'Result',
|
|
307
|
+
'wf.resultEmpty': 'No result yet',
|
|
308
|
+
'wf.noImages': 'This run produced no images',
|
|
309
|
+
'wf.elapsed': 'Elapsed {v}',
|
|
310
|
+
'wf.failed': 'Run failed',
|
|
311
|
+
'wf.nodeErrors': 'Node errors',
|
|
312
|
+
'wf.runWarnings': 'Run notices',
|
|
313
|
+
'wf.applied': 'Applied overrides',
|
|
314
|
+
'wf.promptId': 'Prompt ID',
|
|
315
|
+
'wf.loading': 'Loading workflow…',
|
|
316
|
+
'wf.loadError': 'Could not load the workflow',
|
|
317
|
+
'wf.serverListTitle': 'Workflows on the server',
|
|
318
|
+
'wf.serverLoading': 'Loading server workflows…',
|
|
319
|
+
'wf.serverEmpty': 'The server has no importable workflows',
|
|
320
|
+
'wf.serverError': 'Could not load server workflows',
|
|
321
|
+
'wf.serverUnsupported': 'ComfyUI does not expose the server workflow API; paste the JSON instead.',
|
|
322
|
+
'runs.title': 'Run history',
|
|
323
|
+
'runs.count': 'latest {n}',
|
|
324
|
+
'runs.empty': 'No runs yet',
|
|
325
|
+
'runs.stateQueued': 'Queued',
|
|
326
|
+
'runs.stateDone': 'Done',
|
|
327
|
+
'runs.stateError': 'Failed',
|
|
328
|
+
'runs.stateTimeout': 'Timed out',
|
|
329
|
+
'error.network': 'Network request failed; check that the Host is running',
|
|
330
|
+
'error.http': 'Request failed (HTTP {status})',
|
|
331
|
+
'error.timeout': 'Request timed out: ComfyUI may be unreachable (or the JSON is very large)',
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* ── 样式:只用 DSH 主题 token(--dsw-alias-* / --dsw-radius-* / --dsw-focus-ring-*) ── */
|
|
335
|
+
const CSS = `
|
|
336
|
+
.sc-page{
|
|
337
|
+
box-sizing:border-box;height:100%;max-height:100vh;max-height:100dvh;min-height:0;
|
|
338
|
+
display:flex;flex-direction:column;overflow:hidden;position:relative;
|
|
339
|
+
background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);
|
|
340
|
+
font-size:13px;line-height:20px;--sc-pad:clamp(20px,4vw,48px);
|
|
341
|
+
}
|
|
342
|
+
.sc-page,.sc-page *,.sc-page *::before,.sc-page *::after{box-sizing:border-box}
|
|
343
|
+
|
|
344
|
+
/* 顶部固定标题栏 */
|
|
345
|
+
.sc-head{flex:none;display:flex;flex-wrap:wrap;align-items:flex-start;gap:10px 16px;width:100%;
|
|
346
|
+
max-width:calc(960px + 2 * var(--sc-pad));margin:0 auto;padding:20px var(--sc-pad) 12px}
|
|
347
|
+
.sc-titleGroup{flex:1 1 260px;min-width:0;display:flex;flex-direction:column;gap:2px}
|
|
348
|
+
.sc-title{margin:0;font-size:20px;font-weight:500;line-height:28px;overflow-wrap:anywhere}
|
|
349
|
+
.sc-sub{margin:0;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px;overflow-wrap:anywhere}
|
|
350
|
+
.sc-headActions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-left:auto;flex:none;max-width:100%}
|
|
351
|
+
.sc-headError{flex-basis:100%;margin:2px 0 0}
|
|
352
|
+
|
|
353
|
+
/* 可滚动主区 */
|
|
354
|
+
.sc-scroll{flex:1 1 auto;min-height:120px;max-height:calc(100vh - 150px);max-height:calc(100dvh - 150px);
|
|
355
|
+
overflow-y:auto;overscroll-behavior:contain;width:100%;padding:16px var(--sc-pad) 48px;
|
|
356
|
+
display:flex;flex-direction:column;align-items:center;gap:16px;
|
|
357
|
+
scrollbar-width:thin;scrollbar-color:var(--dsw-alias-scrollbar-bg-l2) transparent}
|
|
358
|
+
|
|
359
|
+
/* 卡片 */
|
|
360
|
+
.sc-card{width:100%;max-width:960px;min-width:0;overflow:hidden;
|
|
361
|
+
border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xl);
|
|
362
|
+
background:var(--dsw-alias-bg-layer-2)}
|
|
363
|
+
.sc-cardHead{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;min-width:0;
|
|
364
|
+
padding:12px 16px;border-bottom:.5px solid var(--dsw-alias-border-l2)}
|
|
365
|
+
.sc-cardTitle{display:flex;align-items:center;gap:8px;margin:0;min-width:0;
|
|
366
|
+
font-size:14px;font-weight:500;line-height:22px}
|
|
367
|
+
.sc-cardTitle>svg{flex:none;color:var(--dsw-alias-label-secondary)}
|
|
368
|
+
.sc-cardTitleText{min-width:0;overflow-wrap:anywhere}
|
|
369
|
+
.sc-cardCount{flex:none;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;
|
|
370
|
+
font-variant-numeric:tabular-nums}
|
|
371
|
+
.sc-cardActions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-left:auto;min-width:0}
|
|
372
|
+
.sc-cardBody{display:flex;flex-direction:column;gap:14px;padding:16px;min-width:0}
|
|
373
|
+
|
|
374
|
+
/* 顶部页签(连接 / 工作流 / 模型 / 记录) */
|
|
375
|
+
.sc-tabs{flex:none;width:100%;border-bottom:.5px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base)}
|
|
376
|
+
.sc-tabsInner{display:flex;flex-wrap:wrap;gap:2px;width:100%;
|
|
377
|
+
max-width:calc(960px + 2 * var(--sc-pad));margin:0 auto;padding:0 var(--sc-pad)}
|
|
378
|
+
.sc-tab{display:inline-flex;align-items:center;gap:6px;height:38px;padding:0 10px;border:0;
|
|
379
|
+
border-bottom:2px solid transparent;margin-bottom:-.5px;background:transparent;
|
|
380
|
+
color:var(--dsw-alias-label-secondary);font:inherit;font-size:13px;line-height:20px;
|
|
381
|
+
white-space:nowrap;cursor:pointer;transition:color .12s ease,border-color .12s ease}
|
|
382
|
+
.sc-tab>svg{flex:none;color:currentColor;opacity:.85}
|
|
383
|
+
.sc-tab:hover{color:var(--dsw-alias-label-primary)}
|
|
384
|
+
.sc-tab[aria-selected="true"]{color:var(--dsw-alias-label-primary);
|
|
385
|
+
border-bottom-color:var(--dsw-alias-state-business-primary);font-weight:500}
|
|
386
|
+
.sc-tab:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));
|
|
387
|
+
outline-offset:-2px;border-radius:var(--dsw-radius-sm)}
|
|
388
|
+
.sc-tabCount{flex:none;min-width:16px;height:16px;padding:0 5px;border-radius:999px;
|
|
389
|
+
background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);
|
|
390
|
+
font-size:10.5px;line-height:16px;text-align:center;font-variant-numeric:tabular-nums}
|
|
391
|
+
|
|
392
|
+
/* 空状态 */
|
|
393
|
+
.sc-emptyState{display:flex;flex-direction:column;align-items:center;gap:6px;
|
|
394
|
+
padding:36px 16px;text-align:center;min-width:0}
|
|
395
|
+
.sc-emptyIcon{width:44px;height:44px;border-radius:50%;display:flex;align-items:center;
|
|
396
|
+
justify-content:center;background:var(--dsw-alias-bg-layer-1);
|
|
397
|
+
border:.5px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);margin-bottom:2px}
|
|
398
|
+
.sc-emptyTitle{margin:0;font-size:14px;line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary)}
|
|
399
|
+
.sc-emptyHint{margin:0;max-width:420px;font-size:12px;line-height:19px;color:var(--dsw-alias-label-tertiary)}
|
|
400
|
+
.sc-emptyActions{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-top:8px}
|
|
401
|
+
|
|
402
|
+
/* 模型搜索栏 */
|
|
403
|
+
.sc-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0}
|
|
404
|
+
.sc-search{flex:1 1 220px;min-width:160px}
|
|
405
|
+
|
|
406
|
+
/* 服务器工作流列表(不导入,点击打开) */
|
|
407
|
+
.sc-serverWfList{display:flex;flex-direction:column;gap:6px;min-width:0}
|
|
408
|
+
.sc-serverWfRow{display:flex;align-items:center;gap:10px;width:100%;min-width:0;
|
|
409
|
+
padding:10px 12px;border:.5px solid var(--dsw-alias-border-l1);
|
|
410
|
+
border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1);
|
|
411
|
+
color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;
|
|
412
|
+
transition:background-color .12s ease,border-color .12s ease}
|
|
413
|
+
.sc-serverWfRow:hover{background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l2)}
|
|
414
|
+
.sc-serverWfRow:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));
|
|
415
|
+
outline-offset:-1px}
|
|
416
|
+
.sc-serverWfLead{flex:none;display:flex;color:var(--dsw-alias-label-secondary)}
|
|
417
|
+
.sc-serverWfMain{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:1px}
|
|
418
|
+
.sc-serverWfName{font-size:13px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
419
|
+
.sc-serverWfPath{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);
|
|
420
|
+
overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
421
|
+
.sc-serverWfUse{flex:none;display:inline-flex;align-items:center;gap:2px;
|
|
422
|
+
color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
|
|
423
|
+
.sc-serverWfRow:hover .sc-serverWfUse{color:var(--dsw-alias-label-primary)}
|
|
424
|
+
|
|
425
|
+
/* 按钮 */
|
|
426
|
+
.sc-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;flex:none;
|
|
427
|
+
height:32px;padding:0 12px;border-radius:var(--dsw-radius-md);border:.5px solid var(--dsw-alias-border-l4);
|
|
428
|
+
background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;
|
|
429
|
+
white-space:nowrap;cursor:pointer;transition:background-color .12s ease,color .12s ease,border-color .12s ease}
|
|
430
|
+
.sc-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
|
431
|
+
.sc-btn:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}
|
|
432
|
+
.sc-btn:disabled{opacity:.5;cursor:default}
|
|
433
|
+
.sc-btnPrimary{background:var(--dsw-alias-button-primary-fill);border-color:transparent;
|
|
434
|
+
color:var(--dsw-alias-label-primary-foreground)}
|
|
435
|
+
.sc-btnPrimary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}
|
|
436
|
+
.sc-btnPrimary:active:not(:disabled){background:var(--dsw-alias-button-primary-hover)}
|
|
437
|
+
.sc-btnDanger{color:var(--dsw-alias-state-error-primary)}
|
|
438
|
+
.sc-btnDanger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger,var(--dsw-alias-interactive-bg-hover))}
|
|
439
|
+
.sc-iconBtn{display:inline-flex;align-items:center;justify-content:center;flex:none;
|
|
440
|
+
width:28px;height:28px;padding:0;border:0;border-radius:var(--dsw-radius-sm);
|
|
441
|
+
background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer}
|
|
442
|
+
.sc-iconBtn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
443
|
+
.sc-iconBtn:disabled{opacity:.5;cursor:default}
|
|
444
|
+
.sc-linkBtn{padding:0;border:0;background:none;font:inherit;font-size:12px;line-height:18px;
|
|
445
|
+
color:var(--dsw-alias-link);text-decoration:underline;text-underline-offset:2px;cursor:pointer}
|
|
446
|
+
.sc-page button:focus-visible,.sc-page summary:focus-visible{
|
|
447
|
+
outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));
|
|
448
|
+
outline-offset:1px}
|
|
449
|
+
.sc-btnRow{display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0}
|
|
450
|
+
|
|
451
|
+
/* 表单 */
|
|
452
|
+
.sc-field{display:flex;flex-wrap:wrap;align-items:flex-start;gap:6px 12px;min-width:0}
|
|
453
|
+
.sc-fieldLabel{flex:0 0 auto;min-width:96px;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:32px}
|
|
454
|
+
.sc-fieldCtl{display:flex;flex-direction:column;gap:5px;flex:1 1 240px;min-width:0}
|
|
455
|
+
.sc-hint{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;overflow-wrap:anywhere}
|
|
456
|
+
.sc-input,.sc-textarea,.sc-select{width:100%;min-width:0;border:.5px solid var(--dsw-alias-border-l4);
|
|
457
|
+
border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);
|
|
458
|
+
color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;outline:none}
|
|
459
|
+
.sc-input,.sc-select{height:32px;padding:0 10px}
|
|
460
|
+
.sc-inputShort{width:140px;max-width:100%}
|
|
461
|
+
.sc-textarea{min-height:72px;padding:8px 10px;line-height:20px;resize:vertical}
|
|
462
|
+
.sc-input::placeholder,.sc-textarea::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
463
|
+
.sc-input:focus,.sc-textarea:focus,.sc-select:focus{
|
|
464
|
+
border-color:var(--dsw-alias-state-business-primary);
|
|
465
|
+
box-shadow:inset 0 0 0 .5px var(--dsw-alias-state-business-primary)}
|
|
466
|
+
.sc-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary);box-shadow:none}
|
|
467
|
+
.sc-selectWrap{position:relative;display:flex;min-width:0;flex:1 1 auto}
|
|
468
|
+
.sc-select{appearance:none;-webkit-appearance:none;padding-right:28px}
|
|
469
|
+
.sc-selectWrap::after{content:"";position:absolute;right:10px;top:50%;margin-top:-2px;width:0;height:0;
|
|
470
|
+
border-left:4px solid transparent;border-right:4px solid transparent;
|
|
471
|
+
border-top:5px solid var(--dsw-alias-label-secondary);pointer-events:none}
|
|
472
|
+
.sc-dropActive{border-color:var(--dsw-alias-state-business-primary);
|
|
473
|
+
box-shadow:inset 0 0 0 .5px var(--dsw-alias-state-business-primary)}
|
|
474
|
+
.sc-srOnly{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
|
|
475
|
+
clip:rect(0 0 0 0);white-space:nowrap;border:0}
|
|
476
|
+
.sc-fileLabel{position:relative;cursor:pointer}
|
|
477
|
+
.sc-fileLabel:focus-within{
|
|
478
|
+
outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));
|
|
479
|
+
outline-offset:1px}
|
|
480
|
+
.sc-stack{display:flex;flex-direction:column;gap:6px;min-width:0}
|
|
481
|
+
|
|
482
|
+
/* 状态 pill / 提示行 */
|
|
483
|
+
.sc-pill{display:inline-flex;align-items:center;gap:6px;flex:none;height:22px;padding:0 8px;
|
|
484
|
+
border:.5px solid var(--dsw-alias-border-l3);border-radius:999px;color:var(--dsw-alias-label-secondary);
|
|
485
|
+
font-size:12px;line-height:18px;white-space:nowrap}
|
|
486
|
+
.sc-pill[data-tone="ok"]{color:var(--dsw-alias-state-success-primary)}
|
|
487
|
+
.sc-pill[data-tone="error"]{color:var(--dsw-alias-state-error-primary)}
|
|
488
|
+
.sc-pill[data-tone="warn"]{color:var(--dsw-alias-state-warn-primary)}
|
|
489
|
+
.sc-pill[data-tone="busy"]{color:var(--dsw-alias-state-business-primary)}
|
|
490
|
+
.sc-dot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption)}
|
|
491
|
+
.sc-dot[data-tone="ok"]{background:var(--dsw-alias-state-success-primary)}
|
|
492
|
+
.sc-dot[data-tone="error"]{background:var(--dsw-alias-state-error-primary)}
|
|
493
|
+
.sc-dot[data-tone="warn"]{background:var(--dsw-alias-state-warn-primary)}
|
|
494
|
+
.sc-dot[data-tone="busy"]{background:var(--dsw-alias-state-business-primary)}
|
|
495
|
+
.sc-errorLine{display:flex;flex-wrap:wrap;align-items:center;gap:6px;min-width:0;
|
|
496
|
+
color:var(--dsw-alias-state-error-primary);font-size:12.5px;line-height:18px}
|
|
497
|
+
.sc-errorText{min-width:0;overflow-wrap:anywhere}
|
|
498
|
+
.sc-okLine{margin:0;color:var(--dsw-alias-state-success-primary);font-size:12.5px;line-height:18px;overflow-wrap:anywhere}
|
|
499
|
+
.sc-warnLine{margin:0;color:var(--dsw-alias-state-warn-primary);font-size:12.5px;line-height:18px;overflow-wrap:anywhere}
|
|
500
|
+
.sc-muted{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12.5px;line-height:18px;overflow-wrap:anywhere}
|
|
501
|
+
.sc-empty{margin:0;padding:4px 0;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px;text-align:center}
|
|
502
|
+
.sc-noteList{margin:0;padding-left:16px;font-size:12px;line-height:18px;color:var(--dsw-alias-state-warn-primary);overflow-wrap:anywhere}
|
|
503
|
+
.sc-noteTitle{font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-state-warn-primary)}
|
|
504
|
+
.sc-loadingRow{display:flex;flex-wrap:wrap;align-items:center;gap:8px;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px}
|
|
505
|
+
.sc-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:36px 0;
|
|
506
|
+
color:var(--dsw-alias-label-tertiary);font-size:13px}
|
|
507
|
+
.sc-errorBox{display:flex;flex-direction:column;align-items:flex-start;gap:12px;padding:20px 16px}
|
|
508
|
+
.sc-spinner{flex:none;width:12px;height:12px;border-radius:50%;
|
|
509
|
+
border:1.5px solid var(--dsw-alias-border-l3);border-top-color:var(--dsw-alias-state-business-primary);
|
|
510
|
+
animation:sc-spin .8s linear infinite;display:inline-block}
|
|
511
|
+
@keyframes sc-spin{to{transform:rotate(360deg)}}
|
|
512
|
+
|
|
513
|
+
/* 测试结果事实行 */
|
|
514
|
+
.sc-facts{display:flex;flex-wrap:wrap;align-items:center;gap:6px 16px;min-width:0}
|
|
515
|
+
.sc-fact{display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dsw-alias-label-secondary);
|
|
516
|
+
font-size:12.5px;line-height:18px}
|
|
517
|
+
.sc-factLabel{color:var(--dsw-alias-label-tertiary)}
|
|
518
|
+
.sc-factValue{min-width:0;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
|
|
519
|
+
.sc-fact code{font-size:11.5px;background:var(--dsw-alias-bg-layer-3);border-radius:var(--dsw-radius-xs);
|
|
520
|
+
color:var(--dsw-alias-label-secondary);padding:1px 5px}
|
|
521
|
+
|
|
522
|
+
/* 模型分类 / 文件名 */
|
|
523
|
+
.sc-catList{display:flex;flex-direction:column;min-width:0}
|
|
524
|
+
.sc-cat{border-bottom:.5px solid var(--dsw-alias-border-l2);min-width:0}
|
|
525
|
+
.sc-cat:last-child{border-bottom:0}
|
|
526
|
+
.sc-catHead{display:flex;align-items:center;gap:8px;width:100%;min-width:0;padding:9px 0;
|
|
527
|
+
border:0;background:none;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;
|
|
528
|
+
line-height:20px;text-align:left;cursor:pointer}
|
|
529
|
+
.sc-chev{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .15s ease}
|
|
530
|
+
.sc-catLabel{flex:1;min-width:0;font-weight:500;overflow-wrap:anywhere}
|
|
531
|
+
.sc-catCount{flex:none;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;font-variant-numeric:tabular-nums}
|
|
532
|
+
.sc-files{display:flex;flex-wrap:wrap;gap:6px;padding:0 0 10px;min-width:0}
|
|
533
|
+
.sc-file{display:inline-flex;align-items:center;gap:6px;min-width:0;max-width:min(100%,420px);
|
|
534
|
+
height:26px;padding:0 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);
|
|
535
|
+
background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font:inherit;
|
|
536
|
+
font-size:12px;line-height:18px;text-align:left;cursor:pointer}
|
|
537
|
+
.sc-file:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l3)}
|
|
538
|
+
.sc-file>.sc-fileName{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
|
|
539
|
+
.sc-fileCopied{flex:none;color:var(--dsw-alias-state-success-primary);font-size:11.5px}
|
|
540
|
+
.sc-fileDone{color:var(--dsw-alias-state-success-primary)}
|
|
541
|
+
|
|
542
|
+
/* 工作流列表 */
|
|
543
|
+
.sc-wfList{display:flex;flex-direction:column;min-width:0}
|
|
544
|
+
.sc-wfRow{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;min-width:0;
|
|
545
|
+
padding:10px 0;border-bottom:.5px solid var(--dsw-alias-border-l2)}
|
|
546
|
+
.sc-wfRow:last-child{border-bottom:0;padding-bottom:0}
|
|
547
|
+
.sc-wfMain{display:flex;flex-direction:column;gap:3px;flex:1 1 240px;min-width:0}
|
|
548
|
+
.sc-wfNameBtn{padding:0;border:0;background:none;font:inherit;font-size:14px;font-weight:500;
|
|
549
|
+
line-height:20px;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;
|
|
550
|
+
overflow-wrap:anywhere;max-width:100%}
|
|
551
|
+
.sc-wfNameBtn:hover{text-decoration:underline;text-underline-offset:3px}
|
|
552
|
+
.sc-wfMeta{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;min-width:0;
|
|
553
|
+
color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
|
554
|
+
.sc-metaTime{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}
|
|
555
|
+
.sc-wfDescRow{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;min-width:0;width:100%;margin-top:2px}
|
|
556
|
+
.sc-subRow{display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 10px;min-width:0}
|
|
557
|
+
.sc-version{flex:none;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);
|
|
558
|
+
border:0.5px solid var(--dsw-alias-border-l2);border-radius:999px;padding:0 6px}
|
|
559
|
+
.sc-kindChips{display:inline-flex;flex-wrap:wrap;align-items:center;gap:4px;min-width:0}
|
|
560
|
+
.sc-kindChip{display:inline-flex;align-items:center;padding:0 6px;height:18px;border-radius:var(--dsw-radius-sm,8px);
|
|
561
|
+
border:0.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);
|
|
562
|
+
color:var(--dsw-alias-label-secondary);font-size:11px;line-height:16px;white-space:nowrap}
|
|
563
|
+
.sc-wfDesc{flex:1 1 120px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
564
|
+
color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
|
|
565
|
+
.sc-needBadge{flex:none;display:inline-flex;align-items:center;padding:0 6px;height:18px;border-radius:var(--dsw-radius-sm,8px);
|
|
566
|
+
border:0.5px solid var(--dsw-alias-state-warn-primary);color:var(--dsw-alias-state-warn-primary);
|
|
567
|
+
font-size:11px;line-height:16px;white-space:nowrap}
|
|
568
|
+
.sc-needList{display:flex;flex-direction:column;gap:4px;margin-top:4px}
|
|
569
|
+
.sc-needRow{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;min-width:0;font-size:12px;line-height:18px}
|
|
570
|
+
.sc-needPath{flex:none;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;
|
|
571
|
+
color:var(--dsw-alias-label-secondary)}
|
|
572
|
+
.sc-needLabel{flex:none;color:var(--dsw-alias-label-primary)}
|
|
573
|
+
.sc-needHint{flex:1 1 180px;min-width:0;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:17px;overflow-wrap:anywhere}
|
|
574
|
+
.sc-wfActions{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-left:auto}
|
|
575
|
+
.sc-renameRow{display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0}
|
|
576
|
+
.sc-renameRow>.sc-input{flex:1 1 160px}
|
|
577
|
+
.sc-badge{display:inline-flex;align-items:center;flex:none;height:20px;padding:0 6px;
|
|
578
|
+
border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);
|
|
579
|
+
color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:18px;white-space:nowrap}
|
|
580
|
+
|
|
581
|
+
/* 导入 / 服务器工作流 */
|
|
582
|
+
.sc-import{display:flex;flex-direction:column;gap:12px;min-width:0;padding:12px;
|
|
583
|
+
border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);
|
|
584
|
+
background:var(--dsw-alias-bg-layer-1)}
|
|
585
|
+
.sc-serverList{display:flex;flex-direction:column;min-width:0;max-height:260px;overflow-y:auto;
|
|
586
|
+
padding:0 10px;border:.5px solid var(--dsw-alias-border-l2);
|
|
587
|
+
border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3)}
|
|
588
|
+
.sc-serverRow{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;min-width:0;
|
|
589
|
+
padding:8px 0;border-bottom:.5px solid var(--dsw-alias-border-l2)}
|
|
590
|
+
.sc-serverRow:last-child{border-bottom:0}
|
|
591
|
+
.sc-serverMain{display:flex;flex-direction:column;gap:2px;flex:1 1 200px;min-width:0}
|
|
592
|
+
.sc-serverName{font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
593
|
+
.sc-serverPath{font-size:11.5px;line-height:16px;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere}
|
|
594
|
+
.sc-warnBox{display:flex;flex-direction:column;gap:4px;min-width:0;padding:8px 10px;
|
|
595
|
+
border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);
|
|
596
|
+
background:var(--dsw-alias-bg-layer-1)}
|
|
597
|
+
|
|
598
|
+
/* 提示词 / 参数 */
|
|
599
|
+
.sc-promptGroup{display:flex;flex-direction:column;gap:12px;min-width:0}
|
|
600
|
+
.sc-promptBlock{display:flex;flex-direction:column;gap:5px;min-width:0}
|
|
601
|
+
.sc-promptHead{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;min-width:0}
|
|
602
|
+
.sc-promptLabel{font-size:13px;font-weight:500;line-height:20px;color:var(--dsw-alias-label-primary)}
|
|
603
|
+
.sc-promptHead .sc-chipRow{margin-left:auto}
|
|
604
|
+
.sc-chipRow{display:flex;flex-wrap:wrap;gap:4px;min-width:0}
|
|
605
|
+
.sc-chip{display:inline-flex;align-items:center;max-width:100%;height:20px;padding:0 6px;
|
|
606
|
+
border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-layer-3);
|
|
607
|
+
color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:18px;
|
|
608
|
+
font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
|
|
609
|
+
.sc-section{display:flex;flex-direction:column;gap:8px;min-width:0;padding-top:12px;
|
|
610
|
+
border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
611
|
+
.sc-sectionHead{display:flex;flex-wrap:wrap;align-items:baseline;gap:8px;min-width:0}
|
|
612
|
+
.sc-sectionTitle{font-size:13px;font-weight:500;line-height:20px;color:var(--dsw-alias-label-primary)}
|
|
613
|
+
.sc-params{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr));gap:12px 16px;min-width:0}
|
|
614
|
+
.sc-param{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
615
|
+
.sc-paramHead{display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 8px;min-width:0}
|
|
616
|
+
.sc-paramLabel{min-width:0;font-size:12.5px;line-height:18px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
|
|
617
|
+
.sc-paramPath{min-width:0;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);
|
|
618
|
+
font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
|
|
619
|
+
.sc-paramCtl{display:flex;align-items:center;gap:8px;min-width:0}
|
|
620
|
+
.sc-switch{position:relative;display:inline-flex;align-items:center;flex:none;width:34px;height:20px;
|
|
621
|
+
padding:0;border:.5px solid var(--dsw-alias-border-l3);border-radius:999px;
|
|
622
|
+
background:var(--dsw-alias-bg-module-platform);cursor:pointer;transition:background-color .15s ease,border-color .15s ease}
|
|
623
|
+
.sc-switch::after{content:"";position:absolute;left:2px;top:2px;width:14px;height:14px;border-radius:50%;
|
|
624
|
+
background:var(--dsw-alias-switch-thumb);transition:transform .15s ease}
|
|
625
|
+
.sc-switch[aria-checked="true"]{background:var(--dsw-alias-state-business-primary);border-color:transparent}
|
|
626
|
+
.sc-switch[aria-checked="true"]::after{transform:translateX(14px)}
|
|
627
|
+
.sc-switch:disabled{opacity:.5;cursor:default}
|
|
628
|
+
|
|
629
|
+
/* 节点摘要 */
|
|
630
|
+
.sc-details{border-top:.5px solid var(--dsw-alias-border-l2);padding-top:10px;min-width:0}
|
|
631
|
+
.sc-detailsSummary{cursor:pointer;font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary)}
|
|
632
|
+
.sc-detailsSummary:hover{color:var(--dsw-alias-label-primary)}
|
|
633
|
+
.sc-nodeList{display:flex;flex-direction:column;gap:2px;margin:8px 0 0;padding:0;list-style:none;
|
|
634
|
+
max-height:220px;overflow-y:auto;font-size:12px;line-height:18px}
|
|
635
|
+
.sc-nodeItem{display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 8px;min-width:0;color:var(--dsw-alias-label-secondary)}
|
|
636
|
+
.sc-nodeId{flex:none;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}
|
|
637
|
+
.sc-nodeClass{min-width:0;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
|
|
638
|
+
.sc-nodeTitle{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere}
|
|
639
|
+
|
|
640
|
+
/* 运行 / 结果 */
|
|
641
|
+
.sc-runBar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0;padding-top:12px;
|
|
642
|
+
border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
643
|
+
.sc-runInfo{margin-left:auto;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;
|
|
644
|
+
font-variant-numeric:tabular-nums}
|
|
645
|
+
.sc-result{display:flex;flex-direction:column;gap:10px;min-width:0;padding-top:12px;
|
|
646
|
+
border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
647
|
+
.sc-resultHead{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:13px;font-weight:500;line-height:20px}
|
|
648
|
+
.sc-applied{display:flex;flex-direction:column;gap:6px;min-width:0}
|
|
649
|
+
.sc-nodeErrors{display:flex;flex-direction:column;gap:4px;min-width:0;padding:8px 10px;
|
|
650
|
+
border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);
|
|
651
|
+
background:var(--dsw-alias-bg-layer-1)}
|
|
652
|
+
.sc-images{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(150px,100%),1fr));gap:8px;min-width:0}
|
|
653
|
+
.sc-imageBtn{display:block;min-width:0;padding:0;cursor:zoom-in;overflow:hidden;
|
|
654
|
+
border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);
|
|
655
|
+
background:var(--dsw-alias-bg-layer-3)}
|
|
656
|
+
.sc-image{display:block;width:100%;height:auto}
|
|
657
|
+
.sc-runList{display:flex;flex-direction:column;min-width:0}
|
|
658
|
+
.sc-runRow{display:flex;flex-wrap:wrap;align-items:flex-start;gap:8px 12px;min-width:0;
|
|
659
|
+
padding:10px 0;border-bottom:.5px solid var(--dsw-alias-border-l2)}
|
|
660
|
+
.sc-runRow:last-child{border-bottom:0;padding-bottom:0}
|
|
661
|
+
.sc-runMain{display:flex;flex-direction:column;gap:3px;flex:1 1 200px;min-width:0}
|
|
662
|
+
.sc-runTitle{font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
663
|
+
.sc-runMeta{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 10px;min-width:0;
|
|
664
|
+
color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;font-variant-numeric:tabular-nums}
|
|
665
|
+
.sc-thumbRow{display:flex;flex-wrap:wrap;gap:6px;flex:none;max-width:100%}
|
|
666
|
+
.sc-thumbWrap{display:block;flex:none;width:44px;height:44px;padding:0;overflow:hidden;cursor:pointer;
|
|
667
|
+
border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);
|
|
668
|
+
background:var(--dsw-alias-bg-layer-3)}
|
|
669
|
+
.sc-thumb{display:block;width:100%;height:100%;object-fit:cover}
|
|
670
|
+
|
|
671
|
+
@media (max-width:560px){
|
|
672
|
+
.sc-head{padding-top:20px;padding-bottom:10px}
|
|
673
|
+
.sc-headActions{margin-left:0;width:100%}
|
|
674
|
+
.sc-cardHead{padding:10px 12px}
|
|
675
|
+
.sc-cardBody{padding:12px}
|
|
676
|
+
.sc-fieldLabel{flex-basis:100%;min-width:0;line-height:20px}
|
|
677
|
+
.sc-scroll{gap:12px}
|
|
678
|
+
}
|
|
679
|
+
@media (prefers-reduced-motion:reduce){
|
|
680
|
+
.sc-btn,.sc-chev,.sc-switch,.sc-switch::after{transition:none}
|
|
681
|
+
.sc-spinner{animation-duration:2.4s}
|
|
682
|
+
}
|
|
683
|
+
`
|
|
684
|
+
|
|
685
|
+
/* ── 通用工具 ────────────────────────────────────────────────────────── */
|
|
686
|
+
function fallbackT(key, params) {
|
|
687
|
+
const table = ZH[key] !== undefined ? ZH : EN
|
|
688
|
+
const template = table[key] !== undefined ? table[key] : key
|
|
689
|
+
if (!params) return template
|
|
690
|
+
return String(template).replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match))
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
function makeApiError(message, options) {
|
|
694
|
+
const error = new Error(message || 'request failed')
|
|
695
|
+
if (options) {
|
|
696
|
+
if (options.status !== undefined) error.status = options.status
|
|
697
|
+
if (options.code !== undefined) error.code = options.code
|
|
698
|
+
}
|
|
699
|
+
return error
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** 同源 JSON 请求:网络失败 / 非 2xx / json.ok===false 都抛结构化错误。 */
|
|
703
|
+
async function api(path, options) {
|
|
704
|
+
const opts = options || {}
|
|
705
|
+
let response
|
|
706
|
+
let timer = null
|
|
707
|
+
const timeoutMs = Number(opts.timeoutMs) > 0 ? Number(opts.timeoutMs) : 0
|
|
708
|
+
const controller = timeoutMs > 0 && typeof AbortController === 'function' ? new AbortController() : null
|
|
709
|
+
try {
|
|
710
|
+
const init = { method: opts.method || 'GET', credentials: 'same-origin' }
|
|
711
|
+
if (controller) {
|
|
712
|
+
init.signal = controller.signal
|
|
713
|
+
timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
714
|
+
}
|
|
715
|
+
if (opts.body !== undefined) {
|
|
716
|
+
init.headers = { 'content-type': 'application/json' }
|
|
717
|
+
init.body = JSON.stringify(opts.body)
|
|
718
|
+
}
|
|
719
|
+
response = await fetch(API + path, init)
|
|
720
|
+
} catch (cause) {
|
|
721
|
+
if (controller && controller.signal.aborted) {
|
|
722
|
+
throw makeApiError('', { code: 'TIMEOUT', status: 0 })
|
|
723
|
+
}
|
|
724
|
+
throw makeApiError('network', { code: 'NET' })
|
|
725
|
+
} finally {
|
|
726
|
+
if (timer !== null) clearTimeout(timer)
|
|
727
|
+
}
|
|
728
|
+
let text = ''
|
|
729
|
+
try {
|
|
730
|
+
text = await response.text()
|
|
731
|
+
} catch (cause) {
|
|
732
|
+
throw makeApiError('network', { code: 'NET' })
|
|
733
|
+
}
|
|
734
|
+
let data = null
|
|
735
|
+
if (text) {
|
|
736
|
+
try {
|
|
737
|
+
data = JSON.parse(text)
|
|
738
|
+
} catch (cause) {
|
|
739
|
+
data = null
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (!response.ok) {
|
|
743
|
+
throw makeApiError(data && data.error ? String(data.error) : '', { status: response.status })
|
|
744
|
+
}
|
|
745
|
+
if (data && data.ok === false && !opts.allowFail) {
|
|
746
|
+
throw makeApiError(String(data.error || ''), { status: response.status })
|
|
747
|
+
}
|
|
748
|
+
return data || {}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function humanError(error, t) {
|
|
752
|
+
if (!error) return t('error.network')
|
|
753
|
+
if (error.code === 'TIMEOUT') return t('error.timeout')
|
|
754
|
+
if (error.code === 'NET') return t('error.network')
|
|
755
|
+
const message = typeof error.message === 'string' ? error.message : ''
|
|
756
|
+
if (message && message !== 'request failed' && message !== 'network') return message
|
|
757
|
+
if (error.status) return t('error.http', { status: String(error.status) })
|
|
758
|
+
return message || t('error.network')
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function fmtDuration(ms) {
|
|
762
|
+
const value = Number(ms)
|
|
763
|
+
if (!Number.isFinite(value) || value < 0) return ''
|
|
764
|
+
if (value < 950) return Math.round(value) + 'ms'
|
|
765
|
+
if (value < 60000) return (value / 1000).toFixed(value < 10000 ? 1 : 0) + 's'
|
|
766
|
+
const minutes = Math.floor(value / 60000)
|
|
767
|
+
const seconds = Math.round((value % 60000) / 1000)
|
|
768
|
+
return minutes + 'm ' + (seconds < 10 ? '0' : '') + seconds + 's'
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function fmtTime(iso) {
|
|
772
|
+
if (!iso) return ''
|
|
773
|
+
const date = new Date(iso)
|
|
774
|
+
if (Number.isNaN(date.getTime())) return String(iso)
|
|
775
|
+
try {
|
|
776
|
+
return date.toLocaleString()
|
|
777
|
+
} catch (cause) {
|
|
778
|
+
return String(iso)
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function fmtBytes(bytes) {
|
|
783
|
+
const value = Number(bytes)
|
|
784
|
+
if (!Number.isFinite(value) || value < 0) return ''
|
|
785
|
+
if (value < 1024) return value + ' B'
|
|
786
|
+
if (value < 1024 * 1024) return (value / 1024).toFixed(1) + ' KB'
|
|
787
|
+
return (value / (1024 * 1024)).toFixed(1) + ' MB'
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function imageUrl(image) {
|
|
791
|
+
const filename = image && image.filename ? String(image.filename) : ''
|
|
792
|
+
if (!filename) return ''
|
|
793
|
+
const search = '?filename=' + encodeURIComponent(filename)
|
|
794
|
+
+ '&subfolder=' + encodeURIComponent(image && image.subfolder ? String(image.subfolder) : '')
|
|
795
|
+
+ '&type=' + encodeURIComponent(image && image.type ? String(image.type) : 'output')
|
|
796
|
+
return IMAGE_PATH + search
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function resultImageUrl(image) {
|
|
800
|
+
if (image && typeof image.url === 'string' && image.url) return image.url
|
|
801
|
+
return imageUrl(image)
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function openImage(url) {
|
|
805
|
+
if (!url || typeof window === 'undefined') return
|
|
806
|
+
try {
|
|
807
|
+
window.open(url, '_blank', 'noopener,noreferrer')
|
|
808
|
+
} catch (cause) {
|
|
809
|
+
/* 弹窗被拦截时静默;图片本身仍可在网格里看 */
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
async function copyText(text) {
|
|
814
|
+
try {
|
|
815
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
816
|
+
await navigator.clipboard.writeText(text)
|
|
817
|
+
return true
|
|
818
|
+
}
|
|
819
|
+
} catch (cause) {
|
|
820
|
+
/* 剪贴板不可用时静默(CONTRACT §7.1) */
|
|
821
|
+
}
|
|
822
|
+
return false
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function readFileText(file) {
|
|
826
|
+
if (typeof file.text === 'function') return file.text()
|
|
827
|
+
return new Promise((resolve, reject) => {
|
|
828
|
+
const reader = new FileReader()
|
|
829
|
+
reader.onload = () => resolve(String(reader.result || ''))
|
|
830
|
+
reader.onerror = () => reject(reader.error || new Error('read failed'))
|
|
831
|
+
reader.readAsText(file)
|
|
832
|
+
})
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
function normalizeState(data) {
|
|
836
|
+
const source = data && typeof data === 'object' ? data : {}
|
|
837
|
+
return {
|
|
838
|
+
baseUrl: typeof source.baseUrl === 'string' ? source.baseUrl : '',
|
|
839
|
+
timeoutSec: Number.isFinite(Number(source.timeoutSec)) ? Number(source.timeoutSec) : 300,
|
|
840
|
+
clientId: typeof source.clientId === 'string' ? source.clientId : '',
|
|
841
|
+
workflows: Array.isArray(source.workflows) ? source.workflows : [],
|
|
842
|
+
lastRuns: Array.isArray(source.lastRuns) ? source.lastRuns : [],
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
function sourceLabel(source, t) {
|
|
847
|
+
if (source === 'ui') return t('wf.sourceUi')
|
|
848
|
+
if (source === 'api') return t('wf.sourceApi')
|
|
849
|
+
if (source === 'server') return t('wf.sourceServer')
|
|
850
|
+
return source ? String(source) : ''
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function runStateLabel(state, t) {
|
|
854
|
+
if (state === 'done') return t('runs.stateDone')
|
|
855
|
+
if (state === 'error') return t('runs.stateError')
|
|
856
|
+
if (state === 'timeout') return t('runs.stateTimeout')
|
|
857
|
+
return t('runs.stateQueued')
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function runTone(state) {
|
|
861
|
+
if (state === 'done') return 'ok'
|
|
862
|
+
if (state === 'error') return 'error'
|
|
863
|
+
if (state === 'timeout') return 'warn'
|
|
864
|
+
return 'busy'
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
function pickCreated(response) {
|
|
868
|
+
const created = response && response.workflow
|
|
869
|
+
if (Array.isArray(created)) return created[0] || null
|
|
870
|
+
return created && typeof created === 'object' ? created : null
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function paramDefaults(params) {
|
|
874
|
+
const values = {}
|
|
875
|
+
for (const param of Array.isArray(params) ? params : []) {
|
|
876
|
+
if (param && typeof param.path === 'string') values[param.path] = param.value
|
|
877
|
+
}
|
|
878
|
+
return values
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function promptDefaults(workflow) {
|
|
882
|
+
const targets = workflow && workflow.promptTargets && typeof workflow.promptTargets === 'object'
|
|
883
|
+
? workflow.promptTargets
|
|
884
|
+
: {}
|
|
885
|
+
const params = Array.isArray(workflow && workflow.params) ? workflow.params : []
|
|
886
|
+
const read = (paths) => {
|
|
887
|
+
for (const path of Array.isArray(paths) ? paths : []) {
|
|
888
|
+
const param = params.find((item) => item && item.path === path)
|
|
889
|
+
if (param && typeof param.value === 'string') return param.value
|
|
890
|
+
}
|
|
891
|
+
return ''
|
|
892
|
+
}
|
|
893
|
+
return { positive: read(targets.positive), negative: read(targets.negative) }
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** 参数值 → POST /run 的 params 对象({ '节点id.输入名': 值 })。 */
|
|
897
|
+
function buildParamValues(params, values) {
|
|
898
|
+
const out = {}
|
|
899
|
+
for (const param of Array.isArray(params) ? params : []) {
|
|
900
|
+
if (!param || typeof param.path !== 'string') continue
|
|
901
|
+
const value = values[param.path]
|
|
902
|
+
if (value === undefined || value === null) continue
|
|
903
|
+
if (param.type === 'boolean') {
|
|
904
|
+
out[param.path] = Boolean(value)
|
|
905
|
+
continue
|
|
906
|
+
}
|
|
907
|
+
if (param.type === 'integer' || param.type === 'number') {
|
|
908
|
+
const text = String(value).trim()
|
|
909
|
+
if (text === '') continue
|
|
910
|
+
const number = Number(text)
|
|
911
|
+
if (!Number.isFinite(number)) continue
|
|
912
|
+
out[param.path] = number
|
|
913
|
+
continue
|
|
914
|
+
}
|
|
915
|
+
out[param.path] = value
|
|
916
|
+
}
|
|
917
|
+
return out
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function nodeErrorRows(nodeErrors) {
|
|
921
|
+
if (!nodeErrors || typeof nodeErrors !== 'object') return []
|
|
922
|
+
const rows = []
|
|
923
|
+
for (const id of Object.keys(nodeErrors)) {
|
|
924
|
+
const entry = nodeErrors[id]
|
|
925
|
+
const messages = []
|
|
926
|
+
if (entry && Array.isArray(entry.errors)) {
|
|
927
|
+
for (const item of entry.errors) {
|
|
928
|
+
if (item && item.message) messages.push(String(item.message))
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if (messages.length === 0) {
|
|
932
|
+
try {
|
|
933
|
+
messages.push(typeof entry === 'string' ? entry : JSON.stringify(entry))
|
|
934
|
+
} catch (cause) {
|
|
935
|
+
messages.push(String(entry))
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
rows.push({
|
|
939
|
+
id,
|
|
940
|
+
classType: entry && typeof entry.class_type === 'string' ? entry.class_type : '',
|
|
941
|
+
messages,
|
|
942
|
+
})
|
|
943
|
+
}
|
|
944
|
+
return rows
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function useAlive() {
|
|
948
|
+
const ref = useRef(true)
|
|
949
|
+
useEffect(() => {
|
|
950
|
+
ref.current = true
|
|
951
|
+
return () => {
|
|
952
|
+
ref.current = false
|
|
953
|
+
}
|
|
954
|
+
}, [])
|
|
955
|
+
return ref
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/** locale 切换时让整棵面板重新渲染(t() 本身由 locale 服务更新)。 */
|
|
959
|
+
function useLocaleTick(locale) {
|
|
960
|
+
const [, setVersion] = useState(0)
|
|
961
|
+
useEffect(() => {
|
|
962
|
+
if (!locale || typeof locale.subscribe !== 'function') return undefined
|
|
963
|
+
return locale.subscribe(() => setVersion((value) => value + 1))
|
|
964
|
+
}, [locale])
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/* ── 图标(内联 SVG,颜色一律 currentColor) ─────────────────────────── */
|
|
968
|
+
const ICONS = {
|
|
969
|
+
refresh: ['M20 12a8 8 0 1 1-2.34-5.66', 'M20 4.5v6h-6'],
|
|
970
|
+
chevron: ['M9.5 6.5L15 12l-5.5 5.5'],
|
|
971
|
+
copy: ['M9 9h9a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z', 'M6 15H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v1'],
|
|
972
|
+
check: ['M5 12.5L9.5 17L19 7'],
|
|
973
|
+
trash: ['M4.5 6.5h15', 'M9 6.5V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1.5', 'M6.5 6.5l.9 12a1 1 0 0 0 1 .9h7.2a1 1 0 0 0 1-.9l.9-12', 'M10 10.5v6', 'M14 10.5v6'],
|
|
974
|
+
pencil: ['M4.5 19.5l.7-4.2 9.9-9.9a2.1 2.1 0 0 1 3 3l-9.9 9.9z', 'M13.2 6.7l3.1 3.1'],
|
|
975
|
+
plus: ['M12 5v14', 'M5 12h14'],
|
|
976
|
+
back: ['M14.5 5.5L8 12l6.5 6.5'],
|
|
977
|
+
alert: ['M12 4.2L21 19.5H3z', 'M12 10v4.5', 'M12 17.2v.1'],
|
|
978
|
+
download: ['M12 4.5v9', 'M8.5 10L12 13.5L15.5 10', 'M5 16.5v2a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2'],
|
|
979
|
+
file: ['M13 4.5H7a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V9.5z', 'M13 4.5v5h5'],
|
|
980
|
+
server: ['M4.5 5.5h15v5h-15z', 'M4.5 13.5h15v5h-15z', 'M8 8h.1', 'M8 16h.1'],
|
|
981
|
+
stack: ['M12 4.5L19.5 8.5L12 12.5L4.5 8.5z', 'M4.5 12.5L12 16.5L19.5 12.5', 'M4.5 16.5L12 20.5L19.5 16.5'],
|
|
982
|
+
workflow: ['M6 6.5h3', 'M6 17.5h3', 'M15 6.5v11', 'M15 12h3.5'],
|
|
983
|
+
clock: ['M12 5a7 7 0 1 0 0 14a7 7 0 0 0 0-14z', 'M12 8.5V12l2.6 2'],
|
|
984
|
+
x: ['M6 6l12 12', 'M18 6L6 18'],
|
|
985
|
+
play: { solid: 'M8.5 5.4v13.2L19 12z' },
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
function Icon(props) {
|
|
989
|
+
const definition = ICONS[props.name]
|
|
990
|
+
let children = null
|
|
991
|
+
if (Array.isArray(definition)) {
|
|
992
|
+
children = definition.map((d, index) => h('path', { key: index, d }))
|
|
993
|
+
} else if (definition && definition.solid) {
|
|
994
|
+
children = h('path', { d: definition.solid, fill: 'currentColor', stroke: 'none' })
|
|
995
|
+
}
|
|
996
|
+
return h('svg', {
|
|
997
|
+
className: props.className || undefined,
|
|
998
|
+
width: props.size || 14,
|
|
999
|
+
height: props.size || 14,
|
|
1000
|
+
viewBox: '0 0 24 24',
|
|
1001
|
+
fill: 'none',
|
|
1002
|
+
stroke: 'currentColor',
|
|
1003
|
+
strokeWidth: 1.8,
|
|
1004
|
+
strokeLinecap: 'round',
|
|
1005
|
+
strokeLinejoin: 'round',
|
|
1006
|
+
'aria-hidden': 'true',
|
|
1007
|
+
focusable: 'false',
|
|
1008
|
+
style: props.style || undefined,
|
|
1009
|
+
}, children)
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/** 侧栏图标:props = { size, active }。 */
|
|
1013
|
+
function ComfyIcon(props) {
|
|
1014
|
+
const size = props && Number.isFinite(Number(props.size)) ? Number(props.size) : 20
|
|
1015
|
+
const active = props && props.active
|
|
1016
|
+
return h('svg', {
|
|
1017
|
+
width: size,
|
|
1018
|
+
height: size,
|
|
1019
|
+
viewBox: '0 0 24 24',
|
|
1020
|
+
fill: 'none',
|
|
1021
|
+
stroke: 'currentColor',
|
|
1022
|
+
strokeWidth: 1.7,
|
|
1023
|
+
strokeLinecap: 'round',
|
|
1024
|
+
strokeLinejoin: 'round',
|
|
1025
|
+
'aria-hidden': 'true',
|
|
1026
|
+
focusable: 'false',
|
|
1027
|
+
style: { display: 'block', opacity: active ? 1 : 0.82 },
|
|
1028
|
+
},
|
|
1029
|
+
h('path', { d: 'M7.8 7h4.6M7.8 17h4.6M15.4 7v10M15.4 12h3' }),
|
|
1030
|
+
h('circle', { cx: 6, cy: 7, r: 1.7, fill: 'currentColor', stroke: 'none' }),
|
|
1031
|
+
h('circle', { cx: 6, cy: 17, r: 1.7, fill: 'currentColor', stroke: 'none' }),
|
|
1032
|
+
h('circle', { cx: 20.2, cy: 12, r: 1.7, fill: 'currentColor', stroke: 'none' }))
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/* ── 小组件 ──────────────────────────────────────────────────────────── */
|
|
1036
|
+
function Spinner() {
|
|
1037
|
+
return h('span', { className: 'sc-spinner', 'aria-hidden': 'true' })
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
function Pill(props) {
|
|
1041
|
+
const tone = props.tone || 'neutral'
|
|
1042
|
+
return h('span', { className: 'sc-pill', 'data-tone': tone },
|
|
1043
|
+
h('span', { className: 'sc-dot', 'data-tone': tone, 'aria-hidden': 'true' }),
|
|
1044
|
+
props.children)
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
function InlineError(props) {
|
|
1048
|
+
return h('div', { className: 'sc-errorLine', role: 'alert' },
|
|
1049
|
+
h(Icon, { name: 'alert', size: 14 }),
|
|
1050
|
+
h('span', { className: 'sc-errorText' }, props.message),
|
|
1051
|
+
props.onRetry
|
|
1052
|
+
? h('button', { type: 'button', className: 'sc-linkBtn', onClick: props.onRetry }, props.t('common.retry'))
|
|
1053
|
+
: null)
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
function LoadingRow(props) {
|
|
1057
|
+
return h('div', { className: 'sc-loadingRow' },
|
|
1058
|
+
h(Spinner),
|
|
1059
|
+
h('span', null, props.label || props.t('common.loading')))
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
function WarnList(props) {
|
|
1063
|
+
const warnings = Array.isArray(props.warnings) ? props.warnings : []
|
|
1064
|
+
if (warnings.length === 0) return null
|
|
1065
|
+
return h('div', { className: 'sc-warnBox' },
|
|
1066
|
+
props.title ? h('div', { className: 'sc-noteTitle' }, props.title) : null,
|
|
1067
|
+
h('ul', { className: 'sc-noteList' }, warnings.map((warning, index) => h('li', { key: index }, String(warning)))))
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
function Switch(props) {
|
|
1071
|
+
return h('button', {
|
|
1072
|
+
type: 'button',
|
|
1073
|
+
role: 'switch',
|
|
1074
|
+
'aria-checked': props.checked ? 'true' : 'false',
|
|
1075
|
+
'aria-label': props.label || undefined,
|
|
1076
|
+
className: 'sc-switch',
|
|
1077
|
+
disabled: Boolean(props.disabled),
|
|
1078
|
+
onClick: () => props.onChange(!props.checked),
|
|
1079
|
+
})
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
function Card(props) {
|
|
1083
|
+
return h('section', { className: 'sc-card' },
|
|
1084
|
+
h('div', { className: 'sc-cardHead' },
|
|
1085
|
+
h('h2', { className: 'sc-cardTitle' },
|
|
1086
|
+
props.icon ? h(Icon, { name: props.icon, size: 16 }) : null,
|
|
1087
|
+
h('span', { className: 'sc-cardTitleText' }, props.title),
|
|
1088
|
+
props.count !== undefined && props.count !== null
|
|
1089
|
+
? h('span', { className: 'sc-cardCount' }, props.count)
|
|
1090
|
+
: null),
|
|
1091
|
+
props.actions ? h('div', { className: 'sc-cardActions' }, props.actions) : null),
|
|
1092
|
+
h('div', { className: 'sc-cardBody' }, props.children))
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
function Field(props) {
|
|
1096
|
+
return h('div', { className: 'sc-field' },
|
|
1097
|
+
props.htmlFor
|
|
1098
|
+
? h('label', { className: 'sc-fieldLabel', htmlFor: props.htmlFor }, props.label)
|
|
1099
|
+
: h('span', { className: 'sc-fieldLabel' }, props.label),
|
|
1100
|
+
h('div', { className: 'sc-fieldCtl' }, props.children))
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
/* ── 连接配置卡 ──────────────────────────────────────────────────────── */
|
|
1104
|
+
function ConnectionCard(props) {
|
|
1105
|
+
const t = props.t
|
|
1106
|
+
const data = props.data
|
|
1107
|
+
const test = props.test
|
|
1108
|
+
const alive = useAlive()
|
|
1109
|
+
const savedTimeout = String(data.timeoutSec === undefined || data.timeoutSec === null ? 300 : data.timeoutSec)
|
|
1110
|
+
const [url, setUrl] = useState(data.baseUrl || '')
|
|
1111
|
+
const [timeoutValue, setTimeoutValue] = useState(savedTimeout)
|
|
1112
|
+
const [baseline, setBaseline] = useState({ url: data.baseUrl || '', timeout: savedTimeout })
|
|
1113
|
+
const [saving, setSaving] = useState(false)
|
|
1114
|
+
const [saveError, setSaveError] = useState(null)
|
|
1115
|
+
const [saved, setSaved] = useState(false)
|
|
1116
|
+
|
|
1117
|
+
useEffect(() => {
|
|
1118
|
+
setBaseline({
|
|
1119
|
+
url: data.baseUrl || '',
|
|
1120
|
+
timeout: String(data.timeoutSec === undefined || data.timeoutSec === null ? 300 : data.timeoutSec),
|
|
1121
|
+
})
|
|
1122
|
+
}, [data.baseUrl, data.timeoutSec])
|
|
1123
|
+
|
|
1124
|
+
const dirty = url.trim() !== baseline.url || timeoutValue.trim() !== baseline.timeout
|
|
1125
|
+
|
|
1126
|
+
function editUrl(value) {
|
|
1127
|
+
setUrl(value)
|
|
1128
|
+
setSaveError(null)
|
|
1129
|
+
setSaved(false)
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
function editTimeout(value) {
|
|
1133
|
+
setTimeoutValue(value)
|
|
1134
|
+
setSaveError(null)
|
|
1135
|
+
setSaved(false)
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
async function save() {
|
|
1139
|
+
const nextUrl = url.trim()
|
|
1140
|
+
if (!nextUrl) {
|
|
1141
|
+
setSaveError(t('conn.urlRequired'))
|
|
1142
|
+
setSaved(false)
|
|
1143
|
+
return
|
|
1144
|
+
}
|
|
1145
|
+
let timeoutSec
|
|
1146
|
+
if (timeoutValue.trim() !== '') {
|
|
1147
|
+
const parsed = Number(timeoutValue.trim())
|
|
1148
|
+
if (!Number.isFinite(parsed) || parsed < 5 || parsed > 3600) {
|
|
1149
|
+
setSaveError(t('conn.timeoutInvalid'))
|
|
1150
|
+
setSaved(false)
|
|
1151
|
+
return
|
|
1152
|
+
}
|
|
1153
|
+
timeoutSec = parsed
|
|
1154
|
+
}
|
|
1155
|
+
setSaveError(null)
|
|
1156
|
+
setSaved(false)
|
|
1157
|
+
setSaving(true)
|
|
1158
|
+
try {
|
|
1159
|
+
const body = timeoutSec === undefined ? { baseUrl: nextUrl } : { baseUrl: nextUrl, timeoutSec }
|
|
1160
|
+
const response = await api('/config', { method: 'POST', body })
|
|
1161
|
+
if (!alive.current) return
|
|
1162
|
+
if (typeof response.baseUrl === 'string' && response.baseUrl) {
|
|
1163
|
+
setUrl(response.baseUrl)
|
|
1164
|
+
setBaseline({
|
|
1165
|
+
url: response.baseUrl,
|
|
1166
|
+
timeout: String(response.timeoutSec === undefined || response.timeoutSec === null ? baseline.timeout : response.timeoutSec),
|
|
1167
|
+
})
|
|
1168
|
+
}
|
|
1169
|
+
setSaved(true)
|
|
1170
|
+
props.onSaved()
|
|
1171
|
+
} catch (error) {
|
|
1172
|
+
if (alive.current) setSaveError(humanError(error, t))
|
|
1173
|
+
} finally {
|
|
1174
|
+
if (alive.current) setSaving(false)
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
let facts
|
|
1179
|
+
if (test.phase === 'loading') {
|
|
1180
|
+
facts = h(LoadingRow, { t, label: t('conn.testing') })
|
|
1181
|
+
} else if (test.phase === 'ok' && test.data) {
|
|
1182
|
+
const info = test.data
|
|
1183
|
+
const items = []
|
|
1184
|
+
if (Number.isFinite(Number(info.latencyMs))) {
|
|
1185
|
+
items.push(h('span', { key: 'latency', className: 'sc-fact' },
|
|
1186
|
+
h('span', { className: 'sc-factLabel' }, t('conn.latency')),
|
|
1187
|
+
h('span', { className: 'sc-factValue' }, Math.round(Number(info.latencyMs)) + 'ms')))
|
|
1188
|
+
}
|
|
1189
|
+
if (typeof info.comfyuiVersion === 'string' && info.comfyuiVersion) {
|
|
1190
|
+
items.push(h('span', { key: 'version', className: 'sc-fact' },
|
|
1191
|
+
h('span', { className: 'sc-factLabel' }, t('conn.version')),
|
|
1192
|
+
h('span', { className: 'sc-factValue' }, info.comfyuiVersion)))
|
|
1193
|
+
}
|
|
1194
|
+
if (typeof info.device === 'string' && info.device) {
|
|
1195
|
+
items.push(h('span', { key: 'device', className: 'sc-fact' },
|
|
1196
|
+
h('span', { className: 'sc-factLabel' }, t('conn.device')),
|
|
1197
|
+
h('span', { className: 'sc-factValue' }, info.device)))
|
|
1198
|
+
}
|
|
1199
|
+
facts = items.length > 0 ? h('div', { className: 'sc-facts' }, items) : h('p', { className: 'sc-muted' }, t('conn.connected'))
|
|
1200
|
+
} else if (test.phase === 'error') {
|
|
1201
|
+
facts = h(InlineError, {
|
|
1202
|
+
t,
|
|
1203
|
+
message: typeof test.error === 'string' && test.error ? test.error : t('conn.testFailed'),
|
|
1204
|
+
onRetry: props.onRetest,
|
|
1205
|
+
})
|
|
1206
|
+
} else {
|
|
1207
|
+
facts = h('p', { className: 'sc-muted' }, t('conn.unknown'))
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
return h(Card, { icon: 'server', title: t('conn.title') },
|
|
1211
|
+
h(Field, { label: t('conn.url'), htmlFor: 'sc-conn-url' },
|
|
1212
|
+
h('input', {
|
|
1213
|
+
id: 'sc-conn-url',
|
|
1214
|
+
className: 'sc-input',
|
|
1215
|
+
type: 'text',
|
|
1216
|
+
inputMode: 'url',
|
|
1217
|
+
placeholder: '127.0.0.1:8188',
|
|
1218
|
+
value: url,
|
|
1219
|
+
disabled: saving,
|
|
1220
|
+
onChange: (event) => editUrl(event.target.value),
|
|
1221
|
+
}),
|
|
1222
|
+
h('p', { className: 'sc-hint' }, t('conn.urlHint'))),
|
|
1223
|
+
h(Field, { label: t('conn.timeout'), htmlFor: 'sc-conn-timeout' },
|
|
1224
|
+
h('input', {
|
|
1225
|
+
id: 'sc-conn-timeout',
|
|
1226
|
+
className: 'sc-input sc-inputShort',
|
|
1227
|
+
type: 'number',
|
|
1228
|
+
min: 5,
|
|
1229
|
+
max: 3600,
|
|
1230
|
+
step: 1,
|
|
1231
|
+
value: timeoutValue,
|
|
1232
|
+
disabled: saving,
|
|
1233
|
+
onChange: (event) => editTimeout(event.target.value),
|
|
1234
|
+
}),
|
|
1235
|
+
h('p', { className: 'sc-hint' }, t('conn.timeoutHint'))),
|
|
1236
|
+
h('div', { className: 'sc-btnRow' },
|
|
1237
|
+
h('button', {
|
|
1238
|
+
type: 'button',
|
|
1239
|
+
className: 'sc-btn sc-btnPrimary',
|
|
1240
|
+
onClick: save,
|
|
1241
|
+
disabled: saving,
|
|
1242
|
+
'aria-busy': saving ? 'true' : 'false',
|
|
1243
|
+
}, saving ? h(Spinner) : null, saving ? t('conn.saving') : t('conn.saveTest')),
|
|
1244
|
+
dirty ? h('span', { className: 'sc-warnLine' }, t('conn.unsaved')) : null,
|
|
1245
|
+
saved && !dirty ? h('span', { className: 'sc-okLine' }, t('conn.saved')) : null),
|
|
1246
|
+
saveError ? h(InlineError, { t, message: saveError }) : null,
|
|
1247
|
+
facts)
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/* ── 模型库卡 ────────────────────────────────────────────────────────── */
|
|
1251
|
+
function ModelsCard(props) {
|
|
1252
|
+
const t = props.t
|
|
1253
|
+
const alive = useAlive()
|
|
1254
|
+
const seq = useRef(0)
|
|
1255
|
+
const [models, setModels] = useState({ phase: 'idle', data: null, error: null })
|
|
1256
|
+
const [expanded, setExpanded] = useState({})
|
|
1257
|
+
const [copied, setCopied] = useState(null)
|
|
1258
|
+
const [query, setQuery] = useState('')
|
|
1259
|
+
|
|
1260
|
+
async function load(refresh) {
|
|
1261
|
+
const requestId = seq.current + 1
|
|
1262
|
+
seq.current = requestId
|
|
1263
|
+
setModels((previous) => ({ phase: 'loading', data: previous.data, error: null }))
|
|
1264
|
+
try {
|
|
1265
|
+
const data = await api('/models' + (refresh ? '?refresh=1' : ''), { allowFail: true })
|
|
1266
|
+
if (requestId !== seq.current || !alive.current) return
|
|
1267
|
+
if (!data || data.ok === false) {
|
|
1268
|
+
setModels({ phase: 'error', data: null, error: (data && data.error) || t('models.error') })
|
|
1269
|
+
return
|
|
1270
|
+
}
|
|
1271
|
+
setModels({ phase: 'ok', data, error: null })
|
|
1272
|
+
setExpanded((previous) => {
|
|
1273
|
+
if (Object.keys(previous).length > 0) return previous
|
|
1274
|
+
const next = {}
|
|
1275
|
+
const categories = Array.isArray(data.categories) ? data.categories : []
|
|
1276
|
+
for (const category of categories.slice(0, 2)) {
|
|
1277
|
+
if (category && category.id) next[category.id] = true
|
|
1278
|
+
}
|
|
1279
|
+
return next
|
|
1280
|
+
})
|
|
1281
|
+
} catch (error) {
|
|
1282
|
+
if (requestId !== seq.current || !alive.current) return
|
|
1283
|
+
setModels({ phase: 'error', data: null, error: humanError(error, t) })
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
useEffect(() => {
|
|
1288
|
+
if (!props.ready) return undefined
|
|
1289
|
+
load(false)
|
|
1290
|
+
return undefined
|
|
1291
|
+
}, [props.ready, props.baseUrl])
|
|
1292
|
+
|
|
1293
|
+
useEffect(() => {
|
|
1294
|
+
if (!copied) return undefined
|
|
1295
|
+
const timer = setTimeout(() => setCopied(null), 1200)
|
|
1296
|
+
return () => clearTimeout(timer)
|
|
1297
|
+
}, [copied])
|
|
1298
|
+
|
|
1299
|
+
async function copyName(name) {
|
|
1300
|
+
const ok = await copyText(name)
|
|
1301
|
+
if (ok && alive.current) setCopied(name)
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
function toggle(categoryId) {
|
|
1305
|
+
setExpanded((previous) => ({ ...previous, [categoryId]: !previous[categoryId] }))
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
const loading = models.phase === 'loading'
|
|
1309
|
+
const categories = models.phase === 'ok' && models.data && Array.isArray(models.data.categories)
|
|
1310
|
+
? models.data.categories
|
|
1311
|
+
: []
|
|
1312
|
+
const total = models.phase === 'ok' && models.data && Number.isFinite(Number(models.data.total))
|
|
1313
|
+
? Number(models.data.total)
|
|
1314
|
+
: null
|
|
1315
|
+
|
|
1316
|
+
let body
|
|
1317
|
+
if (models.phase === 'error') {
|
|
1318
|
+
body = h(InlineError, { t, message: models.error, onRetry: () => load(true) })
|
|
1319
|
+
} else if (models.phase === 'idle' || (loading && !models.data)) {
|
|
1320
|
+
body = h(LoadingRow, { t, label: t('models.loading') })
|
|
1321
|
+
} else if (categories.length === 0 || total === 0) {
|
|
1322
|
+
body = h('div', { className: 'sc-emptyState' },
|
|
1323
|
+
h('div', { className: 'sc-emptyIcon' }, h(Icon, { name: 'stack', size: 22 })),
|
|
1324
|
+
h('p', { className: 'sc-emptyTitle' }, t('models.empty')),
|
|
1325
|
+
props.baseUrl ? null : h('button', {
|
|
1326
|
+
type: 'button',
|
|
1327
|
+
className: 'sc-btn sc-btnPrimary',
|
|
1328
|
+
onClick: props.onOpenConnection,
|
|
1329
|
+
}, t('conn.configureCta')))
|
|
1330
|
+
} else {
|
|
1331
|
+
const items = []
|
|
1332
|
+
const q = query.trim().toLowerCase()
|
|
1333
|
+
const visibleCategories = q
|
|
1334
|
+
? categories
|
|
1335
|
+
.map((category) => ({
|
|
1336
|
+
...category,
|
|
1337
|
+
files: (category && Array.isArray(category.files) ? category.files : [])
|
|
1338
|
+
.filter((file) => String(file).toLowerCase().includes(q)),
|
|
1339
|
+
}))
|
|
1340
|
+
.filter((category) => category.files.length > 0)
|
|
1341
|
+
: categories
|
|
1342
|
+
if (Array.isArray(models.data.warnings) && models.data.warnings.length > 0) {
|
|
1343
|
+
items.push(h(WarnList, { key: 'warnings', warnings: models.data.warnings, title: t('wf.importWarnings') }))
|
|
1344
|
+
}
|
|
1345
|
+
items.push(h('div', { key: 'toolbar', className: 'sc-toolbar' },
|
|
1346
|
+
h('input', {
|
|
1347
|
+
className: 'sc-input sc-search',
|
|
1348
|
+
type: 'search',
|
|
1349
|
+
placeholder: t('models.search'),
|
|
1350
|
+
'aria-label': t('models.search'),
|
|
1351
|
+
value: query,
|
|
1352
|
+
onChange: (event) => setQuery(event.target.value),
|
|
1353
|
+
})))
|
|
1354
|
+
if (q && visibleCategories.length === 0) {
|
|
1355
|
+
items.push(h('p', { key: 'noMatch', className: 'sc-empty' }, t('models.noMatch')))
|
|
1356
|
+
} else {
|
|
1357
|
+
items.push(h('div', { key: 'categories', className: 'sc-catList' }, visibleCategories.map((category) => {
|
|
1358
|
+
const id = category && category.id ? String(category.id) : ''
|
|
1359
|
+
const files = category && Array.isArray(category.files) ? category.files : []
|
|
1360
|
+
const open = Boolean(expanded[id]) || q.length > 0
|
|
1361
|
+
return h('div', { key: id || category.label, className: 'sc-cat' },
|
|
1362
|
+
h('button', {
|
|
1363
|
+
type: 'button',
|
|
1364
|
+
className: 'sc-catHead',
|
|
1365
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
1366
|
+
'aria-label': (open ? t('models.collapse') : t('models.expand')) + ': ' + String((category && category.label) || id),
|
|
1367
|
+
onClick: () => toggle(id),
|
|
1368
|
+
},
|
|
1369
|
+
h(Icon, {
|
|
1370
|
+
name: 'chevron',
|
|
1371
|
+
size: 12,
|
|
1372
|
+
className: 'sc-chev',
|
|
1373
|
+
style: { transform: open ? 'rotate(90deg)' : 'none' },
|
|
1374
|
+
}),
|
|
1375
|
+
h('span', { className: 'sc-catLabel' }, (category && category.label) || id),
|
|
1376
|
+
h('span', { className: 'sc-catCount' }, t('models.files', { n: String(files.length) }))),
|
|
1377
|
+
open
|
|
1378
|
+
? h('div', { className: 'sc-files' }, files.map((file) => {
|
|
1379
|
+
const name = String(file)
|
|
1380
|
+
const isCopied = copied === name
|
|
1381
|
+
return h('button', {
|
|
1382
|
+
key: name,
|
|
1383
|
+
type: 'button',
|
|
1384
|
+
className: 'sc-file' + (isCopied ? ' sc-fileDone' : ''),
|
|
1385
|
+
title: t('models.copy') + ': ' + name,
|
|
1386
|
+
onClick: () => copyName(name),
|
|
1387
|
+
},
|
|
1388
|
+
h('span', { className: 'sc-fileName' }, name),
|
|
1389
|
+
isCopied
|
|
1390
|
+
? h('span', { className: 'sc-fileCopied' }, t('models.copied'))
|
|
1391
|
+
: h(Icon, { name: 'copy', size: 12 }))
|
|
1392
|
+
}))
|
|
1393
|
+
: null)
|
|
1394
|
+
})))
|
|
1395
|
+
}
|
|
1396
|
+
body = items
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
return h(Card, {
|
|
1400
|
+
icon: 'stack',
|
|
1401
|
+
title: t('models.title'),
|
|
1402
|
+
count: total !== null ? t('models.total', { n: String(total) }) : null,
|
|
1403
|
+
actions: [
|
|
1404
|
+
h('button', {
|
|
1405
|
+
key: 'refresh',
|
|
1406
|
+
type: 'button',
|
|
1407
|
+
className: 'sc-btn',
|
|
1408
|
+
onClick: () => load(true),
|
|
1409
|
+
disabled: loading,
|
|
1410
|
+
'aria-busy': loading ? 'true' : 'false',
|
|
1411
|
+
}, loading ? h(Spinner) : h(Icon, { name: 'refresh' }), t('models.refresh')),
|
|
1412
|
+
],
|
|
1413
|
+
}, body)
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/* ── 工作流卡(列表 / 详情两态) ─────────────────────────────────────── */
|
|
1417
|
+
function WorkflowsCard(props) {
|
|
1418
|
+
const t = props.t
|
|
1419
|
+
const workflows = Array.isArray(props.workflows) ? props.workflows : []
|
|
1420
|
+
const alive = useAlive()
|
|
1421
|
+
const [view, setView] = useState({ kind: 'list' })
|
|
1422
|
+
const [renaming, setRenaming] = useState(null)
|
|
1423
|
+
const [busyId, setBusyId] = useState(null)
|
|
1424
|
+
const [actionError, setActionError] = useState(null)
|
|
1425
|
+
const [notice, setNotice] = useState(null)
|
|
1426
|
+
const [importOpen, setImportOpen] = useState(false)
|
|
1427
|
+
const [importText, setImportText] = useState('')
|
|
1428
|
+
const [importName, setImportName] = useState('')
|
|
1429
|
+
const [importing, setImporting] = useState(false)
|
|
1430
|
+
const [importError, setImportError] = useState(null)
|
|
1431
|
+
const [importResult, setImportResult] = useState(null)
|
|
1432
|
+
const [dragging, setDragging] = useState(false)
|
|
1433
|
+
const [serverOpen, setServerOpen] = useState(false)
|
|
1434
|
+
const [server, setServer] = useState({ phase: 'idle', items: [], error: null })
|
|
1435
|
+
const [serverBusy, setServerBusy] = useState(null)
|
|
1436
|
+
const [serverError, setServerError] = useState(null)
|
|
1437
|
+
const [serverResult, setServerResult] = useState(null)
|
|
1438
|
+
|
|
1439
|
+
function openDetail(workflow) {
|
|
1440
|
+
setActionError(null)
|
|
1441
|
+
setNotice(null)
|
|
1442
|
+
setView({ kind: 'detail', id: workflow.id, name: workflow.name })
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
function editImportText(value) {
|
|
1446
|
+
setImportText(value)
|
|
1447
|
+
setImportError(null)
|
|
1448
|
+
setImportResult(null)
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
function editImportName(value) {
|
|
1452
|
+
setImportName(value)
|
|
1453
|
+
setImportError(null)
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function toggleImport() {
|
|
1457
|
+
setImportOpen((previous) => !previous)
|
|
1458
|
+
setImportError(null)
|
|
1459
|
+
setImportResult(null)
|
|
1460
|
+
setActionError(null)
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
function autoImportName() {
|
|
1464
|
+
const explicit = importName.trim()
|
|
1465
|
+
if (explicit) return explicit
|
|
1466
|
+
const stamp = new Date().toISOString().slice(0, 19).replace(/[:T]/g, '-')
|
|
1467
|
+
return 'workflow-' + stamp
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
async function doImport(textOverride) {
|
|
1471
|
+
const json = String(textOverride === undefined ? importText : textOverride).trim()
|
|
1472
|
+
if (!json) {
|
|
1473
|
+
setImportError(t('wf.importNeedJson'))
|
|
1474
|
+
return
|
|
1475
|
+
}
|
|
1476
|
+
const name = autoImportName()
|
|
1477
|
+
setImportError(null)
|
|
1478
|
+
setImportResult(null)
|
|
1479
|
+
setNotice({ tone: 'ok', text: t('wf.importing') })
|
|
1480
|
+
setImporting(true)
|
|
1481
|
+
try {
|
|
1482
|
+
const response = await api('/workflows', {
|
|
1483
|
+
method: 'POST',
|
|
1484
|
+
body: { action: 'import', name, json },
|
|
1485
|
+
timeoutMs: 60000,
|
|
1486
|
+
})
|
|
1487
|
+
if (!alive.current) return
|
|
1488
|
+
setNotice({ tone: 'ok', text: t('wf.importedAs', { name: (response && response.workflow && response.workflow.name) || name }) })
|
|
1489
|
+
setImportResult({
|
|
1490
|
+
text: t('wf.importOk'),
|
|
1491
|
+
warnings: Array.isArray(response.warnings) ? response.warnings : [],
|
|
1492
|
+
})
|
|
1493
|
+
setImportText('')
|
|
1494
|
+
setImportName('')
|
|
1495
|
+
props.onChanged()
|
|
1496
|
+
const created = pickCreated(response)
|
|
1497
|
+
if (created && created.id) setView({ kind: 'detail', id: created.id, name: created.name })
|
|
1498
|
+
} catch (error) {
|
|
1499
|
+
if (alive.current) {
|
|
1500
|
+
setNotice(null)
|
|
1501
|
+
setImportError(humanError(error, t))
|
|
1502
|
+
}
|
|
1503
|
+
} finally {
|
|
1504
|
+
if (alive.current) setImporting(false)
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
async function readWorkflowFile(file) {
|
|
1509
|
+
if (!file) return
|
|
1510
|
+
setImportError(null)
|
|
1511
|
+
setImportResult(null)
|
|
1512
|
+
if (Number(file.size) > IMPORT_LIMIT_BYTES) {
|
|
1513
|
+
setImportError(t('wf.importFileTooBig'))
|
|
1514
|
+
return
|
|
1515
|
+
}
|
|
1516
|
+
try {
|
|
1517
|
+
const text = await readFileText(file)
|
|
1518
|
+
if (!alive.current) return
|
|
1519
|
+
setImportText(text)
|
|
1520
|
+
if (!importName.trim()) setImportName(String(file.name || '').replace(/\.json$/i, ''))
|
|
1521
|
+
} catch (cause) {
|
|
1522
|
+
if (alive.current) setImportError(t('wf.importFileError'))
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
function onDrop(event) {
|
|
1527
|
+
event.preventDefault()
|
|
1528
|
+
setDragging(false)
|
|
1529
|
+
const file = event.dataTransfer && event.dataTransfer.files ? event.dataTransfer.files[0] : null
|
|
1530
|
+
if (file) readWorkflowFile(file)
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
function startRename(workflow) {
|
|
1534
|
+
setActionError(null)
|
|
1535
|
+
setNotice(null)
|
|
1536
|
+
setRenaming({ id: workflow.id, name: workflow.name })
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
async function saveRename() {
|
|
1540
|
+
if (!renaming) return
|
|
1541
|
+
const name = renaming.name.trim()
|
|
1542
|
+
if (!name) {
|
|
1543
|
+
setActionError(t('wf.renameEmpty'))
|
|
1544
|
+
return
|
|
1545
|
+
}
|
|
1546
|
+
setActionError(null)
|
|
1547
|
+
setBusyId(renaming.id)
|
|
1548
|
+
try {
|
|
1549
|
+
await api('/workflows', { method: 'POST', body: { action: 'rename', id: renaming.id, name } })
|
|
1550
|
+
if (!alive.current) return
|
|
1551
|
+
setRenaming(null)
|
|
1552
|
+
setNotice({ tone: 'ok', text: t('wf.renamedOk') })
|
|
1553
|
+
props.onChanged()
|
|
1554
|
+
} catch (error) {
|
|
1555
|
+
if (alive.current) setActionError(humanError(error, t))
|
|
1556
|
+
} finally {
|
|
1557
|
+
if (alive.current) setBusyId(null)
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
async function removeWorkflow(workflow) {
|
|
1562
|
+
if (typeof window !== 'undefined' && typeof window.confirm === 'function' && !window.confirm(t('wf.deleteConfirm'))) {
|
|
1563
|
+
return
|
|
1564
|
+
}
|
|
1565
|
+
setActionError(null)
|
|
1566
|
+
setNotice(null)
|
|
1567
|
+
setBusyId(workflow.id)
|
|
1568
|
+
try {
|
|
1569
|
+
await api('/workflows', { method: 'POST', body: { action: 'delete', id: workflow.id } })
|
|
1570
|
+
if (!alive.current) return
|
|
1571
|
+
setNotice({ tone: 'ok', text: t('wf.deletedOk') })
|
|
1572
|
+
props.onChanged()
|
|
1573
|
+
} catch (error) {
|
|
1574
|
+
if (alive.current) setActionError(humanError(error, t))
|
|
1575
|
+
} finally {
|
|
1576
|
+
if (alive.current) setBusyId(null)
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
async function loadServer() {
|
|
1581
|
+
setServer({ phase: 'loading', items: [], error: null })
|
|
1582
|
+
try {
|
|
1583
|
+
const data = await api('/server-workflows', { allowFail: true, timeoutMs: 25000 })
|
|
1584
|
+
if (!alive.current) return
|
|
1585
|
+
if (!data || data.ok === false) {
|
|
1586
|
+
setServer({ phase: 'error', items: [], error: (data && data.error) || t('wf.serverError') })
|
|
1587
|
+
return
|
|
1588
|
+
}
|
|
1589
|
+
setServer({ phase: 'ok', items: Array.isArray(data.items) ? data.items : [], error: null })
|
|
1590
|
+
} catch (error) {
|
|
1591
|
+
if (alive.current) setServer({ phase: 'error', items: [], error: humanError(error, t) })
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
function toggleServer() {
|
|
1596
|
+
const next = !serverOpen
|
|
1597
|
+
setServerOpen(next)
|
|
1598
|
+
setServerError(null)
|
|
1599
|
+
setServerResult(null)
|
|
1600
|
+
setActionError(null)
|
|
1601
|
+
if (next && server.phase !== 'ok' && server.phase !== 'loading') loadServer()
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
async function importServer(item) {
|
|
1605
|
+
setServerError(null)
|
|
1606
|
+
setServerResult(null)
|
|
1607
|
+
setNotice({ tone: 'ok', text: t('wf.importing') })
|
|
1608
|
+
setServerBusy(item.path)
|
|
1609
|
+
try {
|
|
1610
|
+
const response = await api('/server-workflows', {
|
|
1611
|
+
method: 'POST',
|
|
1612
|
+
body: { action: 'import', path: item.path },
|
|
1613
|
+
timeoutMs: 60000,
|
|
1614
|
+
})
|
|
1615
|
+
if (!alive.current) return
|
|
1616
|
+
setNotice({ tone: 'ok', text: t('wf.importedAs', { name: (response && response.workflow && response.workflow.name) || item.name || item.path || '' }) })
|
|
1617
|
+
setServerResult({
|
|
1618
|
+
text: t('wf.importOk'),
|
|
1619
|
+
warnings: Array.isArray(response.warnings) ? response.warnings : [],
|
|
1620
|
+
})
|
|
1621
|
+
props.onChanged()
|
|
1622
|
+
const created = pickCreated(response)
|
|
1623
|
+
if (created && created.id) setView({ kind: 'detail', id: created.id, name: created.name })
|
|
1624
|
+
} catch (error) {
|
|
1625
|
+
if (alive.current) {
|
|
1626
|
+
setNotice(null)
|
|
1627
|
+
setServerError(humanError(error, t))
|
|
1628
|
+
}
|
|
1629
|
+
} finally {
|
|
1630
|
+
if (alive.current) setServerBusy(null)
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
if (view.kind === 'detail') {
|
|
1635
|
+
return h(WorkflowDetail, {
|
|
1636
|
+
key: view.id,
|
|
1637
|
+
id: view.id,
|
|
1638
|
+
fallbackName: view.name,
|
|
1639
|
+
t,
|
|
1640
|
+
onBack: () => setView({ kind: 'list' }),
|
|
1641
|
+
onChanged: props.onChanged,
|
|
1642
|
+
})
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
const actions = [
|
|
1646
|
+
h('button', {
|
|
1647
|
+
key: 'import',
|
|
1648
|
+
type: 'button',
|
|
1649
|
+
className: 'sc-btn sc-btnPrimary',
|
|
1650
|
+
onClick: toggleImport,
|
|
1651
|
+
'aria-expanded': importOpen ? 'true' : 'false',
|
|
1652
|
+
}, h(Icon, { name: 'plus', size: 13 }), t('wf.importWorkflow')),
|
|
1653
|
+
h('button', {
|
|
1654
|
+
key: 'server',
|
|
1655
|
+
type: 'button',
|
|
1656
|
+
className: 'sc-btn',
|
|
1657
|
+
onClick: toggleServer,
|
|
1658
|
+
'aria-expanded': serverOpen ? 'true' : 'false',
|
|
1659
|
+
}, h(Icon, { name: 'download', size: 13 }), t('wf.fromServer')),
|
|
1660
|
+
]
|
|
1661
|
+
|
|
1662
|
+
const body = []
|
|
1663
|
+
if (importOpen) {
|
|
1664
|
+
body.push(h('div', { key: 'importPanel', className: 'sc-import' },
|
|
1665
|
+
h(Field, { label: t('wf.import'), htmlFor: 'sc-import-json' },
|
|
1666
|
+
h('textarea', {
|
|
1667
|
+
id: 'sc-import-json',
|
|
1668
|
+
className: 'sc-textarea' + (dragging ? ' sc-dropActive' : ''),
|
|
1669
|
+
rows: 6,
|
|
1670
|
+
spellCheck: false,
|
|
1671
|
+
placeholder: t('wf.importPlaceholder'),
|
|
1672
|
+
value: importText,
|
|
1673
|
+
onChange: (event) => editImportText(event.target.value),
|
|
1674
|
+
onDragOver: (event) => {
|
|
1675
|
+
event.preventDefault()
|
|
1676
|
+
setDragging(true)
|
|
1677
|
+
},
|
|
1678
|
+
onDragLeave: () => setDragging(false),
|
|
1679
|
+
onDrop: onDrop,
|
|
1680
|
+
}),
|
|
1681
|
+
h('p', { className: 'sc-hint' }, t('wf.importDropHint'))),
|
|
1682
|
+
h(Field, { label: t('wf.importName'), htmlFor: 'sc-import-name' },
|
|
1683
|
+
h('input', {
|
|
1684
|
+
id: 'sc-import-name',
|
|
1685
|
+
className: 'sc-input',
|
|
1686
|
+
type: 'text',
|
|
1687
|
+
placeholder: t('wf.importNamePlaceholder'),
|
|
1688
|
+
value: importName,
|
|
1689
|
+
onChange: (event) => editImportName(event.target.value),
|
|
1690
|
+
})),
|
|
1691
|
+
h('div', { className: 'sc-btnRow' },
|
|
1692
|
+
h('button', {
|
|
1693
|
+
type: 'button',
|
|
1694
|
+
className: 'sc-btn sc-btnPrimary',
|
|
1695
|
+
onClick: () => doImport(),
|
|
1696
|
+
disabled: importing,
|
|
1697
|
+
'aria-busy': importing ? 'true' : 'false',
|
|
1698
|
+
}, importing ? h(Spinner) : null, importing ? t('wf.importing') : t('wf.import')),
|
|
1699
|
+
h('label', { className: 'sc-btn sc-fileLabel' },
|
|
1700
|
+
h(Icon, { name: 'file', size: 13 }),
|
|
1701
|
+
t('wf.importFromFile'),
|
|
1702
|
+
h('input', {
|
|
1703
|
+
type: 'file',
|
|
1704
|
+
accept: 'application/json,.json',
|
|
1705
|
+
className: 'sc-srOnly',
|
|
1706
|
+
onChange: (event) => {
|
|
1707
|
+
const file = event.target.files ? event.target.files[0] : null
|
|
1708
|
+
readWorkflowFile(file)
|
|
1709
|
+
event.target.value = ''
|
|
1710
|
+
},
|
|
1711
|
+
})),
|
|
1712
|
+
h('button', {
|
|
1713
|
+
type: 'button',
|
|
1714
|
+
className: 'sc-btn',
|
|
1715
|
+
onClick: () => {
|
|
1716
|
+
setImportOpen(false)
|
|
1717
|
+
setImportError(null)
|
|
1718
|
+
setImportResult(null)
|
|
1719
|
+
},
|
|
1720
|
+
}, t('common.cancel'))),
|
|
1721
|
+
importError ? h(InlineError, { t, message: importError }) : null,
|
|
1722
|
+
importResult
|
|
1723
|
+
? h('div', { className: 'sc-warnBox' },
|
|
1724
|
+
h('p', { className: 'sc-okLine' }, importResult.text),
|
|
1725
|
+
h(WarnList, { warnings: importResult.warnings, title: t('wf.importWarnings') }))
|
|
1726
|
+
: null))
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
if (serverOpen) {
|
|
1730
|
+
let serverBody
|
|
1731
|
+
if (server.phase === 'loading') {
|
|
1732
|
+
serverBody = h(LoadingRow, { t, label: t('wf.serverLoading') })
|
|
1733
|
+
} else if (server.phase === 'error') {
|
|
1734
|
+
serverBody = h('div', { className: 'sc-stack' },
|
|
1735
|
+
h(InlineError, { t, message: server.error, onRetry: loadServer }),
|
|
1736
|
+
h('p', { className: 'sc-hint' }, t('wf.serverUnsupported')))
|
|
1737
|
+
} else if (server.items.length === 0) {
|
|
1738
|
+
serverBody = h('p', { className: 'sc-empty' }, t('wf.serverEmpty'))
|
|
1739
|
+
} else {
|
|
1740
|
+
serverBody = h('div', { className: 'sc-serverList' }, server.items.map((item, index) => {
|
|
1741
|
+
const path = typeof item.path === 'string' ? item.path : ''
|
|
1742
|
+
const busy = serverBusy === path
|
|
1743
|
+
const meta = []
|
|
1744
|
+
if (item.size !== undefined) meta.push(fmtBytes(item.size))
|
|
1745
|
+
if (item.modified) meta.push(fmtTime(item.modified))
|
|
1746
|
+
return h('div', { key: path || index, className: 'sc-serverRow' },
|
|
1747
|
+
h('div', { className: 'sc-serverMain' },
|
|
1748
|
+
h('span', { className: 'sc-serverName' }, item.name || path),
|
|
1749
|
+
h('span', { className: 'sc-serverPath' }, path + (meta.length > 0 ? ' · ' + meta.join(' · ') : ''))),
|
|
1750
|
+
h('button', {
|
|
1751
|
+
type: 'button',
|
|
1752
|
+
className: 'sc-btn',
|
|
1753
|
+
disabled: serverBusy !== null,
|
|
1754
|
+
'aria-busy': busy ? 'true' : 'false',
|
|
1755
|
+
onClick: () => importServer(item),
|
|
1756
|
+
}, busy ? h(Spinner) : null, busy ? t('wf.importing') : t('wf.import')))
|
|
1757
|
+
}))
|
|
1758
|
+
}
|
|
1759
|
+
body.push(h('div', { key: 'serverPanel', className: 'sc-import' },
|
|
1760
|
+
h('div', { className: 'sc-sectionHead' },
|
|
1761
|
+
h('span', { className: 'sc-sectionTitle' }, t('wf.serverListTitle')),
|
|
1762
|
+
h('button', {
|
|
1763
|
+
type: 'button',
|
|
1764
|
+
className: 'sc-iconBtn',
|
|
1765
|
+
title: t('models.refresh'),
|
|
1766
|
+
'aria-label': t('models.refresh'),
|
|
1767
|
+
onClick: loadServer,
|
|
1768
|
+
disabled: server.phase === 'loading',
|
|
1769
|
+
}, h(Icon, { name: 'refresh', size: 13 }))),
|
|
1770
|
+
serverError ? h(InlineError, { t, message: serverError }) : null,
|
|
1771
|
+
serverBody,
|
|
1772
|
+
serverResult
|
|
1773
|
+
? h('div', { className: 'sc-warnBox' },
|
|
1774
|
+
h('p', { className: 'sc-okLine' }, serverResult.text),
|
|
1775
|
+
h(WarnList, { warnings: serverResult.warnings, title: t('wf.importWarnings') }))
|
|
1776
|
+
: null,
|
|
1777
|
+
h('div', { className: 'sc-btnRow' },
|
|
1778
|
+
h('button', {
|
|
1779
|
+
type: 'button',
|
|
1780
|
+
className: 'sc-btn',
|
|
1781
|
+
onClick: () => {
|
|
1782
|
+
setServerOpen(false)
|
|
1783
|
+
setServerError(null)
|
|
1784
|
+
setServerResult(null)
|
|
1785
|
+
},
|
|
1786
|
+
}, t('common.close')))))
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
if (notice) body.push(h('p', { key: 'notice', className: 'sc-okLine', role: 'status' }, notice.text))
|
|
1790
|
+
if (actionError) body.push(h(InlineError, { key: 'actionError', t, message: actionError }))
|
|
1791
|
+
|
|
1792
|
+
if (workflows.length === 0) {
|
|
1793
|
+
body.push(h('div', { key: 'empty', className: 'sc-emptyState' },
|
|
1794
|
+
h('div', { className: 'sc-emptyIcon' }, h(Icon, { name: 'workflow', size: 22 })),
|
|
1795
|
+
h('p', { className: 'sc-emptyTitle' }, t('wf.emptyTitle')),
|
|
1796
|
+
h('p', { className: 'sc-emptyHint' }, t('wf.emptyHint')),
|
|
1797
|
+
h('div', { className: 'sc-emptyActions' },
|
|
1798
|
+
h('button', {
|
|
1799
|
+
type: 'button',
|
|
1800
|
+
className: 'sc-btn sc-btnPrimary',
|
|
1801
|
+
onClick: toggleImport,
|
|
1802
|
+
}, h(Icon, { name: 'plus', size: 13 }), t('wf.importWorkflow')),
|
|
1803
|
+
h('button', {
|
|
1804
|
+
type: 'button',
|
|
1805
|
+
className: 'sc-btn',
|
|
1806
|
+
onClick: toggleServer,
|
|
1807
|
+
}, h(Icon, { name: 'download', size: 13 }), t('wf.fromServer')))))
|
|
1808
|
+
} else {
|
|
1809
|
+
body.push(h('div', { key: 'list', className: 'sc-wfList' }, workflows.map((workflow) => {
|
|
1810
|
+
const busy = busyId === workflow.id
|
|
1811
|
+
const isRenaming = Boolean(renaming && renaming.id === workflow.id)
|
|
1812
|
+
const meta = [
|
|
1813
|
+
h('span', { key: 'source', className: 'sc-badge', title: t('wf.source') }, sourceLabel(workflow.source, t)),
|
|
1814
|
+
h('span', { key: 'nodes' }, t('wf.nodes', { n: String(workflow.nodeCount === undefined ? 0 : workflow.nodeCount) })),
|
|
1815
|
+
h('span', { key: 'params' }, t('wf.params', { n: String(workflow.paramCount === undefined ? 0 : workflow.paramCount) })),
|
|
1816
|
+
]
|
|
1817
|
+
if (workflow.updatedAt) meta.push(h('span', { key: 'time', className: 'sc-metaTime' }, fmtTime(workflow.updatedAt)))
|
|
1818
|
+
const kindChips = Array.isArray(workflow.kindLabels) ? workflow.kindLabels.slice(0, 3) : []
|
|
1819
|
+
const needCount = Number(workflow.neededInputCount) || 0
|
|
1820
|
+
const summaryLine = h('div', { key: 'descRow', className: 'sc-wfDescRow' },
|
|
1821
|
+
kindChips.length > 0
|
|
1822
|
+
? h('span', { className: 'sc-kindChips' }, kindChips.map((label, index) => h('span', { key: index, className: 'sc-kindChip' }, String(label))))
|
|
1823
|
+
: null,
|
|
1824
|
+
workflow.description
|
|
1825
|
+
? h('span', { className: 'sc-wfDesc', title: String(workflow.description) }, String(workflow.description))
|
|
1826
|
+
: null,
|
|
1827
|
+
needCount > 0
|
|
1828
|
+
? h('span', { className: 'sc-needBadge', title: t('wf.needsInput', { n: String(needCount) }) }, t('wf.needsInput', { n: String(needCount) }))
|
|
1829
|
+
: null)
|
|
1830
|
+
return h('div', { key: workflow.id, className: 'sc-wfRow' },
|
|
1831
|
+
h('div', { className: 'sc-wfMain' },
|
|
1832
|
+
isRenaming
|
|
1833
|
+
? h('div', { className: 'sc-renameRow' },
|
|
1834
|
+
h('input', {
|
|
1835
|
+
className: 'sc-input',
|
|
1836
|
+
type: 'text',
|
|
1837
|
+
value: renaming.name,
|
|
1838
|
+
placeholder: t('wf.renamePrompt'),
|
|
1839
|
+
'aria-label': t('wf.renamePrompt'),
|
|
1840
|
+
disabled: busy,
|
|
1841
|
+
onChange: (event) => setRenaming({ id: workflow.id, name: event.target.value }),
|
|
1842
|
+
onKeyDown: (event) => {
|
|
1843
|
+
if (event.key === 'Enter') saveRename()
|
|
1844
|
+
if (event.key === 'Escape') setRenaming(null)
|
|
1845
|
+
},
|
|
1846
|
+
}),
|
|
1847
|
+
h('button', {
|
|
1848
|
+
type: 'button',
|
|
1849
|
+
className: 'sc-btn sc-btnPrimary',
|
|
1850
|
+
onClick: saveRename,
|
|
1851
|
+
disabled: busy,
|
|
1852
|
+
'aria-busy': busy ? 'true' : 'false',
|
|
1853
|
+
}, busy ? h(Spinner) : null, t('wf.renameSave')),
|
|
1854
|
+
h('button', {
|
|
1855
|
+
type: 'button',
|
|
1856
|
+
className: 'sc-btn',
|
|
1857
|
+
onClick: () => setRenaming(null),
|
|
1858
|
+
disabled: busy,
|
|
1859
|
+
}, t('common.cancel')))
|
|
1860
|
+
: h('button', {
|
|
1861
|
+
type: 'button',
|
|
1862
|
+
className: 'sc-wfNameBtn',
|
|
1863
|
+
title: t('wf.open'),
|
|
1864
|
+
onClick: () => openDetail(workflow),
|
|
1865
|
+
}, workflow.name),
|
|
1866
|
+
h('div', { className: 'sc-wfMeta' }, meta)),
|
|
1867
|
+
summaryLine,
|
|
1868
|
+
h('div', { className: 'sc-wfActions' },
|
|
1869
|
+
h('button', {
|
|
1870
|
+
type: 'button',
|
|
1871
|
+
className: 'sc-btn',
|
|
1872
|
+
onClick: () => openDetail(workflow),
|
|
1873
|
+
disabled: busy,
|
|
1874
|
+
}, t('wf.open')),
|
|
1875
|
+
h('button', {
|
|
1876
|
+
type: 'button',
|
|
1877
|
+
className: 'sc-btn',
|
|
1878
|
+
onClick: () => startRename(workflow),
|
|
1879
|
+
disabled: busy,
|
|
1880
|
+
}, h(Icon, { name: 'pencil', size: 13 }), t('wf.rename')),
|
|
1881
|
+
h('button', {
|
|
1882
|
+
type: 'button',
|
|
1883
|
+
className: 'sc-btn sc-btnDanger',
|
|
1884
|
+
onClick: () => removeWorkflow(workflow),
|
|
1885
|
+
disabled: busy,
|
|
1886
|
+
'aria-busy': busy ? 'true' : 'false',
|
|
1887
|
+
}, busy ? h(Spinner) : h(Icon, { name: 'trash', size: 13 }), t('wf.delete'))))
|
|
1888
|
+
})))
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
return h(Card, {
|
|
1892
|
+
icon: 'workflow',
|
|
1893
|
+
title: t('wf.title'),
|
|
1894
|
+
count: String(workflows.length),
|
|
1895
|
+
actions,
|
|
1896
|
+
}, body)
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
/* ── 服务器工作流浏览器(不导入:直接查看 + 使用时按需加载) ────────────── */
|
|
1900
|
+
function ServerWorkflowsCard(props) {
|
|
1901
|
+
const t = props.t
|
|
1902
|
+
const alive = useAlive()
|
|
1903
|
+
const [list, setList] = useState({ phase: 'idle', items: [], error: null })
|
|
1904
|
+
const [query, setQuery] = useState('')
|
|
1905
|
+
const [view, setView] = useState({ kind: 'list' })
|
|
1906
|
+
|
|
1907
|
+
async function load(force) {
|
|
1908
|
+
if (!props.baseUrl) {
|
|
1909
|
+
setList({ phase: 'noConfig', items: [], error: null })
|
|
1910
|
+
return
|
|
1911
|
+
}
|
|
1912
|
+
setList((previous) => ({ phase: 'loading', items: previous.items || [], error: null }))
|
|
1913
|
+
try {
|
|
1914
|
+
const data = await api('/server-workflows?refresh=' + (force ? '1' : '0'), {
|
|
1915
|
+
allowFail: true,
|
|
1916
|
+
timeoutMs: 25000,
|
|
1917
|
+
})
|
|
1918
|
+
if (!alive.current) return
|
|
1919
|
+
if (!data || data.ok === false) {
|
|
1920
|
+
setList({ phase: 'error', items: [], error: (data && data.error) || t('wf.serverLoadError') })
|
|
1921
|
+
return
|
|
1922
|
+
}
|
|
1923
|
+
setList({ phase: 'ok', items: Array.isArray(data.items) ? data.items : [], error: null })
|
|
1924
|
+
} catch (error) {
|
|
1925
|
+
if (!alive.current) return
|
|
1926
|
+
setList({ phase: 'error', items: [], error: humanError(error, t) })
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
useEffect(() => {
|
|
1931
|
+
load(false)
|
|
1932
|
+
return undefined
|
|
1933
|
+
}, [props.baseUrl])
|
|
1934
|
+
|
|
1935
|
+
function openDetail(item) {
|
|
1936
|
+
setView({ kind: 'detail', path: String(item.path || ''), name: String(item.name || item.path || '') })
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
if (view.kind === 'detail') {
|
|
1940
|
+
return h(WorkflowDetail, {
|
|
1941
|
+
key: 'server:' + view.path,
|
|
1942
|
+
path: view.path,
|
|
1943
|
+
fallbackName: view.name,
|
|
1944
|
+
t,
|
|
1945
|
+
onBack: () => {
|
|
1946
|
+
setView({ kind: 'list' })
|
|
1947
|
+
load(false)
|
|
1948
|
+
},
|
|
1949
|
+
onChanged: () => load(false),
|
|
1950
|
+
})
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
const items = list.phase === 'ok' || list.phase === 'loading' ? list.items || [] : []
|
|
1954
|
+
const q = query.trim().toLowerCase()
|
|
1955
|
+
const visible = q
|
|
1956
|
+
? items.filter((item) => String(item.name || '').toLowerCase().includes(q) || String(item.path || '').toLowerCase().includes(q))
|
|
1957
|
+
: items
|
|
1958
|
+
const loading = list.phase === 'loading'
|
|
1959
|
+
|
|
1960
|
+
const actions = [
|
|
1961
|
+
h('button', {
|
|
1962
|
+
key: 'refresh',
|
|
1963
|
+
type: 'button',
|
|
1964
|
+
className: 'sc-btn',
|
|
1965
|
+
onClick: () => load(true),
|
|
1966
|
+
disabled: loading || !props.baseUrl,
|
|
1967
|
+
'aria-busy': loading ? 'true' : 'false',
|
|
1968
|
+
}, loading ? h(Spinner) : h(Icon, { name: 'refresh', size: 13 }), t('common.refresh')),
|
|
1969
|
+
]
|
|
1970
|
+
|
|
1971
|
+
let body
|
|
1972
|
+
if (!props.baseUrl || list.phase === 'noConfig') {
|
|
1973
|
+
body = h('div', { className: 'sc-emptyState' },
|
|
1974
|
+
h('div', { className: 'sc-emptyIcon' }, h(Icon, { name: 'server', size: 22 })),
|
|
1975
|
+
h('p', { className: 'sc-emptyTitle' }, t('conn.unconfigured')),
|
|
1976
|
+
h('p', { className: 'sc-emptyHint' }, t('wf.serverHint')),
|
|
1977
|
+
h('div', { className: 'sc-emptyActions' },
|
|
1978
|
+
h('button', {
|
|
1979
|
+
type: 'button',
|
|
1980
|
+
className: 'sc-btn sc-btnPrimary',
|
|
1981
|
+
onClick: props.onOpenConnection,
|
|
1982
|
+
}, t('conn.configureCta'))))
|
|
1983
|
+
} else if (loading && items.length === 0) {
|
|
1984
|
+
body = h(LoadingRow, { t, label: t('wf.serverLoading') })
|
|
1985
|
+
} else if (list.phase === 'error') {
|
|
1986
|
+
body = h(InlineError, { t, message: list.error, onRetry: () => load(true) })
|
|
1987
|
+
} else if (items.length === 0) {
|
|
1988
|
+
body = h('div', { className: 'sc-emptyState' },
|
|
1989
|
+
h('div', { className: 'sc-emptyIcon' }, h(Icon, { name: 'workflow', size: 22 })),
|
|
1990
|
+
h('p', { className: 'sc-emptyTitle' }, t('wf.serverEmptyTitle')),
|
|
1991
|
+
h('p', { className: 'sc-emptyHint' }, t('wf.serverEmptyHint')),
|
|
1992
|
+
h('div', { className: 'sc-emptyActions' },
|
|
1993
|
+
h('button', { type: 'button', className: 'sc-btn', onClick: () => load(true) }, t('common.refresh'))))
|
|
1994
|
+
} else {
|
|
1995
|
+
body = []
|
|
1996
|
+
body.push(h('div', { key: 'toolbar', className: 'sc-toolbar' },
|
|
1997
|
+
h('input', {
|
|
1998
|
+
className: 'sc-input sc-search',
|
|
1999
|
+
type: 'search',
|
|
2000
|
+
placeholder: t('wf.searchServer'),
|
|
2001
|
+
'aria-label': t('wf.searchServer'),
|
|
2002
|
+
value: query,
|
|
2003
|
+
onChange: (event) => setQuery(event.target.value),
|
|
2004
|
+
}),
|
|
2005
|
+
h('span', { className: 'sc-cardCount' }, t('wf.serverCount', { n: String(visible.length) }))))
|
|
2006
|
+
body.push(h('p', { key: 'hint', className: 'sc-muted' }, t('wf.useHint')))
|
|
2007
|
+
if (visible.length === 0) {
|
|
2008
|
+
body.push(h('p', { key: 'noMatch', className: 'sc-empty' }, t('wf.serverNoMatch')))
|
|
2009
|
+
} else {
|
|
2010
|
+
body.push(h('div', { key: 'list', className: 'sc-serverWfList' }, visible.map((item, index) => {
|
|
2011
|
+
const path = String(item.path || '')
|
|
2012
|
+
const name = String(item.name || path)
|
|
2013
|
+
const meta = []
|
|
2014
|
+
if (item.size !== undefined) meta.push(fmtBytes(item.size))
|
|
2015
|
+
if (item.modified) meta.push(fmtTime(item.modified))
|
|
2016
|
+
return h('button', {
|
|
2017
|
+
key: path || index,
|
|
2018
|
+
type: 'button',
|
|
2019
|
+
className: 'sc-serverWfRow',
|
|
2020
|
+
title: path,
|
|
2021
|
+
onClick: () => openDetail(item),
|
|
2022
|
+
},
|
|
2023
|
+
h('span', { className: 'sc-serverWfLead' }, h(Icon, { name: 'workflow', size: 15 })),
|
|
2024
|
+
h('span', { className: 'sc-serverWfMain' },
|
|
2025
|
+
h('span', { className: 'sc-serverWfName' }, name),
|
|
2026
|
+
h('span', { className: 'sc-serverWfPath' }, path + (meta.length > 0 ? ' · ' + meta.join(' · ') : ''))),
|
|
2027
|
+
h('span', { className: 'sc-serverWfUse' }, t('wf.use'), h(Icon, { name: 'chevron', size: 12 })))
|
|
2028
|
+
})))
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
return h(Card, {
|
|
2033
|
+
icon: 'workflow',
|
|
2034
|
+
title: t('wf.title'),
|
|
2035
|
+
count: items.length > 0 ? t('wf.serverCount', { n: String(items.length) }) : null,
|
|
2036
|
+
actions,
|
|
2037
|
+
}, body)
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
/* ── 提示词输入 ──────────────────────────────────────────────────────── */
|
|
2041
|
+
function PromptField(props) {
|
|
2042
|
+
return h('div', { className: 'sc-promptBlock' },
|
|
2043
|
+
h('div', { className: 'sc-promptHead' },
|
|
2044
|
+
h('label', { className: 'sc-promptLabel', htmlFor: props.id }, props.label),
|
|
2045
|
+
Array.isArray(props.targets) && props.targets.length > 0
|
|
2046
|
+
? h('div', { className: 'sc-chipRow' }, props.targets.map((path) => h('span', {
|
|
2047
|
+
key: path,
|
|
2048
|
+
className: 'sc-chip',
|
|
2049
|
+
title: props.t('wf.promptTargets'),
|
|
2050
|
+
}, path)))
|
|
2051
|
+
: null),
|
|
2052
|
+
h('textarea', {
|
|
2053
|
+
id: props.id,
|
|
2054
|
+
className: 'sc-textarea',
|
|
2055
|
+
rows: 3,
|
|
2056
|
+
spellCheck: false,
|
|
2057
|
+
value: props.value || '',
|
|
2058
|
+
disabled: Boolean(props.disabled),
|
|
2059
|
+
onChange: (event) => props.onChange(event.target.value),
|
|
2060
|
+
}))
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
/* ── 参数控件 ────────────────────────────────────────────────────────── */
|
|
2064
|
+
function ParamControl(props) {
|
|
2065
|
+
const t = props.t
|
|
2066
|
+
const param = props.param
|
|
2067
|
+
const value = props.value
|
|
2068
|
+
const inputId = 'sc-param-' + String(param.path || '').replace(/[^a-zA-Z0-9_-]/g, '_')
|
|
2069
|
+
const textValue = value === undefined || value === null ? '' : String(value)
|
|
2070
|
+
const disabled = Boolean(props.disabled)
|
|
2071
|
+
let control
|
|
2072
|
+
if (param.type === 'enum') {
|
|
2073
|
+
const options = Array.isArray(param.options) ? param.options.slice() : []
|
|
2074
|
+
if (textValue !== '' && options.indexOf(textValue) === -1) options.unshift(textValue)
|
|
2075
|
+
control = h('div', { className: 'sc-selectWrap' },
|
|
2076
|
+
h('select', {
|
|
2077
|
+
id: inputId,
|
|
2078
|
+
className: 'sc-select',
|
|
2079
|
+
value: textValue,
|
|
2080
|
+
disabled: disabled || undefined,
|
|
2081
|
+
onChange: (event) => props.onChange(event.target.value),
|
|
2082
|
+
}, options.map((option) => h('option', { key: option, value: option }, option))))
|
|
2083
|
+
} else if (param.type === 'boolean') {
|
|
2084
|
+
control = h('div', { className: 'sc-paramCtl' },
|
|
2085
|
+
h(Switch, {
|
|
2086
|
+
checked: Boolean(value),
|
|
2087
|
+
label: param.path,
|
|
2088
|
+
disabled,
|
|
2089
|
+
onChange: (next) => props.onChange(next),
|
|
2090
|
+
}))
|
|
2091
|
+
} else if (param.type === 'number' || param.type === 'integer') {
|
|
2092
|
+
control = h('input', {
|
|
2093
|
+
id: inputId,
|
|
2094
|
+
className: 'sc-input',
|
|
2095
|
+
type: 'number',
|
|
2096
|
+
inputMode: 'decimal',
|
|
2097
|
+
value: textValue,
|
|
2098
|
+
disabled: disabled || undefined,
|
|
2099
|
+
min: typeof param.min === 'number' ? param.min : undefined,
|
|
2100
|
+
max: typeof param.max === 'number' ? param.max : undefined,
|
|
2101
|
+
step: param.type === 'integer' ? 1 : (typeof param.step === 'number' ? param.step : 'any'),
|
|
2102
|
+
onChange: (event) => props.onChange(event.target.value),
|
|
2103
|
+
})
|
|
2104
|
+
} else if (param.multiline) {
|
|
2105
|
+
control = h('textarea', {
|
|
2106
|
+
id: inputId,
|
|
2107
|
+
className: 'sc-textarea',
|
|
2108
|
+
rows: 3,
|
|
2109
|
+
spellCheck: false,
|
|
2110
|
+
value: textValue,
|
|
2111
|
+
disabled: disabled || undefined,
|
|
2112
|
+
onChange: (event) => props.onChange(event.target.value),
|
|
2113
|
+
})
|
|
2114
|
+
} else {
|
|
2115
|
+
control = h('input', {
|
|
2116
|
+
id: inputId,
|
|
2117
|
+
className: 'sc-input',
|
|
2118
|
+
type: 'text',
|
|
2119
|
+
value: textValue,
|
|
2120
|
+
disabled: disabled || undefined,
|
|
2121
|
+
onChange: (event) => props.onChange(event.target.value),
|
|
2122
|
+
})
|
|
2123
|
+
}
|
|
2124
|
+
return h('div', { className: 'sc-param' },
|
|
2125
|
+
h('div', { className: 'sc-paramHead' },
|
|
2126
|
+
h('label', { className: 'sc-paramLabel', htmlFor: inputId }, param.inputName || param.path),
|
|
2127
|
+
h('span', { className: 'sc-paramPath', title: t('wf.paramPath') }, '#' + String(param.path || ''))),
|
|
2128
|
+
control)
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/* ── 结果图片网格 ────────────────────────────────────────────────────── */
|
|
2132
|
+
function ResultImages(props) {
|
|
2133
|
+
const images = Array.isArray(props.images) ? props.images : []
|
|
2134
|
+
return h('div', { className: 'sc-images' }, images.map((image, index) => {
|
|
2135
|
+
const url = resultImageUrl(image)
|
|
2136
|
+
if (!url) return null
|
|
2137
|
+
const filename = image && image.filename ? String(image.filename) : 'image-' + (index + 1)
|
|
2138
|
+
return h('button', {
|
|
2139
|
+
key: index,
|
|
2140
|
+
type: 'button',
|
|
2141
|
+
className: 'sc-imageBtn',
|
|
2142
|
+
title: filename + (image && image.path ? '\n' + image.path : ''),
|
|
2143
|
+
onClick: () => openImage(url),
|
|
2144
|
+
}, h('img', { className: 'sc-image', src: url, alt: filename, loading: 'lazy' }))
|
|
2145
|
+
}))
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
function NodeErrors(props) {
|
|
2149
|
+
const rows = nodeErrorRows(props.nodeErrors)
|
|
2150
|
+
if (rows.length === 0) return null
|
|
2151
|
+
return h('div', { className: 'sc-nodeErrors' },
|
|
2152
|
+
h('span', { className: 'sc-sectionTitle' }, props.t('wf.nodeErrors')),
|
|
2153
|
+
rows.map((row, index) => h('p', { key: index, className: 'sc-errorLine' },
|
|
2154
|
+
h('code', null, '#' + row.id + (row.classType ? ' ' + row.classType : '')),
|
|
2155
|
+
h('span', { className: 'sc-errorText' }, row.messages.join(' · ')))))
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
/* ── 运行结果区 ──────────────────────────────────────────────────────── */
|
|
2159
|
+
function RunResult(props) {
|
|
2160
|
+
const t = props.t
|
|
2161
|
+
const run = props.run
|
|
2162
|
+
const elapsed = props.elapsedMs
|
|
2163
|
+
function head(extra) {
|
|
2164
|
+
return h('div', { className: 'sc-resultHead' },
|
|
2165
|
+
h('span', null, t('wf.result')),
|
|
2166
|
+
extra || null)
|
|
2167
|
+
}
|
|
2168
|
+
if (!run || run.phase === 'idle') {
|
|
2169
|
+
return h('div', { className: 'sc-result' },
|
|
2170
|
+
head(),
|
|
2171
|
+
h('p', { className: 'sc-muted' }, t('wf.resultEmpty')))
|
|
2172
|
+
}
|
|
2173
|
+
if (run.phase === 'running') {
|
|
2174
|
+
return h('div', { className: 'sc-result' },
|
|
2175
|
+
head(),
|
|
2176
|
+
h('div', { className: 'sc-loadingRow' },
|
|
2177
|
+
h(Spinner),
|
|
2178
|
+
h('span', null, t('wf.running')),
|
|
2179
|
+
elapsed !== null && elapsed !== undefined
|
|
2180
|
+
? h('span', { className: 'sc-muted' }, t('wf.elapsed', { v: fmtDuration(elapsed) }))
|
|
2181
|
+
: null))
|
|
2182
|
+
}
|
|
2183
|
+
if (run.phase === 'error') {
|
|
2184
|
+
const data = run.data && typeof run.data === 'object' ? run.data : {}
|
|
2185
|
+
const images = Array.isArray(data.images) ? data.images.filter((image) => resultImageUrl(image)) : []
|
|
2186
|
+
return h('div', { className: 'sc-result' },
|
|
2187
|
+
head(h(Pill, { tone: 'error' }, t('wf.failed'))),
|
|
2188
|
+
h(InlineError, { t, message: run.error || (data.error ? String(data.error) : t('wf.failed')) }),
|
|
2189
|
+
images.length > 0 ? h(ResultImages, { images }) : null,
|
|
2190
|
+
h(NodeErrors, { t, nodeErrors: run.nodeErrors || data.nodeErrors }),
|
|
2191
|
+
h(WarnList, {
|
|
2192
|
+
warnings: run.warnings && run.warnings.length > 0 ? run.warnings : data.warnings,
|
|
2193
|
+
title: t('wf.runWarnings'),
|
|
2194
|
+
}))
|
|
2195
|
+
}
|
|
2196
|
+
const data = run.data && typeof run.data === 'object' ? run.data : {}
|
|
2197
|
+
const state = data.state ? String(data.state) : 'done'
|
|
2198
|
+
const images = Array.isArray(data.images) ? data.images.filter((image) => resultImageUrl(image)) : []
|
|
2199
|
+
const applied = Array.isArray(data.applied) ? data.applied : []
|
|
2200
|
+
const elapsedValue = elapsed !== null && elapsed !== undefined
|
|
2201
|
+
? elapsed
|
|
2202
|
+
: (Number.isFinite(Number(data.elapsedMs)) ? Number(data.elapsedMs) : null)
|
|
2203
|
+
const facts = []
|
|
2204
|
+
if (elapsedValue !== null) {
|
|
2205
|
+
facts.push(h('span', { key: 'elapsed', className: 'sc-fact' },
|
|
2206
|
+
h('span', { className: 'sc-factLabel' }, t('wf.elapsed')),
|
|
2207
|
+
h('span', { className: 'sc-factValue' }, fmtDuration(elapsedValue))))
|
|
2208
|
+
}
|
|
2209
|
+
if (data.promptId) {
|
|
2210
|
+
facts.push(h('span', { key: 'prompt', className: 'sc-fact' },
|
|
2211
|
+
h('span', { className: 'sc-factLabel' }, t('wf.promptId')),
|
|
2212
|
+
h('code', null, String(data.promptId))))
|
|
2213
|
+
}
|
|
2214
|
+
return h('div', { className: 'sc-result' },
|
|
2215
|
+
head(h(Pill, { tone: runTone(state) }, runStateLabel(state, t))),
|
|
2216
|
+
facts.length > 0 ? h('div', { className: 'sc-facts' }, facts) : null,
|
|
2217
|
+
images.length > 0
|
|
2218
|
+
? h(ResultImages, { images })
|
|
2219
|
+
: h('p', { className: 'sc-muted' }, t('wf.noImages')),
|
|
2220
|
+
state === 'error' && data.error ? h(InlineError, { t, message: String(data.error) }) : null,
|
|
2221
|
+
applied.length > 0
|
|
2222
|
+
? h('div', { className: 'sc-applied' },
|
|
2223
|
+
h('span', { className: 'sc-sectionTitle' }, t('wf.applied')),
|
|
2224
|
+
h('div', { className: 'sc-chipRow' }, applied.map((item, index) => h('span', {
|
|
2225
|
+
key: index,
|
|
2226
|
+
className: 'sc-chip',
|
|
2227
|
+
}, String(item.path || '') + (item.field ? ' @' + item.field : '') + ' = ' + String(item.value)))))
|
|
2228
|
+
: null,
|
|
2229
|
+
h(NodeErrors, { t, nodeErrors: data.nodeErrors }),
|
|
2230
|
+
h(WarnList, { warnings: data.warnings, title: t('wf.runWarnings') }))
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
/* ── 工作流详情 ──────────────────────────────────────────────────────── */
|
|
2234
|
+
function WorkflowDetail(props) {
|
|
2235
|
+
const t = props.t
|
|
2236
|
+
const isServer = Boolean(props.path)
|
|
2237
|
+
const alive = useAlive()
|
|
2238
|
+
const [load, setLoad] = useState({ phase: 'loading', workflow: null, error: null })
|
|
2239
|
+
const [loadSeq, setLoadSeq] = useState(0)
|
|
2240
|
+
const [overrides, setOverrides] = useState({})
|
|
2241
|
+
const [prompts, setPrompts] = useState({ positive: '', negative: '' })
|
|
2242
|
+
const [run, setRun] = useState({ phase: 'idle' })
|
|
2243
|
+
const [elapsedMs, setElapsedMs] = useState(null)
|
|
2244
|
+
const [copiedPath, setCopiedPath] = useState(false)
|
|
2245
|
+
const [meta, setMeta] = useState({ description: '', tags: '', phase: 'idle', error: null, saved: false })
|
|
2246
|
+
|
|
2247
|
+
useEffect(() => {
|
|
2248
|
+
let cancelled = false
|
|
2249
|
+
setLoad((previous) => (previous.phase === 'ok' ? previous : { phase: 'loading', workflow: null, error: null }))
|
|
2250
|
+
const url = props.path
|
|
2251
|
+
? '/server-workflows/detail?path=' + encodeURIComponent(props.path)
|
|
2252
|
+
+ (props.fallbackName ? '&name=' + encodeURIComponent(props.fallbackName) : '')
|
|
2253
|
+
: '/workflows/' + encodeURIComponent(props.id)
|
|
2254
|
+
api(url, { timeoutMs: 60000 }).then((response) => {
|
|
2255
|
+
if (cancelled) return
|
|
2256
|
+
const workflow = response && response.workflow ? response.workflow : null
|
|
2257
|
+
if (!workflow) {
|
|
2258
|
+
setLoad({ phase: 'error', workflow: null, error: t('wf.loadError') })
|
|
2259
|
+
return
|
|
2260
|
+
}
|
|
2261
|
+
setLoad({ phase: 'ok', workflow, error: null })
|
|
2262
|
+
setOverrides(paramDefaults(workflow.params))
|
|
2263
|
+
setPrompts(promptDefaults(workflow))
|
|
2264
|
+
setMeta({
|
|
2265
|
+
description: typeof workflow.description === 'string'
|
|
2266
|
+
? workflow.description
|
|
2267
|
+
: (workflow.capabilities && typeof workflow.capabilities.summary === 'string' ? workflow.capabilities.summary : ''),
|
|
2268
|
+
tags: Array.isArray(workflow.tags) ? workflow.tags.join(',') : '',
|
|
2269
|
+
phase: 'idle',
|
|
2270
|
+
error: null,
|
|
2271
|
+
saved: false,
|
|
2272
|
+
})
|
|
2273
|
+
setRun({ phase: 'idle' })
|
|
2274
|
+
setElapsedMs(null)
|
|
2275
|
+
}).catch((error) => {
|
|
2276
|
+
if (cancelled) return
|
|
2277
|
+
setLoad({ phase: 'error', workflow: null, error: humanError(error, t) })
|
|
2278
|
+
setRun({ phase: 'idle' })
|
|
2279
|
+
})
|
|
2280
|
+
return () => {
|
|
2281
|
+
cancelled = true
|
|
2282
|
+
}
|
|
2283
|
+
}, [props.id, props.path, loadSeq])
|
|
2284
|
+
|
|
2285
|
+
useEffect(() => {
|
|
2286
|
+
if (!run || run.phase === 'idle') {
|
|
2287
|
+
setElapsedMs(null)
|
|
2288
|
+
return undefined
|
|
2289
|
+
}
|
|
2290
|
+
if (run.phase === 'running') {
|
|
2291
|
+
const startedAt = run.startedAt || Date.now()
|
|
2292
|
+
setElapsedMs(0)
|
|
2293
|
+
const timer = setInterval(() => setElapsedMs(Date.now() - startedAt), 500)
|
|
2294
|
+
return () => clearInterval(timer)
|
|
2295
|
+
}
|
|
2296
|
+
const data = run.data && typeof run.data === 'object' ? run.data : {}
|
|
2297
|
+
let final = null
|
|
2298
|
+
if (Number.isFinite(Number(data.elapsedMs))) final = Number(data.elapsedMs)
|
|
2299
|
+
else if (run.endedAt && run.startedAt) final = run.endedAt - run.startedAt
|
|
2300
|
+
setElapsedMs(final)
|
|
2301
|
+
return undefined
|
|
2302
|
+
}, [run])
|
|
2303
|
+
|
|
2304
|
+
useEffect(() => {
|
|
2305
|
+
if (!copiedPath) return undefined
|
|
2306
|
+
const timer = setTimeout(() => setCopiedPath(false), 1400)
|
|
2307
|
+
return () => clearTimeout(timer)
|
|
2308
|
+
}, [copiedPath])
|
|
2309
|
+
|
|
2310
|
+
const workflow = load.phase === 'ok' ? load.workflow : null
|
|
2311
|
+
const params = workflow && Array.isArray(workflow.params) ? workflow.params : []
|
|
2312
|
+
const targets = workflow && workflow.promptTargets && typeof workflow.promptTargets === 'object'
|
|
2313
|
+
? workflow.promptTargets
|
|
2314
|
+
: {}
|
|
2315
|
+
const positiveTargets = Array.isArray(targets.positive) ? targets.positive : []
|
|
2316
|
+
const negativeTargets = Array.isArray(targets.negative) ? targets.negative : []
|
|
2317
|
+
const promptPathSet = new Set([].concat(positiveTargets, negativeTargets))
|
|
2318
|
+
const shownParams = params.filter((param) => param && param.path && !promptPathSet.has(param.path))
|
|
2319
|
+
const running = run.phase === 'running'
|
|
2320
|
+
|
|
2321
|
+
function setParam(path, value) {
|
|
2322
|
+
setOverrides((previous) => ({ ...previous, [path]: value }))
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
function setPrompt(field, value) {
|
|
2326
|
+
setPrompts((previous) => ({ ...previous, [field]: value }))
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
function resetDefaults() {
|
|
2330
|
+
setOverrides(paramDefaults(params))
|
|
2331
|
+
setPrompts(promptDefaults(workflow))
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
function parseTagsInput(text) {
|
|
2335
|
+
return [...new Set(String(text || '').split(/[,,、\n]/).map((item) => item.trim()).filter(Boolean))]
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
const metaTags = parseTagsInput(meta.tags)
|
|
2339
|
+
const metaInvalid = meta.description.length > 500
|
|
2340
|
+
|| metaTags.length > 12
|
|
2341
|
+
|| metaTags.some((tag) => tag.length > 40)
|
|
2342
|
+
|
|
2343
|
+
async function saveMeta() {
|
|
2344
|
+
if (!workflow || meta.phase === 'saving' || metaInvalid) return
|
|
2345
|
+
setMeta((previous) => ({ ...previous, phase: 'saving', error: null, saved: false }))
|
|
2346
|
+
try {
|
|
2347
|
+
const response = await api('/workflows', {
|
|
2348
|
+
method: 'POST',
|
|
2349
|
+
body: { action: 'update', id: props.id, description: meta.description, tags: metaTags },
|
|
2350
|
+
allowFail: true,
|
|
2351
|
+
})
|
|
2352
|
+
if (!alive.current) return
|
|
2353
|
+
if (!response || response.ok === false) {
|
|
2354
|
+
setMeta((previous) => ({
|
|
2355
|
+
...previous,
|
|
2356
|
+
phase: 'error',
|
|
2357
|
+
error: (response && response.error) ? String(response.error) : t('wf.failed'),
|
|
2358
|
+
}))
|
|
2359
|
+
return
|
|
2360
|
+
}
|
|
2361
|
+
setMeta((previous) => ({ ...previous, phase: 'idle', error: null, saved: true }))
|
|
2362
|
+
props.onChanged()
|
|
2363
|
+
} catch (error) {
|
|
2364
|
+
if (alive.current) {
|
|
2365
|
+
setMeta((previous) => ({ ...previous, phase: 'error', error: humanError(error, t) }))
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
async function runNow() {
|
|
2371
|
+
if (running || !workflow) return
|
|
2372
|
+
const startedAt = Date.now()
|
|
2373
|
+
setRun({ phase: 'running', startedAt })
|
|
2374
|
+
setElapsedMs(0)
|
|
2375
|
+
const builtParams = buildParamValues(shownParams, overrides)
|
|
2376
|
+
try {
|
|
2377
|
+
const response = await api('/run', {
|
|
2378
|
+
method: 'POST',
|
|
2379
|
+
body: {
|
|
2380
|
+
workflow: props.path || props.id,
|
|
2381
|
+
prompt: prompts.positive,
|
|
2382
|
+
negativePrompt: prompts.negative,
|
|
2383
|
+
params: builtParams,
|
|
2384
|
+
},
|
|
2385
|
+
allowFail: true,
|
|
2386
|
+
})
|
|
2387
|
+
if (!alive.current) return
|
|
2388
|
+
const endedAt = Date.now()
|
|
2389
|
+
if (!response || response.ok === false) {
|
|
2390
|
+
const data = response && typeof response === 'object' ? response : {}
|
|
2391
|
+
setRun({
|
|
2392
|
+
phase: 'error',
|
|
2393
|
+
data,
|
|
2394
|
+
error: data.error ? String(data.error) : t('wf.failed'),
|
|
2395
|
+
startedAt,
|
|
2396
|
+
endedAt,
|
|
2397
|
+
nodeErrors: data.nodeErrors,
|
|
2398
|
+
warnings: Array.isArray(data.warnings) ? data.warnings : [],
|
|
2399
|
+
})
|
|
2400
|
+
} else {
|
|
2401
|
+
setRun({ phase: 'done', data: response, startedAt, endedAt })
|
|
2402
|
+
}
|
|
2403
|
+
props.onChanged()
|
|
2404
|
+
} catch (error) {
|
|
2405
|
+
if (!alive.current) return
|
|
2406
|
+
setRun({ phase: 'error', error: humanError(error, t), startedAt, endedAt: Date.now() })
|
|
2407
|
+
props.onChanged()
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
const actions = [
|
|
2412
|
+
h('button', {
|
|
2413
|
+
key: 'back',
|
|
2414
|
+
type: 'button',
|
|
2415
|
+
className: 'sc-btn',
|
|
2416
|
+
onClick: props.onBack,
|
|
2417
|
+
}, h(Icon, { name: 'back', size: 13 }), t('wf.detailBack')),
|
|
2418
|
+
isServer
|
|
2419
|
+
? h('button', {
|
|
2420
|
+
key: 'copyPath',
|
|
2421
|
+
type: 'button',
|
|
2422
|
+
className: 'sc-btn',
|
|
2423
|
+
title: props.path,
|
|
2424
|
+
onClick: async () => {
|
|
2425
|
+
const ok = await copyText(props.path)
|
|
2426
|
+
if (ok && alive.current) setCopiedPath(true)
|
|
2427
|
+
},
|
|
2428
|
+
}, h(Icon, { name: 'copy', size: 13 }), copiedPath ? t('wf.copiedPath') : t('wf.copyPath'))
|
|
2429
|
+
: null,
|
|
2430
|
+
]
|
|
2431
|
+
|
|
2432
|
+
let body
|
|
2433
|
+
if (load.phase === 'loading') {
|
|
2434
|
+
body = h(LoadingRow, { t, label: t('wf.loading') })
|
|
2435
|
+
} else if (load.phase === 'error') {
|
|
2436
|
+
body = h(InlineError, {
|
|
2437
|
+
t,
|
|
2438
|
+
message: load.error,
|
|
2439
|
+
onRetry: () => setLoadSeq((value) => value + 1),
|
|
2440
|
+
})
|
|
2441
|
+
} else {
|
|
2442
|
+
const hasPrompts = positiveTargets.length > 0 || negativeTargets.length > 0
|
|
2443
|
+
const nodes = Array.isArray(workflow.nodes) ? workflow.nodes : []
|
|
2444
|
+
const recordWarnings = Array.isArray(workflow.warnings) ? workflow.warnings : []
|
|
2445
|
+
body = []
|
|
2446
|
+
if (recordWarnings.length > 0) {
|
|
2447
|
+
body.push(h(WarnList, {
|
|
2448
|
+
key: 'recordWarnings',
|
|
2449
|
+
warnings: recordWarnings,
|
|
2450
|
+
title: t('wf.importWarnings'),
|
|
2451
|
+
}))
|
|
2452
|
+
}
|
|
2453
|
+
if (hasPrompts) {
|
|
2454
|
+
const promptItems = []
|
|
2455
|
+
if (positiveTargets.length > 0) {
|
|
2456
|
+
promptItems.push(h(PromptField, {
|
|
2457
|
+
key: 'positive',
|
|
2458
|
+
id: 'sc-prompt-positive',
|
|
2459
|
+
label: t('wf.prompt'),
|
|
2460
|
+
value: prompts.positive,
|
|
2461
|
+
targets: positiveTargets,
|
|
2462
|
+
t,
|
|
2463
|
+
disabled: running,
|
|
2464
|
+
onChange: (value) => setPrompt('positive', value),
|
|
2465
|
+
}))
|
|
2466
|
+
}
|
|
2467
|
+
if (negativeTargets.length > 0) {
|
|
2468
|
+
promptItems.push(h(PromptField, {
|
|
2469
|
+
key: 'negative',
|
|
2470
|
+
id: 'sc-prompt-negative',
|
|
2471
|
+
label: t('wf.negativePrompt'),
|
|
2472
|
+
value: prompts.negative,
|
|
2473
|
+
targets: negativeTargets,
|
|
2474
|
+
t,
|
|
2475
|
+
disabled: running,
|
|
2476
|
+
onChange: (value) => setPrompt('negative', value),
|
|
2477
|
+
}))
|
|
2478
|
+
}
|
|
2479
|
+
body.push(h('div', { key: 'prompts', className: 'sc-promptGroup' }, promptItems))
|
|
2480
|
+
} else {
|
|
2481
|
+
body.push(h('p', { key: 'noPrompts', className: 'sc-muted' }, t('wf.promptNone')))
|
|
2482
|
+
}
|
|
2483
|
+
const capabilities = workflow.capabilities && typeof workflow.capabilities === 'object' ? workflow.capabilities : {}
|
|
2484
|
+
const capabilityLabels = Array.isArray(capabilities.kindLabels) ? capabilities.kindLabels : []
|
|
2485
|
+
const neededInputs = Array.isArray(capabilities.neededInputs) ? capabilities.neededInputs : []
|
|
2486
|
+
body.push(h('div', { key: 'meta', className: 'sc-section' },
|
|
2487
|
+
h('div', { className: 'sc-sectionHead' },
|
|
2488
|
+
h('span', { className: 'sc-sectionTitle' }, t('wf.capabilities')),
|
|
2489
|
+
h('span', { className: 'sc-cardCount' }, String(capabilityLabels.length))),
|
|
2490
|
+
capabilityLabels.length > 0
|
|
2491
|
+
? h('div', { className: 'sc-kindChips' }, capabilityLabels.map((label, index) => h('span', { key: index, className: 'sc-kindChip' }, String(label))))
|
|
2492
|
+
: null,
|
|
2493
|
+
typeof capabilities.summary === 'string' && capabilities.summary
|
|
2494
|
+
? h('p', { className: 'sc-muted' }, capabilities.summary)
|
|
2495
|
+
: null,
|
|
2496
|
+
isServer
|
|
2497
|
+
? h('p', { className: 'sc-muted' }, t('wf.serverReadonly'))
|
|
2498
|
+
: [
|
|
2499
|
+
h(Field, { key: 'desc', label: t('wf.description'), htmlFor: 'sc-meta-desc' },
|
|
2500
|
+
h('textarea', {
|
|
2501
|
+
id: 'sc-meta-desc',
|
|
2502
|
+
className: 'sc-textarea',
|
|
2503
|
+
rows: 3,
|
|
2504
|
+
maxLength: 500,
|
|
2505
|
+
value: meta.description,
|
|
2506
|
+
placeholder: t('wf.descriptionHint'),
|
|
2507
|
+
disabled: running,
|
|
2508
|
+
onChange: (event) => setMeta((previous) => ({ ...previous, description: event.target.value, saved: false, error: null })),
|
|
2509
|
+
})),
|
|
2510
|
+
h(Field, { key: 'tags', label: t('wf.tags'), htmlFor: 'sc-meta-tags' },
|
|
2511
|
+
h('input', {
|
|
2512
|
+
id: 'sc-meta-tags',
|
|
2513
|
+
className: 'sc-input',
|
|
2514
|
+
type: 'text',
|
|
2515
|
+
value: meta.tags,
|
|
2516
|
+
placeholder: t('wf.tagsHint'),
|
|
2517
|
+
disabled: running,
|
|
2518
|
+
onChange: (event) => setMeta((previous) => ({ ...previous, tags: event.target.value, saved: false, error: null })),
|
|
2519
|
+
})),
|
|
2520
|
+
h('div', { key: 'save', className: 'sc-btnRow' },
|
|
2521
|
+
h('button', {
|
|
2522
|
+
type: 'button',
|
|
2523
|
+
className: 'sc-btn sc-btnPrimary',
|
|
2524
|
+
onClick: saveMeta,
|
|
2525
|
+
disabled: meta.phase === 'saving' || metaInvalid || running,
|
|
2526
|
+
'aria-busy': meta.phase === 'saving' ? 'true' : 'false',
|
|
2527
|
+
},
|
|
2528
|
+
meta.phase === 'saving' ? h(Spinner) : h(Icon, { name: 'check', size: 13 }),
|
|
2529
|
+
meta.phase === 'saving' ? t('common.saving') : t('wf.saveMeta')),
|
|
2530
|
+
meta.saved ? h('span', { className: 'sc-okLine', role: 'status' }, t('wf.savedMeta')) : null,
|
|
2531
|
+
metaInvalid ? h('span', { className: 'sc-muted' }, t('wf.metaInvalid')) : null),
|
|
2532
|
+
meta.error ? h(InlineError, { key: 'metaError', t, message: meta.error }) : null,
|
|
2533
|
+
],
|
|
2534
|
+
neededInputs.length > 0
|
|
2535
|
+
? h('div', { className: 'sc-needList' },
|
|
2536
|
+
h('p', { className: 'sc-sectionTitle' }, t('wf.needsInputTitle')),
|
|
2537
|
+
neededInputs.map((item, index) => h('div', { key: index, className: 'sc-needRow' },
|
|
2538
|
+
h('code', { className: 'sc-needPath' }, '#' + String(item && item.param ? item.param : '')),
|
|
2539
|
+
h('span', { className: 'sc-needLabel' }, String(item && item.label ? item.label : '')),
|
|
2540
|
+
h('span', { className: 'sc-needHint' }, String(item && item.hint ? item.hint : '')))))
|
|
2541
|
+
: null))
|
|
2542
|
+
body.push(h('div', { key: 'params', className: 'sc-section' },
|
|
2543
|
+
h('div', { className: 'sc-sectionHead' },
|
|
2544
|
+
h('span', { className: 'sc-sectionTitle' }, t('wf.paramsTitle')),
|
|
2545
|
+
h('span', { className: 'sc-cardCount' }, t('wf.params', { n: String(shownParams.length) }))),
|
|
2546
|
+
shownParams.length > 0
|
|
2547
|
+
? h('div', { className: 'sc-params' }, shownParams.map((param) => h(ParamControl, {
|
|
2548
|
+
key: param.path,
|
|
2549
|
+
param,
|
|
2550
|
+
value: overrides[param.path],
|
|
2551
|
+
t,
|
|
2552
|
+
disabled: running,
|
|
2553
|
+
onChange: (value) => setParam(param.path, value),
|
|
2554
|
+
})))
|
|
2555
|
+
: h('p', { className: 'sc-muted' }, t('wf.paramsEmpty'))))
|
|
2556
|
+
body.push(h('details', { key: 'nodes', className: 'sc-details' },
|
|
2557
|
+
h('summary', { className: 'sc-detailsSummary' }, t('wf.nodesTitle') + ' · ' + String(nodes.length)),
|
|
2558
|
+
h('ul', { className: 'sc-nodeList' }, nodes.map((node) => h('li', {
|
|
2559
|
+
key: node.id,
|
|
2560
|
+
className: 'sc-nodeItem',
|
|
2561
|
+
},
|
|
2562
|
+
h('span', { className: 'sc-nodeId' }, '#' + String(node.id)),
|
|
2563
|
+
h('span', { className: 'sc-nodeClass' }, node.class ? String(node.class) : ''),
|
|
2564
|
+
node.title ? h('span', { className: 'sc-nodeTitle' }, String(node.title)) : null)))))
|
|
2565
|
+
body.push(h('div', { key: 'runbar', className: 'sc-runBar' },
|
|
2566
|
+
h('button', {
|
|
2567
|
+
type: 'button',
|
|
2568
|
+
className: 'sc-btn sc-btnPrimary',
|
|
2569
|
+
onClick: runNow,
|
|
2570
|
+
disabled: running,
|
|
2571
|
+
'aria-busy': running ? 'true' : 'false',
|
|
2572
|
+
},
|
|
2573
|
+
running ? h(Spinner) : h(Icon, { name: 'play', size: 13 }),
|
|
2574
|
+
running ? t('wf.running') : t('wf.run')),
|
|
2575
|
+
h('button', {
|
|
2576
|
+
type: 'button',
|
|
2577
|
+
className: 'sc-btn',
|
|
2578
|
+
onClick: resetDefaults,
|
|
2579
|
+
disabled: running,
|
|
2580
|
+
}, h(Icon, { name: 'refresh', size: 13 }), t('wf.resetDefaults')),
|
|
2581
|
+
running && elapsedMs !== null
|
|
2582
|
+
? h('span', { className: 'sc-runInfo' }, t('wf.elapsed', { v: fmtDuration(elapsedMs) }))
|
|
2583
|
+
: null))
|
|
2584
|
+
body.push(h(RunResult, { key: 'result', t, run, elapsedMs }))
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
return h(Card, {
|
|
2588
|
+
icon: 'workflow',
|
|
2589
|
+
title: workflow ? workflow.name : (props.fallbackName || t('wf.title')),
|
|
2590
|
+
count: workflow ? sourceLabel(workflow.source, t) : null,
|
|
2591
|
+
actions,
|
|
2592
|
+
}, body)
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
/* ── 运行记录卡 ──────────────────────────────────────────────────────── */
|
|
2596
|
+
function RunsCard(props) {
|
|
2597
|
+
const t = props.t
|
|
2598
|
+
const runs = Array.isArray(props.runs) ? props.runs.slice(0, RUN_ROWS) : []
|
|
2599
|
+
let body
|
|
2600
|
+
if (runs.length === 0) {
|
|
2601
|
+
body = h('p', { className: 'sc-empty' }, t('runs.empty'))
|
|
2602
|
+
} else {
|
|
2603
|
+
body = h('div', { className: 'sc-runList' }, runs.map((run, index) => {
|
|
2604
|
+
const state = run && run.state ? String(run.state) : 'queued'
|
|
2605
|
+
const images = run && Array.isArray(run.images)
|
|
2606
|
+
? run.images.filter((image) => image && (image.url || image.filename))
|
|
2607
|
+
: []
|
|
2608
|
+
return h('div', { key: (run && run.promptId) || index, className: 'sc-runRow' },
|
|
2609
|
+
h(Pill, { tone: runTone(state) }, runStateLabel(state, t)),
|
|
2610
|
+
h('div', { className: 'sc-runMain' },
|
|
2611
|
+
h('div', { className: 'sc-runTitle' }, (run && run.workflowName) || '—'),
|
|
2612
|
+
h('div', { className: 'sc-runMeta' },
|
|
2613
|
+
h('span', null, fmtTime(run && run.createdAt)),
|
|
2614
|
+
run && Number.isFinite(Number(run.durationMs))
|
|
2615
|
+
? h('span', null, t('wf.elapsed', { v: fmtDuration(Number(run.durationMs)) }))
|
|
2616
|
+
: null),
|
|
2617
|
+
run && run.error
|
|
2618
|
+
? h('p', { className: 'sc-errorText sc-errorLine', role: 'alert' }, String(run.error))
|
|
2619
|
+
: null),
|
|
2620
|
+
images.length > 0
|
|
2621
|
+
? h('div', { className: 'sc-thumbRow' }, images.slice(0, 3).map((image, imageIndex) => {
|
|
2622
|
+
const url = image.url || imageUrl(image)
|
|
2623
|
+
const filename = image.filename ? String(image.filename) : 'image-' + (imageIndex + 1)
|
|
2624
|
+
return h('button', {
|
|
2625
|
+
key: imageIndex,
|
|
2626
|
+
type: 'button',
|
|
2627
|
+
className: 'sc-thumbWrap',
|
|
2628
|
+
title: filename,
|
|
2629
|
+
onClick: () => openImage(url),
|
|
2630
|
+
}, h('img', {
|
|
2631
|
+
className: 'sc-thumb',
|
|
2632
|
+
src: url,
|
|
2633
|
+
alt: filename,
|
|
2634
|
+
loading: 'lazy',
|
|
2635
|
+
onError: (event) => {
|
|
2636
|
+
const node = event.currentTarget
|
|
2637
|
+
if (node && node.style) node.style.display = 'none'
|
|
2638
|
+
},
|
|
2639
|
+
}))
|
|
2640
|
+
}))
|
|
2641
|
+
: null)
|
|
2642
|
+
}))
|
|
2643
|
+
}
|
|
2644
|
+
return h(Card, {
|
|
2645
|
+
icon: 'clock',
|
|
2646
|
+
title: t('runs.title'),
|
|
2647
|
+
count: runs.length > 0 ? t('runs.count', { n: String(runs.length) }) : null,
|
|
2648
|
+
}, body)
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
/* ── 主面板 ──────────────────────────────────────────────────────────── */
|
|
2652
|
+
function ComfyPanel(props) {
|
|
2653
|
+
const t = props.t
|
|
2654
|
+
const locale = props.locale
|
|
2655
|
+
useLocaleTick(locale)
|
|
2656
|
+
const [boot, setBoot] = useState({ phase: 'loading' })
|
|
2657
|
+
const [test, setTest] = useState({ phase: 'idle', data: null, error: null })
|
|
2658
|
+
const [stateSeq, setStateSeq] = useState(0)
|
|
2659
|
+
const [testSeq, setTestSeq] = useState(0)
|
|
2660
|
+
const [tab, setTab] = useState('workflows')
|
|
2661
|
+
const tabTouched = useRef(false)
|
|
2662
|
+
|
|
2663
|
+
useEffect(() => {
|
|
2664
|
+
let cancelled = false
|
|
2665
|
+
setBoot((previous) => (previous.phase === 'ok' ? previous : { phase: 'loading' }))
|
|
2666
|
+
api('/state').then((data) => {
|
|
2667
|
+
if (cancelled) return
|
|
2668
|
+
const normalized = normalizeState(data)
|
|
2669
|
+
setBoot({ phase: 'ok', data: normalized, refreshError: null })
|
|
2670
|
+
if (!normalized.baseUrl && !tabTouched.current) setTab('connection')
|
|
2671
|
+
}).catch((error) => {
|
|
2672
|
+
if (cancelled) return
|
|
2673
|
+
setBoot((previous) => {
|
|
2674
|
+
if (previous.phase === 'ok') return { ...previous, refreshError: humanError(error, t) }
|
|
2675
|
+
return { phase: 'error', error }
|
|
2676
|
+
})
|
|
2677
|
+
})
|
|
2678
|
+
return () => {
|
|
2679
|
+
cancelled = true
|
|
2680
|
+
}
|
|
2681
|
+
}, [stateSeq])
|
|
2682
|
+
|
|
2683
|
+
const baseUrl = boot.phase === 'ok' ? boot.data.baseUrl : ''
|
|
2684
|
+
|
|
2685
|
+
useEffect(() => {
|
|
2686
|
+
if (boot.phase !== 'ok') return undefined
|
|
2687
|
+
let cancelled = false
|
|
2688
|
+
setTest({ phase: 'loading', data: null, error: null })
|
|
2689
|
+
api('/test', {
|
|
2690
|
+
method: 'POST',
|
|
2691
|
+
body: baseUrl ? { baseUrl } : {},
|
|
2692
|
+
allowFail: true,
|
|
2693
|
+
}).then((data) => {
|
|
2694
|
+
if (cancelled) return
|
|
2695
|
+
if (data && data.ok === true) {
|
|
2696
|
+
setTest({ phase: 'ok', data, error: null })
|
|
2697
|
+
return
|
|
2698
|
+
}
|
|
2699
|
+
setTest({
|
|
2700
|
+
phase: 'error',
|
|
2701
|
+
data: data || null,
|
|
2702
|
+
error: (data && typeof data.error === 'string' && data.error) || t('conn.testFailed'),
|
|
2703
|
+
})
|
|
2704
|
+
}).catch((error) => {
|
|
2705
|
+
if (cancelled) return
|
|
2706
|
+
setTest({ phase: 'error', data: null, error: humanError(error, t) })
|
|
2707
|
+
})
|
|
2708
|
+
return () => {
|
|
2709
|
+
cancelled = true
|
|
2710
|
+
}
|
|
2711
|
+
}, [boot.phase, baseUrl, testSeq])
|
|
2712
|
+
|
|
2713
|
+
function reloadState() {
|
|
2714
|
+
setStateSeq((value) => value + 1)
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
function refreshAll() {
|
|
2718
|
+
setStateSeq((value) => value + 1)
|
|
2719
|
+
setTestSeq((value) => value + 1)
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
function selectTab(next) {
|
|
2723
|
+
tabTouched.current = true
|
|
2724
|
+
setTab(next)
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
let pill
|
|
2728
|
+
if (boot.phase === 'loading') pill = { tone: 'busy', label: t('common.loading') }
|
|
2729
|
+
else if (boot.phase === 'error') pill = { tone: 'error', label: t('conn.disconnected') }
|
|
2730
|
+
else if (!boot.data.baseUrl) pill = { tone: 'neutral', label: t('conn.unconfigured') }
|
|
2731
|
+
else if (test.phase === 'loading') pill = { tone: 'busy', label: t('conn.testing') }
|
|
2732
|
+
else if (test.phase === 'ok') pill = { tone: 'ok', label: t('conn.connected') }
|
|
2733
|
+
else if (test.phase === 'error') pill = { tone: 'error', label: t('conn.disconnected') }
|
|
2734
|
+
else pill = { tone: 'neutral', label: t('conn.unknown') }
|
|
2735
|
+
|
|
2736
|
+
const busy = boot.phase === 'loading' || test.phase === 'loading'
|
|
2737
|
+
|
|
2738
|
+
let tabsBar = null
|
|
2739
|
+
let body
|
|
2740
|
+
if (boot.phase === 'loading') {
|
|
2741
|
+
body = h('div', { className: 'sc-loading' }, h(Spinner), h('span', null, t('common.loading')))
|
|
2742
|
+
} else if (boot.phase === 'error') {
|
|
2743
|
+
body = h('div', { className: 'sc-card' },
|
|
2744
|
+
h('div', { className: 'sc-errorBox' },
|
|
2745
|
+
h(InlineError, { t, message: humanError(boot.error, t), onRetry: refreshAll })))
|
|
2746
|
+
} else {
|
|
2747
|
+
const tabs = [
|
|
2748
|
+
{ id: 'workflows', label: t('tab.workflows'), icon: 'workflow', count: boot.data.workflows.length },
|
|
2749
|
+
{ id: 'models', label: t('tab.models'), icon: 'stack', count: null },
|
|
2750
|
+
{ id: 'runs', label: t('tab.runs'), icon: 'clock', count: boot.data.lastRuns.length },
|
|
2751
|
+
{ id: 'connection', label: t('tab.connection'), icon: 'server', count: null },
|
|
2752
|
+
]
|
|
2753
|
+
const activeTab = tabs.some((item) => item.id === tab) ? tab : 'workflows'
|
|
2754
|
+
tabsBar = h('nav', { className: 'sc-tabs', role: 'tablist', 'aria-label': t('panel.title') },
|
|
2755
|
+
h('div', { className: 'sc-tabsInner' },
|
|
2756
|
+
tabs.map((item) => h('button', {
|
|
2757
|
+
key: item.id,
|
|
2758
|
+
type: 'button',
|
|
2759
|
+
role: 'tab',
|
|
2760
|
+
'aria-selected': activeTab === item.id ? 'true' : 'false',
|
|
2761
|
+
className: 'sc-tab',
|
|
2762
|
+
onClick: () => selectTab(item.id),
|
|
2763
|
+
},
|
|
2764
|
+
h(Icon, { name: item.icon, size: 14 }),
|
|
2765
|
+
h('span', { className: 'sc-tabLabel' }, item.label),
|
|
2766
|
+
item.count !== null && item.count !== undefined && item.count > 0
|
|
2767
|
+
? h('span', { className: 'sc-tabCount' }, String(item.count))
|
|
2768
|
+
: null))))
|
|
2769
|
+
if (activeTab === 'connection') {
|
|
2770
|
+
body = h(ConnectionCard, {
|
|
2771
|
+
key: 'connection', t, data: boot.data, test,
|
|
2772
|
+
onSaved: refreshAll, onRetest: refreshAll,
|
|
2773
|
+
})
|
|
2774
|
+
} else if (activeTab === 'models') {
|
|
2775
|
+
body = h(ModelsCard, {
|
|
2776
|
+
key: 'models',
|
|
2777
|
+
t,
|
|
2778
|
+
ready: true,
|
|
2779
|
+
baseUrl: boot.data.baseUrl,
|
|
2780
|
+
onOpenConnection: () => selectTab('connection'),
|
|
2781
|
+
})
|
|
2782
|
+
} else if (activeTab === 'runs') {
|
|
2783
|
+
body = h(RunsCard, { key: 'runs', t, runs: boot.data.lastRuns })
|
|
2784
|
+
} else {
|
|
2785
|
+
body = h(ServerWorkflowsCard, {
|
|
2786
|
+
key: 'workflows',
|
|
2787
|
+
t,
|
|
2788
|
+
baseUrl: boot.data.baseUrl,
|
|
2789
|
+
onOpenConnection: () => selectTab('connection'),
|
|
2790
|
+
})
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
return h('div', { className: 'sc-page' },
|
|
2795
|
+
h('header', { className: 'sc-head' },
|
|
2796
|
+
h('div', { className: 'sc-titleGroup' },
|
|
2797
|
+
h('h1', { className: 'sc-title' }, t('panel.title')),
|
|
2798
|
+
h('div', { className: 'sc-subRow' },
|
|
2799
|
+
h('p', { className: 'sc-sub' }, t('panel.subtitle')),
|
|
2800
|
+
h('span', { className: 'sc-version', title: t('panel.version') }, t('panel.version')))),
|
|
2801
|
+
h('div', { className: 'sc-headActions' },
|
|
2802
|
+
h(Pill, { tone: pill.tone }, pill.label),
|
|
2803
|
+
h('button', {
|
|
2804
|
+
type: 'button',
|
|
2805
|
+
className: 'sc-btn',
|
|
2806
|
+
onClick: refreshAll,
|
|
2807
|
+
disabled: busy,
|
|
2808
|
+
'aria-busy': busy ? 'true' : 'false',
|
|
2809
|
+
title: t('common.refresh'),
|
|
2810
|
+
}, busy ? h(Spinner) : h(Icon, { name: 'refresh' }), t('common.refresh'))),
|
|
2811
|
+
boot.phase === 'ok' && boot.refreshError
|
|
2812
|
+
? h('div', { className: 'sc-headError' },
|
|
2813
|
+
h(InlineError, { t, message: boot.refreshError, onRetry: refreshAll }))
|
|
2814
|
+
: null),
|
|
2815
|
+
tabsBar,
|
|
2816
|
+
h('div', { className: 'sc-scroll' }, body))
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
return {
|
|
2820
|
+
inject: ['slots', 'layout', 'locale'],
|
|
2821
|
+
apply(ctx) {
|
|
2822
|
+
const style = document.createElement('style')
|
|
2823
|
+
style.setAttribute('data-plugin-css', 'dsh-sendcomfy')
|
|
2824
|
+
style.textContent = CSS
|
|
2825
|
+
document.head.appendChild(style)
|
|
2826
|
+
ctx.effect(() => () => style.remove(), 'dsh-sendcomfy: styles')
|
|
2827
|
+
|
|
2828
|
+
const slots = (typeof ctx.get === 'function' ? ctx.get('slots') : undefined) || ctx.slots
|
|
2829
|
+
if (!slots) return
|
|
2830
|
+
|
|
2831
|
+
const locale = (typeof ctx.get === 'function' ? ctx.get('locale') : undefined) || ctx.locale
|
|
2832
|
+
let t = fallbackT
|
|
2833
|
+
if (locale && typeof locale.register === 'function' && typeof locale.bind === 'function') {
|
|
2834
|
+
ctx.effect(() => locale.register(NS, { zh: ZH, en: EN }), 'dsh-sendcomfy: dictionaries')
|
|
2835
|
+
t = locale.bind(NS)
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
// 侧栏图标:id 与 main 的 key 相同,shell 会自动按 id 派发到主面板
|
|
2839
|
+
slots.inject('sidebar.panellist', () => slots.register(
|
|
2840
|
+
{ name: 'sidebar.panellist', id: PANEL_ID, order: 6, label: () => t('panel.title') },
|
|
2841
|
+
(iconProps) => h(ComfyIcon, iconProps),
|
|
2842
|
+
))
|
|
2843
|
+
// 主栏面板(root scope:不依赖 Session,点开即用)
|
|
2844
|
+
slots.inject('main', () => slots.register(
|
|
2845
|
+
{ name: 'main', key: PANEL_ID },
|
|
2846
|
+
() => h(ComfyPanel, { t, locale }),
|
|
2847
|
+
))
|
|
2848
|
+
},
|
|
2849
|
+
}
|
|
2850
|
+
},
|
|
2851
|
+
})
|