@xmanrui/dsh-im 5.9.1 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PROACTIVE_DELIVERY.en.md +33 -9
- package/PROACTIVE_DELIVERY.md +33 -9
- package/README.en.md +42 -7
- package/README.md +46 -8
- package/bin/dsh-im.mjs +65 -0
- package/docs/client-integration.md +4 -0
- package/lib/client.js +1735 -203
- package/lib/index.js +367 -341
- package/package.json +7 -6
- package/plugin-src/client/access-policy-settings.js +210 -12
- package/plugin-src/client/bot-general-settings.js +44 -3
- package/plugin-src/client/delivery-settings.js +2 -0
- package/plugin-src/client/delivery-sync-settings.js +269 -0
- package/plugin-src/client/global-settings.js +45 -7
- package/plugin-src/client/i18n-ru.js +112 -0
- package/plugin-src/client/i18n.js +110 -0
- package/plugin-src/client/im-channels.js +419 -0
- package/plugin-src/client/index.js +50 -2
- package/plugin-src/client/model-setting.js +6 -3
- package/plugin-src/client/styles.js +23 -7
- package/plugin-src/client/update-panel.js +2 -1
- package/plugin-src/host/channel-list-rpc.mjs +280 -0
- package/plugin-src/host/channels/dingtalk/production.mjs +28 -10
- package/plugin-src/host/channels/dingtalk/rpc.mjs +10 -1
- package/plugin-src/host/channels/feishu/production.mjs +50 -37
- package/plugin-src/host/channels/feishu/rpc.mjs +10 -1
- package/plugin-src/host/channels/matrix/production.mjs +28 -10
- package/plugin-src/host/channels/matrix/rpc.mjs +10 -0
- package/plugin-src/host/channels/qq/production.mjs +30 -11
- package/plugin-src/host/channels/qq/rpc.mjs +10 -1
- package/plugin-src/host/channels/shared/access-policy-production.mjs +9 -0
- package/plugin-src/host/channels/shared/binding-events.mjs +109 -0
- package/plugin-src/host/channels/shared/production.mjs +14 -1
- package/plugin-src/host/channels/shared/reply-content-rpc.mjs +17 -0
- package/plugin-src/host/channels/shared/rpc.mjs +9 -0
- package/plugin-src/host/channels/shared/workspace-rpc.mjs +1 -0
- package/plugin-src/host/channels/slack/production.mjs +28 -10
- package/plugin-src/host/channels/slack/rpc.mjs +10 -0
- package/plugin-src/host/channels/telegram/production.mjs +5 -0
- package/plugin-src/host/channels/wecom/production.mjs +28 -10
- package/plugin-src/host/channels/wecom/rpc.mjs +10 -1
- package/plugin-src/host/channels/wecom-app/production.mjs +28 -10
- package/plugin-src/host/channels/wecom-app/rpc.mjs +9 -0
- package/plugin-src/host/channels/weixin/production.mjs +28 -10
- package/plugin-src/host/channels/weixin/rpc.mjs +10 -1
- package/plugin-src/host/channels/whatsapp/production.mjs +28 -10
- package/plugin-src/host/channels/whatsapp/rpc.mjs +10 -1
- package/plugin-src/host/delivery-adapter.mjs +35 -20
- package/plugin-src/host/delivery-service.mjs +99 -1
- package/plugin-src/host/delivery-suggestions.mjs +31 -1
- package/plugin-src/host/delivery-sync-rpc.mjs +100 -0
- package/plugin-src/host/harness-connection.mjs +2 -1
- package/plugin-src/host/harness-peer.mjs +3 -1
- package/plugin-src/host/host-language-rpc.mjs +16 -2
- package/plugin-src/host/host-language.mjs +29 -0
- package/plugin-src/host/index.mjs +30 -1
- package/plugin-src/host/modern-harness-api.mjs +5 -1
- package/plugin-src/host/root-scope.mjs +32 -0
- package/plugin-src/host/session-sync-coordinator.mjs +290 -122
- package/plugin-src/host/session-sync-targets.mjs +71 -0
- package/plugin-src/management-rpc.mjs +18 -2
- package/scripts/verify-package.mjs +48 -10
- package/src/channels/dingtalk/dingtalk-bridge.mjs +50 -6
- package/src/channels/dingtalk/state-store.mjs +56 -0
- package/src/channels/discord/discord-api.mjs +2 -1
- package/src/channels/feishu/bridge.mjs +154 -58
- package/src/channels/feishu/feishu-cards.mjs +10 -4
- package/src/channels/feishu/feishu-runtime.mjs +11 -3
- package/src/channels/feishu/message-utils.mjs +106 -30
- package/src/channels/feishu/slash-command-panel.mjs +26 -0
- package/src/channels/feishu/state-store.mjs +14 -0
- package/src/channels/matrix/matrix-api.mjs +2 -1
- package/src/channels/qq/qq-bridge.mjs +114 -14
- package/src/channels/qq/state-store.mjs +55 -1
- package/src/channels/shared/access-policy.mjs +60 -7
- package/src/channels/shared/action-card.mjs +83 -7
- package/src/channels/shared/bot-workspace-store.mjs +255 -11
- package/src/channels/shared/busy-message-dispatcher.mjs +2 -2
- package/src/channels/shared/channel-capabilities.mjs +44 -0
- package/src/channels/shared/command-catalog.mjs +68 -3
- package/src/channels/shared/command-permission.mjs +6 -2
- package/src/channels/shared/conversation-state-store.mjs +16 -0
- package/src/channels/shared/deferred-delivery-coordinator.mjs +6 -1
- package/src/channels/shared/deferred-delivery.mjs +4 -0
- package/src/channels/shared/delivery-sync-settings-store.mjs +86 -0
- package/src/channels/shared/delivery-sync-settings.mjs +122 -0
- package/src/channels/shared/diagnostic-details.mjs +6 -1
- package/src/channels/shared/failure-log-file.mjs +79 -0
- package/src/channels/shared/harness-client.mjs +259 -96
- package/src/channels/shared/i18n-en/diagnostics.mjs +1 -0
- package/src/channels/shared/i18n-en/feishu.mjs +2 -2
- package/src/channels/shared/i18n-en/shared-a.mjs +13 -2
- package/src/channels/shared/i18n-en/shared-b.mjs +73 -4
- package/src/channels/shared/i18n-en/shared-d.mjs +144 -0
- package/src/channels/shared/i18n-en/weixin.mjs +4 -0
- package/src/channels/shared/i18n-en.mjs +2 -0
- package/src/channels/shared/i18n-ru/diagnostics.mjs +1 -0
- package/src/channels/shared/i18n-ru/feishu.mjs +2 -2
- package/src/channels/shared/i18n-ru/shared-a.mjs +13 -2
- package/src/channels/shared/i18n-ru/shared-b.mjs +72 -4
- package/src/channels/shared/i18n-ru/shared-d.mjs +144 -0
- package/src/channels/shared/i18n-ru/weixin.mjs +4 -0
- package/src/channels/shared/i18n-ru.mjs +2 -0
- package/src/channels/shared/inbound-access.mjs +10 -0
- package/src/channels/shared/interface-language-store.mjs +49 -10
- package/src/channels/shared/interface-language.mjs +19 -1
- package/src/channels/shared/markdown-chunks.mjs +5 -0
- package/src/channels/shared/message-failure.mjs +22 -1
- package/src/channels/shared/model-setting.mjs +6 -3
- package/src/channels/shared/new-command.mjs +158 -4
- package/src/channels/shared/plan-goal-command.mjs +132 -0
- package/src/channels/shared/qrcode.mjs +5 -0
- package/src/channels/shared/reply-content.mjs +102 -0
- package/src/channels/shared/reset-command.mjs +46 -0
- package/src/channels/shared/semantic/artifact.mjs +133 -29
- package/src/channels/shared/semantic/reply-reference.mjs +18 -3
- package/src/channels/shared/session-nav-command.mjs +999 -0
- package/src/channels/shared/session-ring-support.mjs +184 -0
- package/src/channels/shared/session-ring.mjs +202 -0
- package/src/channels/shared/session-title.mjs +11 -0
- package/src/channels/shared/status-command.mjs +2 -1
- package/src/channels/shared/text-harness-bridge.mjs +166 -7
- package/src/channels/shared/workspace-command.mjs +567 -31
- package/src/channels/shared/workspace-session.mjs +52 -4
- package/src/channels/slack/slack-api.mjs +2 -1
- package/src/channels/telegram/config-store.mjs +10 -2
- package/src/channels/telegram/telegram-api.mjs +19 -1
- package/src/channels/telegram/telegram-rich-message.mjs +17 -5
- package/src/channels/telegram/telegram-runtime.mjs +14 -1
- package/src/channels/wecom/state-store.mjs +13 -1
- package/src/channels/wecom/wecom-bridge.mjs +183 -26
- package/src/channels/wecom-app/state-store.mjs +13 -1
- package/src/channels/wecom-app/wecom-app-bridge.mjs +44 -4
- package/src/channels/weixin/state-store.mjs +13 -1
- package/src/channels/weixin/weixin-bridge.mjs +71 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmanrui/dsh-im",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"icon": "./assets/logo-plugin-message-link-gradient.webp",
|
|
5
5
|
"description": "把微信、飞书、企微、钉钉、QQ、Telegram、WhatsApp、Slack、Discord、Matrix接入DSH。 Connect Telegram, WhatsApp, Slack, Discord, Matrix, WeChat, Feishu, WeCom, DingTalk, and QQ to DSH.",
|
|
6
6
|
"keywords": [
|
|
@@ -81,18 +81,19 @@
|
|
|
81
81
|
"client": {
|
|
82
82
|
"inject": [
|
|
83
83
|
"@deepseek-ai/dsh-client-connection",
|
|
84
|
-
"@deepseek-ai/dsh-client-
|
|
84
|
+
"@deepseek-ai/dsh-client-locale",
|
|
85
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
85
86
|
"@deepseek-ai/dsh-client-ui-settings",
|
|
86
|
-
"@deepseek-ai/dsh-client-ui-
|
|
87
|
-
"@deepseek-ai/dsh-client-locale"
|
|
87
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
88
88
|
],
|
|
89
89
|
"platform": "web"
|
|
90
90
|
},
|
|
91
91
|
"compatibility": {
|
|
92
|
-
"dsh": "0.2.
|
|
92
|
+
"dsh": "0.2.2-rc.5",
|
|
93
93
|
"dshReleases": {
|
|
94
94
|
"0.2.0-rc.2": "compatible",
|
|
95
|
-
"0.2.1-rc.2": "compatible"
|
|
95
|
+
"0.2.1-rc.2": "compatible",
|
|
96
|
+
"0.2.2-rc.5": "compatible"
|
|
96
97
|
},
|
|
97
98
|
"profiles": [
|
|
98
99
|
"web"
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
normalizeAccessPolicy,
|
|
6
6
|
validateAccessPolicy,
|
|
7
7
|
} from '../../src/channels/shared/access-policy.mjs';
|
|
8
|
-
import { h, localizeText } from './i18n.js';
|
|
8
|
+
import { h, localizeText, localizeTemplate } from './i18n.js';
|
|
9
9
|
|
|
10
10
|
export const ACCESS_POLICY_ENDPOINT = 'bot.access-policy.set';
|
|
11
11
|
const CONFIRMED_OWNER_CHANNELS = new Set(['weixin', 'feishu', 'qq', 'whatsapp', 'discord']);
|
|
@@ -77,6 +77,37 @@ export const ACCESS_CHANNEL_DEFINITIONS = Object.freeze({
|
|
|
77
77
|
}),
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
const DEFAULT_COMMAND_ALLOWLIST = Object.freeze(['new', 'stop', 'help', 'status', 'compact', 'clear']);
|
|
81
|
+
|
|
82
|
+
const COMMAND_CHOICES = Object.freeze([
|
|
83
|
+
['new', '/new 新会话'],
|
|
84
|
+
['stop', '/stop 停止任务'],
|
|
85
|
+
['help', '/help 帮助'],
|
|
86
|
+
['status', '/status 连接状态'],
|
|
87
|
+
['compact', '/compact 压缩上下文'],
|
|
88
|
+
['clear', '/clear 清空上下文'],
|
|
89
|
+
['menu', '/m 或 /menu 菜单'],
|
|
90
|
+
['version', '/version 版本'],
|
|
91
|
+
['models', '/models 模型列表'],
|
|
92
|
+
['model', '/model 模型切换'],
|
|
93
|
+
['reasoninglist', '/reasonings 推理等级'],
|
|
94
|
+
['reasoning', '/reasoning 推理等级切换'],
|
|
95
|
+
['presetlist', '/presets 预设列表'],
|
|
96
|
+
['preset', '/preset 预设切换'],
|
|
97
|
+
['permissionlist', '/permissionlist 权限列表'],
|
|
98
|
+
['permission', '/permission 权限切换'],
|
|
99
|
+
['history', '/history 历史消息'],
|
|
100
|
+
['workspace', '/workspace 工作区'],
|
|
101
|
+
['workspacelist', '/workspaces 工作区列表'],
|
|
102
|
+
['sessionlist', '/sessionlist 会话列表'],
|
|
103
|
+
['session', '/session 绑定会话'],
|
|
104
|
+
['batch', '/batch 批量输入'],
|
|
105
|
+
['send', '/send 发送批量'],
|
|
106
|
+
['cancel', '/cancel 取消批量'],
|
|
107
|
+
['steer', '/steer 补充指令'],
|
|
108
|
+
['repair', '/repair 修复'],
|
|
109
|
+
]);
|
|
110
|
+
|
|
80
111
|
function clonePolicy(policy) {
|
|
81
112
|
const cloneScope = (scope) => ({
|
|
82
113
|
mode: scope.mode,
|
|
@@ -84,7 +115,9 @@ function clonePolicy(policy) {
|
|
|
84
115
|
defaultCanExecuteCommands: scope.open.defaultCanExecuteCommands,
|
|
85
116
|
commandPermissionOverrides: scope.open.commandPermissionOverrides.map((user) => ({
|
|
86
117
|
...user,
|
|
118
|
+
...(user.commandAllowlist === undefined ? {} : { commandAllowlist: [...user.commandAllowlist] }),
|
|
87
119
|
})),
|
|
120
|
+
...(scope.open.commandAllowlist === undefined ? {} : { commandAllowlist: [...scope.open.commandAllowlist] }),
|
|
88
121
|
},
|
|
89
122
|
allowlist: {
|
|
90
123
|
users: scope.allowlist.users.map((user) => ({ ...user })),
|
|
@@ -147,6 +180,41 @@ function ScenePolicyEditor({
|
|
|
147
180
|
const updateUser = (index, patch) => updateUsers(users.map((user, userIndex) => (
|
|
148
181
|
userIndex === index ? { ...user, ...patch } : user
|
|
149
182
|
)));
|
|
183
|
+
const [commandPickerOpen, setCommandPickerOpen] = React.useState(false);
|
|
184
|
+
const [commandQuery, setCommandQuery] = React.useState('');
|
|
185
|
+
const commandMode = policy.open.defaultCanExecuteCommands
|
|
186
|
+
? 'allow'
|
|
187
|
+
: (policy.open.commandAllowlist?.length ? 'custom' : 'deny');
|
|
188
|
+
const allowedCommands = new Set(policy.open.commandAllowlist ?? []);
|
|
189
|
+
const updateOpen = (patch) => onChange({
|
|
190
|
+
...policy,
|
|
191
|
+
open: { ...policy.open, ...patch },
|
|
192
|
+
});
|
|
193
|
+
const changeCommandMode = (nextMode) => {
|
|
194
|
+
if (nextMode === 'allow') {
|
|
195
|
+
updateOpen({ defaultCanExecuteCommands: true, commandAllowlist: undefined });
|
|
196
|
+
setCommandPickerOpen(false);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (nextMode === 'custom') {
|
|
200
|
+
updateOpen({
|
|
201
|
+
defaultCanExecuteCommands: false,
|
|
202
|
+
commandAllowlist: policy.open.commandAllowlist?.length
|
|
203
|
+
? [...policy.open.commandAllowlist]
|
|
204
|
+
: [...DEFAULT_COMMAND_ALLOWLIST],
|
|
205
|
+
});
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
updateOpen({ defaultCanExecuteCommands: false, commandAllowlist: undefined });
|
|
209
|
+
setCommandPickerOpen(false);
|
|
210
|
+
};
|
|
211
|
+
const toggleCommand = (name, checked) => {
|
|
212
|
+
const next = new Set(allowedCommands);
|
|
213
|
+
if (checked) next.add(name);
|
|
214
|
+
else if (next.size > 1) next.delete(name);
|
|
215
|
+
else return;
|
|
216
|
+
updateOpen({ commandAllowlist: [...next] });
|
|
217
|
+
};
|
|
150
218
|
|
|
151
219
|
return h('fieldset', {
|
|
152
220
|
className: 'dim-accessScene',
|
|
@@ -184,21 +252,151 @@ function ScenePolicyEditor({
|
|
|
184
252
|
},
|
|
185
253
|
h('option', { value: 'open' }, '允许所有用户'),
|
|
186
254
|
h('option', { value: 'allowlist' }, '仅白名单用户'))),
|
|
187
|
-
allowlist ? null : h(
|
|
188
|
-
|
|
255
|
+
allowlist ? null : h(React.Fragment, null,
|
|
256
|
+
h('label', { className: 'dim-accessField' },
|
|
257
|
+
h('span', null, '命令权限'),
|
|
189
258
|
h('select', {
|
|
190
|
-
value:
|
|
259
|
+
value: commandMode,
|
|
191
260
|
'aria-label': [localizeText(title), localizeText('默认命令权限')].join(' '),
|
|
192
|
-
onChange: (event) =>
|
|
193
|
-
...policy,
|
|
194
|
-
open: {
|
|
195
|
-
...policy.open,
|
|
196
|
-
defaultCanExecuteCommands: commandValue(event.target.value),
|
|
197
|
-
},
|
|
198
|
-
}),
|
|
261
|
+
onChange: (event) => changeCommandMode(event.target.value),
|
|
199
262
|
},
|
|
263
|
+
h('option', { value: 'deny' }, '不能执行命令'),
|
|
200
264
|
h('option', { value: 'allow' }, '可以执行命令'),
|
|
201
|
-
h('option', { value: '
|
|
265
|
+
h('option', { value: 'custom' }, '可以执行指定的命令'))),
|
|
266
|
+
commandMode !== 'custom' ? null : h('div', {
|
|
267
|
+
className: 'dim-accessField dim-accessCommandPicker',
|
|
268
|
+
style: { position: 'relative' },
|
|
269
|
+
},
|
|
270
|
+
h('button', {
|
|
271
|
+
type: 'button',
|
|
272
|
+
className: 'dim-deliveryButton',
|
|
273
|
+
'aria-expanded': commandPickerOpen,
|
|
274
|
+
onClick: () => setCommandPickerOpen((value) => !value),
|
|
275
|
+
}, localizeTemplate('选择命令({count})', { count: allowedCommands.size })),
|
|
276
|
+
commandPickerOpen ? h('div', {
|
|
277
|
+
role: 'presentation',
|
|
278
|
+
style: {
|
|
279
|
+
position: 'fixed', inset: 0, zIndex: 1000,
|
|
280
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
281
|
+
padding: 24, background: 'rgba(0, 0, 0, 0.42)',
|
|
282
|
+
},
|
|
283
|
+
onClick: () => setCommandPickerOpen(false),
|
|
284
|
+
},
|
|
285
|
+
h('div', {
|
|
286
|
+
role: 'dialog',
|
|
287
|
+
'aria-modal': 'true',
|
|
288
|
+
'aria-label': '选择允许的命令',
|
|
289
|
+
onClick: (event) => event.stopPropagation(),
|
|
290
|
+
style: {
|
|
291
|
+
width: 'min(560px, 100%)',
|
|
292
|
+
maxHeight: 'min(680px, calc(100vh - 48px))',
|
|
293
|
+
display: 'flex', flexDirection: 'column', gap: 12,
|
|
294
|
+
padding: 20, borderRadius: 14,
|
|
295
|
+
border: '1px solid var(--dsw-alias-border-l1)',
|
|
296
|
+
background: 'var(--dsw-alias-bg-overlay)',
|
|
297
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
298
|
+
boxShadow: '0 24px 64px rgba(0, 0, 0, 0.38)',
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 12 } },
|
|
302
|
+
h('div', null,
|
|
303
|
+
h('strong', { style: { fontSize: 15 } }, '选择允许的命令'),
|
|
304
|
+
h('p', { style: { margin: '4px 0 0', fontSize: 12, lineHeight: 1.5, color: 'var(--dsw-alias-label-secondary)' } },
|
|
305
|
+
'默认勾选 new、stop、help、status、compact、clear。')),
|
|
306
|
+
h('button', {
|
|
307
|
+
type: 'button',
|
|
308
|
+
'aria-label': '关闭',
|
|
309
|
+
onClick: () => setCommandPickerOpen(false),
|
|
310
|
+
style: {
|
|
311
|
+
flex: '0 0 auto', width: 28, height: 28, padding: 0,
|
|
312
|
+
border: '1px solid var(--dsw-alias-border-l1)', borderRadius: 7,
|
|
313
|
+
background: 'transparent', color: 'var(--dsw-alias-label-secondary)',
|
|
314
|
+
cursor: 'pointer', fontSize: 16, lineHeight: '24px',
|
|
315
|
+
},
|
|
316
|
+
}, '×')),
|
|
317
|
+
h('input', {
|
|
318
|
+
type: 'search',
|
|
319
|
+
value: commandQuery,
|
|
320
|
+
placeholder: '搜索命令…',
|
|
321
|
+
'aria-label': '搜索命令',
|
|
322
|
+
onChange: (event) => setCommandQuery(event.target.value),
|
|
323
|
+
style: {
|
|
324
|
+
width: '100%', boxSizing: 'border-box', padding: '8px 10px',
|
|
325
|
+
border: '1px solid var(--dsw-alias-border-l1)', borderRadius: 8,
|
|
326
|
+
background: 'var(--dsw-alias-bg-base)', color: 'var(--dsw-alias-label-primary)',
|
|
327
|
+
fontSize: 12,
|
|
328
|
+
},
|
|
329
|
+
}),
|
|
330
|
+
h('div', {
|
|
331
|
+
style: {
|
|
332
|
+
display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
|
|
333
|
+
gap: 4, overflow: 'auto', paddingRight: 4,
|
|
334
|
+
flex: '1 1 auto', minHeight: 0,
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
COMMAND_CHOICES
|
|
338
|
+
.filter(([name, label]) => {
|
|
339
|
+
const query = commandQuery.trim().toLowerCase();
|
|
340
|
+
return !query || name.includes(query) || label.toLowerCase().includes(query);
|
|
341
|
+
})
|
|
342
|
+
.map(([name, label]) => {
|
|
343
|
+
const checked = allowedCommands.has(name);
|
|
344
|
+
return h('button', {
|
|
345
|
+
key: name,
|
|
346
|
+
type: 'button',
|
|
347
|
+
role: 'checkbox',
|
|
348
|
+
'aria-checked': checked,
|
|
349
|
+
onClick: () => toggleCommand(name, !checked),
|
|
350
|
+
style: {
|
|
351
|
+
display: 'flex', alignItems: 'center', gap: 8,
|
|
352
|
+
minWidth: 0, padding: '6px 8px', borderRadius: 6,
|
|
353
|
+
cursor: 'pointer', fontSize: 12, textAlign: 'left',
|
|
354
|
+
color: 'inherit',
|
|
355
|
+
border: checked ? '1px solid var(--dsw-alias-brand-primary)' : '1px solid transparent',
|
|
356
|
+
background: checked ? 'var(--dsw-alias-bg-layer-2)' : 'transparent',
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
h('span', {
|
|
360
|
+
style: {
|
|
361
|
+
flex: '0 0 16px', width: 16, height: 16, lineHeight: '16px',
|
|
362
|
+
textAlign: 'center', borderRadius: 4, fontSize: 11,
|
|
363
|
+
color: checked ? '#fff' : 'transparent',
|
|
364
|
+
background: checked ? 'var(--dsw-alias-brand-primary)' : 'transparent',
|
|
365
|
+
border: checked ? 'none' : '1px solid var(--dsw-alias-border-l2)',
|
|
366
|
+
},
|
|
367
|
+
}, '✓'),
|
|
368
|
+
h('span', {
|
|
369
|
+
style: { overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' },
|
|
370
|
+
}, label));
|
|
371
|
+
})),
|
|
372
|
+
|
|
373
|
+
h('div', {
|
|
374
|
+
style: {
|
|
375
|
+
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
|
376
|
+
gap: 8, paddingTop: 4,
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
h('span', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } },
|
|
380
|
+
localizeTemplate('已选 {count} 项', { count: allowedCommands.size })),
|
|
381
|
+
h('div', { style: { display: 'flex', gap: 8 } },
|
|
382
|
+
h('button', {
|
|
383
|
+
type: 'button',
|
|
384
|
+
className: 'dim-deliveryButton',
|
|
385
|
+
onClick: () => updateOpen({ commandAllowlist: [...DEFAULT_COMMAND_ALLOWLIST] }),
|
|
386
|
+
}, '恢复默认'),
|
|
387
|
+
h('button', {
|
|
388
|
+
type: 'button',
|
|
389
|
+
className: 'dim-deliveryButton',
|
|
390
|
+
onClick: () => updateOpen({ commandAllowlist: COMMAND_CHOICES.map(([name]) => name) }),
|
|
391
|
+
}, '全部命令'),
|
|
392
|
+
h('button', {
|
|
393
|
+
type: 'button',
|
|
394
|
+
className: 'dim-deliveryButton',
|
|
395
|
+
'data-kind': 'primary',
|
|
396
|
+
onClick: () => setCommandPickerOpen(false),
|
|
397
|
+
}, '完成'))))) : null)
|
|
398
|
+
|
|
399
|
+
)),
|
|
202
400
|
h('div', { className: 'dim-accessUsers' },
|
|
203
401
|
h('div', { className: 'dim-accessUsersHeading' },
|
|
204
402
|
h('div', { className: 'dim-accessUsersTitle' },
|
|
@@ -2,8 +2,19 @@ import * as React from 'react';
|
|
|
2
2
|
import { h } from './i18n.js';
|
|
3
3
|
import { SET_MESSAGE_MODE_ENDPOINT, normalizeBusyMessageMode } from '../../src/channels/shared/message-mode.mjs';
|
|
4
4
|
import { normalizeFeishuStepCardPanels } from '../../src/channels/feishu/step-push-mode.mjs';
|
|
5
|
+
import {
|
|
6
|
+
normalizeReplyContent,
|
|
7
|
+
SET_REPLY_CONTENT_ENDPOINT,
|
|
8
|
+
} from '../../src/channels/shared/reply-content.mjs';
|
|
5
9
|
import { FEISHU_ENDPOINTS } from './channels/feishu/api.js';
|
|
6
10
|
|
|
11
|
+
/** The three switches every channel shares, in the order they are shown. */
|
|
12
|
+
const REPLY_CONTENT_ROWS = Object.freeze([
|
|
13
|
+
['narration', '过程正文', '正在执行时助手的说明文字'],
|
|
14
|
+
['tools', '工具步骤', '工具调用、结果与失败提示'],
|
|
15
|
+
['thinking', '思考过程', '模型的推理过程(渠道支持时)'],
|
|
16
|
+
]);
|
|
17
|
+
|
|
7
18
|
function settingsFromResult(result, botId) {
|
|
8
19
|
if (result?.ok !== true) throw new Error(result?.error?.message || '无法读取通用设置,请稍后重试。');
|
|
9
20
|
const bot = result.value?.bots?.find((entry) => entry.botId === botId);
|
|
@@ -11,13 +22,22 @@ function settingsFromResult(result, botId) {
|
|
|
11
22
|
return {
|
|
12
23
|
busyMessageMode: normalizeBusyMessageMode(bot.busyMessageMode),
|
|
13
24
|
stepCardPanels: normalizeFeishuStepCardPanels(bot.stepCardPanels),
|
|
25
|
+
replyContent: normalizeReplyContent(bot.replyContent),
|
|
14
26
|
};
|
|
15
27
|
}
|
|
16
28
|
|
|
29
|
+
const SAVE_ENDPOINTS = Object.freeze({
|
|
30
|
+
busyMessageMode: SET_MESSAGE_MODE_ENDPOINT,
|
|
31
|
+
stepCardPanels: FEISHU_ENDPOINTS.setStepCardPanels,
|
|
32
|
+
replyContent: SET_REPLY_CONTENT_ENDPOINT,
|
|
33
|
+
});
|
|
34
|
+
|
|
17
35
|
export function BotGeneralSettingsPage({ channel, account, rpcCall }) {
|
|
18
36
|
const modeId = React.useId();
|
|
19
37
|
const [settings, setSettings] = React.useState(() => ({
|
|
20
|
-
busyMessageMode: 'queue',
|
|
38
|
+
busyMessageMode: 'queue',
|
|
39
|
+
stepCardPanels: normalizeFeishuStepCardPanels(),
|
|
40
|
+
replyContent: normalizeReplyContent(),
|
|
21
41
|
}));
|
|
22
42
|
const [savedSettings, setSavedSettings] = React.useState(null);
|
|
23
43
|
const [busy, setBusy] = React.useState(false);
|
|
@@ -57,8 +77,7 @@ export function BotGeneralSettingsPage({ channel, account, rpcCall }) {
|
|
|
57
77
|
setBusy(true);
|
|
58
78
|
setFeedback(null);
|
|
59
79
|
try {
|
|
60
|
-
const
|
|
61
|
-
const saved = settingsFromResult(await rpcCall(endpoint, {
|
|
80
|
+
const saved = settingsFromResult(await rpcCall(SAVE_ENDPOINTS[field], {
|
|
62
81
|
botId: account.botId, [field]: value,
|
|
63
82
|
}), account.botId);
|
|
64
83
|
if (!mounted.current) return;
|
|
@@ -94,6 +113,28 @@ export function BotGeneralSettingsPage({ channel, account, rpcCall }) {
|
|
|
94
113
|
h('option', { value: 'steer' }, '插话')),
|
|
95
114
|
h('svg', { width: 14, height: 14, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': true },
|
|
96
115
|
h('path', { d: 'm4 6 4 4 4-4', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', strokeLinejoin: 'round' })))),
|
|
116
|
+
h('div', { className: 'dim-botGeneralRow dim-botGeneralPanelRow' },
|
|
117
|
+
h('div', { className: 'dim-botGeneralText' },
|
|
118
|
+
h('label', { className: 'dim-botGeneralTitle', htmlFor: `${modeId}-reply-content` }, '投递内容'),
|
|
119
|
+
h('p', {
|
|
120
|
+
className: 'dim-botGeneralHelp',
|
|
121
|
+
id: `${modeId}-reply-content-description`,
|
|
122
|
+
}, '最终回答始终发送;关闭的项不再推送。'))),
|
|
123
|
+
...REPLY_CONTENT_ROWS.map(([field, label, help]) => h('div', {
|
|
124
|
+
key: field, className: 'dim-botGeneralRow dim-botGeneralPanelRow',
|
|
125
|
+
},
|
|
126
|
+
h('div', { className: 'dim-botGeneralText' },
|
|
127
|
+
h('label', { className: 'dim-botGeneralTitle', htmlFor: `${modeId}-${field}` }, label),
|
|
128
|
+
h('p', { className: 'dim-botGeneralHelp' }, help)),
|
|
129
|
+
h('div', { className: 'dim-botGeneralControl' },
|
|
130
|
+
h('input', {
|
|
131
|
+
id: `${modeId}-${field}`, type: 'checkbox', role: 'switch', className: 'dim-contextSwitch',
|
|
132
|
+
checked: settings.replyContent[field], disabled: busy || savedSettings === null,
|
|
133
|
+
'aria-label': label, 'aria-describedby': `${modeId}-reply-content-description`,
|
|
134
|
+
onChange: (event) => void save('replyContent', {
|
|
135
|
+
...settings.replyContent, [field]: event.target.checked,
|
|
136
|
+
}),
|
|
137
|
+
})))),
|
|
97
138
|
channel === 'feishu' ? [
|
|
98
139
|
['thinkingExpanded', '展开思考过程'],
|
|
99
140
|
['toolsExpanded', '展开工具摘要'],
|
|
@@ -346,6 +346,8 @@ function TargetForm({
|
|
|
346
346
|
return h('form', { className: 'dim-targetForm', onSubmit: submit },
|
|
347
347
|
h('div', { className: 'dim-targetFormHeading' },
|
|
348
348
|
h('h3', null, editing ? '编辑投递目标' : '新建投递目标'),
|
|
349
|
+
h('p', { style: { color: '#92400e', background: '#fffbeb', padding: '8px 10px', borderRadius: '6px', fontSize: '12px', lineHeight: 1.5 } },
|
|
350
|
+
'目标是细粒度设置:某个机器人一旦配置了目标(哪怕关闭会话同步),该机器人的投递就按目标走。如需使用「通用设置 → 投递」里的简单开关,请先删除该机器人的全部目标。'),
|
|
349
351
|
editing
|
|
350
352
|
? initialValue?.sessionSync?.enabled
|
|
351
353
|
? h('p', null, '修改接收位置会关闭会话双向同步。')
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_DELIVERY_SYNC_SETTINGS,
|
|
5
|
+
normalizeDeliverySyncIcon,
|
|
6
|
+
normalizeDeliverySyncSettings,
|
|
7
|
+
} from '../../src/channels/shared/delivery-sync-settings.mjs';
|
|
8
|
+
import { h } from './i18n.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Delivery-sync settings: which turns the chat mirrors even though they did not
|
|
12
|
+
* start in the chat (a turn typed in the Web GUI, a turn started by a schedule
|
|
13
|
+
* reminder or a subagent notice), the two prefix icons, and the language the
|
|
14
|
+
* plugin's own chat messages are written in.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Management channel serving these endpoints. Separate from the loopback-only
|
|
18
|
+
* `/dsh-im-settings` so the page also works when the dashboard is opened
|
|
19
|
+
* through its own domain.
|
|
20
|
+
*/
|
|
21
|
+
export const DELIVERY_SYNC_SETTINGS_RPC_CHANNEL = '/dsh-im-delivery-sync';
|
|
22
|
+
|
|
23
|
+
export const DELIVERY_SYNC_SETTINGS_ENDPOINTS = Object.freeze({
|
|
24
|
+
get: 'settings.delivery-sync.get',
|
|
25
|
+
set: 'settings.delivery-sync.set',
|
|
26
|
+
getLanguage: 'settings.language.get',
|
|
27
|
+
setLanguage: 'settings.language.set',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/** The languages the plugin ships chat-message dictionaries for, plus "follow DSH". */
|
|
31
|
+
export const MESSAGE_LANGUAGE_OPTIONS = Object.freeze([
|
|
32
|
+
{ value: 'auto', label: '跟随 DSH 界面语言' },
|
|
33
|
+
{ value: 'zh', label: '中文' },
|
|
34
|
+
{ value: 'en', label: 'English' },
|
|
35
|
+
{ value: 'ru', label: 'Русский' },
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
function unwrap(result) {
|
|
39
|
+
if (result?.ok === true) return result.value;
|
|
40
|
+
if (result?.ok === false) {
|
|
41
|
+
const error = new Error(result.error?.message || '无法读取或保存会话同步设置,请稍后重试。');
|
|
42
|
+
error.code = result.error?.code;
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The select shows the pinned language only while it is actually in force: a
|
|
50
|
+
* snapshot resolved by the operator's `language` option keeps reporting its own
|
|
51
|
+
* source, and the page must not claim that selection came from here.
|
|
52
|
+
*/
|
|
53
|
+
export function messageLanguageFromSnapshot(snapshot) {
|
|
54
|
+
if (snapshot?.source !== 'explicit') return 'auto';
|
|
55
|
+
const language = snapshot.language;
|
|
56
|
+
return MESSAGE_LANGUAGE_OPTIONS.some((option) => option.value === language) ? language : 'auto';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function DeliverySyncSettings({ rpcCall, languageRpcCall = null }) {
|
|
60
|
+
const [values, setValues] = React.useState(DEFAULT_DELIVERY_SYNC_SETTINGS);
|
|
61
|
+
const [language, setLanguage] = React.useState('auto');
|
|
62
|
+
const [savedLanguage, setSavedLanguage] = React.useState('auto');
|
|
63
|
+
const [phase, setPhase] = React.useState('loading');
|
|
64
|
+
const [error, setError] = React.useState(null);
|
|
65
|
+
const [saved, setSaved] = React.useState(false);
|
|
66
|
+
const mounted = React.useRef(false);
|
|
67
|
+
const busy = React.useRef(false);
|
|
68
|
+
const id = React.useId();
|
|
69
|
+
const languageAvailable = typeof languageRpcCall === 'function';
|
|
70
|
+
|
|
71
|
+
const load = React.useCallback(async (signal) => {
|
|
72
|
+
setPhase('loading');
|
|
73
|
+
setError(null);
|
|
74
|
+
setSaved(false);
|
|
75
|
+
try {
|
|
76
|
+
// There is no fallback channel: without the delivery-sync one the page
|
|
77
|
+
// says so instead of silently reading another document.
|
|
78
|
+
if (typeof rpcCall !== 'function') throw new Error('投递同步设置通道不可用。');
|
|
79
|
+
const settings = normalizeDeliverySyncSettings(
|
|
80
|
+
unwrap(await rpcCall(DELIVERY_SYNC_SETTINGS_ENDPOINTS.get, {}, signal)),
|
|
81
|
+
);
|
|
82
|
+
if (!settings) throw new Error('会话同步设置返回了无法识别的响应。');
|
|
83
|
+
const snapshot = languageAvailable
|
|
84
|
+
? unwrap(await languageRpcCall(DELIVERY_SYNC_SETTINGS_ENDPOINTS.getLanguage, {}, signal))
|
|
85
|
+
: null;
|
|
86
|
+
if (signal?.aborted || !mounted.current) return;
|
|
87
|
+
setValues(settings);
|
|
88
|
+
const current = messageLanguageFromSnapshot(snapshot);
|
|
89
|
+
setLanguage(current);
|
|
90
|
+
setSavedLanguage(current);
|
|
91
|
+
setPhase('ready');
|
|
92
|
+
} catch (caught) {
|
|
93
|
+
if (signal?.aborted || !mounted.current) return;
|
|
94
|
+
setError(caught.message || '无法读取或保存会话同步设置,请稍后重试。');
|
|
95
|
+
setPhase('error');
|
|
96
|
+
}
|
|
97
|
+
}, [languageAvailable, languageRpcCall, rpcCall]);
|
|
98
|
+
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
mounted.current = true;
|
|
101
|
+
const controller = new AbortController();
|
|
102
|
+
void load(controller.signal);
|
|
103
|
+
return () => { mounted.current = false; controller.abort(); };
|
|
104
|
+
}, [load]);
|
|
105
|
+
|
|
106
|
+
const edit = (patch) => {
|
|
107
|
+
setValues((current) => ({ ...current, ...patch }));
|
|
108
|
+
setSaved(false);
|
|
109
|
+
setError(null);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const save = async (event) => {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (busy.current || phase !== 'ready') return;
|
|
115
|
+
busy.current = true;
|
|
116
|
+
setPhase('saving');
|
|
117
|
+
setError(null);
|
|
118
|
+
setSaved(false);
|
|
119
|
+
try {
|
|
120
|
+
if (languageAvailable && language !== savedLanguage) {
|
|
121
|
+
unwrap(await languageRpcCall(
|
|
122
|
+
DELIVERY_SYNC_SETTINGS_ENDPOINTS.setLanguage,
|
|
123
|
+
{ language },
|
|
124
|
+
));
|
|
125
|
+
if (mounted.current) setSavedLanguage(language);
|
|
126
|
+
}
|
|
127
|
+
// Send the icons already trimmed: the Host normalizes them anyway, and
|
|
128
|
+
// the echoed document then matches the field the reader is looking at.
|
|
129
|
+
const settings = normalizeDeliverySyncSettings(unwrap(await rpcCall(
|
|
130
|
+
DELIVERY_SYNC_SETTINGS_ENDPOINTS.set,
|
|
131
|
+
{
|
|
132
|
+
...values,
|
|
133
|
+
inputIcon: normalizeDeliverySyncIcon(values.inputIcon),
|
|
134
|
+
modelIcon: normalizeDeliverySyncIcon(values.modelIcon),
|
|
135
|
+
},
|
|
136
|
+
)));
|
|
137
|
+
if (!settings) throw new Error('会话同步设置返回了无法识别的响应。');
|
|
138
|
+
if (!mounted.current) return;
|
|
139
|
+
setValues(settings);
|
|
140
|
+
setSaved(true);
|
|
141
|
+
} catch (caught) {
|
|
142
|
+
if (mounted.current) setError(caught.message || '无法读取或保存会话同步设置,请稍后重试。');
|
|
143
|
+
} finally {
|
|
144
|
+
busy.current = false;
|
|
145
|
+
if (mounted.current) setPhase('ready');
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const disabled = phase !== 'ready';
|
|
150
|
+
const iconHint = '最多 32 个字符;留空则不添加前缀。';
|
|
151
|
+
const rows = [
|
|
152
|
+
{
|
|
153
|
+
key: 'mirrorUserInput',
|
|
154
|
+
icon: 'inputIcon',
|
|
155
|
+
title: '镜像 Web 中输入的消息',
|
|
156
|
+
help: '在 Web GUI 中发送的消息会作为一条带前缀的消息转发到本聊天的会话同步目标。',
|
|
157
|
+
iconLabel: '输入前缀图标',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
key: 'deliverModelAnswers',
|
|
161
|
+
icon: 'modelIcon',
|
|
162
|
+
title: '投递模型回答',
|
|
163
|
+
help: '其他回合(Web 输入、定时提醒、子代理通知等)的模型回答会发送到会话同步目标。',
|
|
164
|
+
iconLabel: '回答前缀图标',
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
const helpId = `${id}-help`;
|
|
169
|
+
|
|
170
|
+
const head = h('div', { className: 'dim-globalHead' },
|
|
171
|
+
h('div', { className: 'dim-globalHeadTitle' },
|
|
172
|
+
h('h3', null, '会话同步'),
|
|
173
|
+
h('div', { className: 'dim-globalTtlHelp' },
|
|
174
|
+
h('button', {
|
|
175
|
+
type: 'button',
|
|
176
|
+
className: 'dim-channelHelpButton dim-globalTtlHelpButton',
|
|
177
|
+
'aria-label': '查看会话同步说明',
|
|
178
|
+
'aria-describedby': helpId,
|
|
179
|
+
}, h('span', { 'aria-hidden': 'true' }, '?')),
|
|
180
|
+
h('div', {
|
|
181
|
+
id: helpId,
|
|
182
|
+
className: 'dim-globalTtlTooltip dim-deliverySyncTooltip',
|
|
183
|
+
role: 'tooltip',
|
|
184
|
+
}, '只对已开启会话同步的目标生效:在 Web GUI 里输入的回合、定时提醒、子代理通知等“不是本聊天发起”的回合,其回答会转发到这些目标。消息语言同时影响机器人发送的命令菜单文本。'))));
|
|
185
|
+
|
|
186
|
+
const languageField = h('div', { className: 'dim-deliverySyncField' },
|
|
187
|
+
h('div', { className: 'dim-deliverySyncLabel' },
|
|
188
|
+
h('label', { htmlFor: `${id}-language` }, '插件消息语言'),
|
|
189
|
+
h('p', { className: 'dim-deliverySyncHelp', id: `${id}-language-help` },
|
|
190
|
+
languageAvailable
|
|
191
|
+
? '默认跟随 DSH 界面语言;可以单独固定机器人消息的语言。'
|
|
192
|
+
: '语言设置暂不可用。')),
|
|
193
|
+
h('select', {
|
|
194
|
+
id: `${id}-language`,
|
|
195
|
+
className: 'dim-globalTtlInput dim-deliverySyncSelect',
|
|
196
|
+
value: language,
|
|
197
|
+
disabled: disabled || !languageAvailable,
|
|
198
|
+
'aria-describedby': `${id}-language-help`,
|
|
199
|
+
onChange: (event) => { setLanguage(event.target.value); setSaved(false); setError(null); },
|
|
200
|
+
}, ...MESSAGE_LANGUAGE_OPTIONS.map((option) => h('option', {
|
|
201
|
+
key: option.value,
|
|
202
|
+
value: option.value,
|
|
203
|
+
}, option.label))));
|
|
204
|
+
|
|
205
|
+
const iconFields = rows.map((row) => h('div', { className: 'dim-deliverySyncField', key: row.key },
|
|
206
|
+
h('div', { className: 'dim-deliverySyncLabel' },
|
|
207
|
+
h('label', { className: 'dim-deliverySyncCheckLabel', htmlFor: `${id}-${row.key}` },
|
|
208
|
+
h('input', {
|
|
209
|
+
id: `${id}-${row.key}`,
|
|
210
|
+
type: 'checkbox',
|
|
211
|
+
checked: values[row.key] === true,
|
|
212
|
+
disabled,
|
|
213
|
+
'aria-describedby': `${id}-${row.key}-help`,
|
|
214
|
+
onChange: (event) => edit({ [row.key]: event.target.checked }),
|
|
215
|
+
}),
|
|
216
|
+
h('span', null, row.title)),
|
|
217
|
+
h('p', { className: 'dim-deliverySyncHelp', id: `${id}-${row.key}-help` }, row.help)),
|
|
218
|
+
h('div', { className: 'dim-deliverySyncIcon' },
|
|
219
|
+
h('input', {
|
|
220
|
+
id: `${id}-${row.icon}`,
|
|
221
|
+
className: 'dim-globalTtlInput dim-deliverySyncIconInput',
|
|
222
|
+
type: 'text',
|
|
223
|
+
value: values[row.icon],
|
|
224
|
+
maxLength: 32,
|
|
225
|
+
autoComplete: 'off',
|
|
226
|
+
placeholder: '🔔',
|
|
227
|
+
'aria-label': row.iconLabel,
|
|
228
|
+
'aria-describedby': `${id}-${row.icon}-help`,
|
|
229
|
+
disabled,
|
|
230
|
+
onChange: (event) => edit({ [row.icon]: event.target.value }),
|
|
231
|
+
}),
|
|
232
|
+
h('p', { className: 'dim-deliverySyncHelp', id: `${id}-${row.icon}-help` }, iconHint))));
|
|
233
|
+
|
|
234
|
+
const actions = h('div', { className: 'dim-imageSettingsActions' },
|
|
235
|
+
h('button', {
|
|
236
|
+
type: 'submit',
|
|
237
|
+
className: 'dim-deliveryButton dim-globalSaveButton',
|
|
238
|
+
'data-kind': 'primary',
|
|
239
|
+
disabled,
|
|
240
|
+
}, phase === 'saving' ? '保存中…' : '保存投递设置'),
|
|
241
|
+
phase === 'error'
|
|
242
|
+
? h('button', {
|
|
243
|
+
type: 'button',
|
|
244
|
+
className: 'dim-deliveryButton dim-globalSaveButton',
|
|
245
|
+
onClick: () => void load(),
|
|
246
|
+
}, '重试')
|
|
247
|
+
: null);
|
|
248
|
+
|
|
249
|
+
return h('section', {
|
|
250
|
+
className: 'dim-globalSection dim-deliverySyncSettings',
|
|
251
|
+
'aria-label': '会话同步',
|
|
252
|
+
'aria-busy': phase === 'loading' || phase === 'saving',
|
|
253
|
+
},
|
|
254
|
+
head,
|
|
255
|
+
h('form', { onSubmit: save },
|
|
256
|
+
h('div', { className: 'dim-deliverySyncFields' }, languageField, ...iconFields),
|
|
257
|
+
actions),
|
|
258
|
+
error
|
|
259
|
+
? h('p', {
|
|
260
|
+
className: 'dim-globalInline dim-deliverySyncFeedback',
|
|
261
|
+
'data-tone': 'error',
|
|
262
|
+
role: 'alert',
|
|
263
|
+
}, error)
|
|
264
|
+
: null,
|
|
265
|
+
saved ? h('p', { className: 'dim-globalInline dim-deliverySyncFeedback', role: 'status' }, '已保存') : null,
|
|
266
|
+
phase === 'loading'
|
|
267
|
+
? h('p', { className: 'dim-globalInline dim-deliverySyncFeedback', role: 'status' }, '正在读取投递设置…')
|
|
268
|
+
: null);
|
|
269
|
+
}
|