@xsok/dsh-enhanced 0.0.0-stage → 0.2.2-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/README.md +163 -2
- package/client.js +2876 -0
- package/cordis.patch.yml +4 -0
- package/host/engine/archive.js +134 -0
- package/host/engine/atomic.js +27 -0
- package/host/engine/attachments.js +102 -0
- package/host/engine/config.js +214 -0
- package/host/engine/index.js +323 -0
- package/host/engine/ledger.js +108 -0
- package/host/engine/paths.js +81 -0
- package/host/engine/pluginlist.js +81 -0
- package/host/engine/projcache.js +165 -0
- package/host/engine/prune.js +187 -0
- package/host/engine/scan.js +177 -0
- package/host/engine/session.js +138 -0
- package/host/engine/sessions.js +346 -0
- package/host/engine/workspace.js +223 -0
- package/host/engine/zstd.js +91 -0
- package/host/envcheck.js +288 -0
- package/host/mirror.js +502 -0
- package/host/move.js +196 -0
- package/host/overwrite.js +305 -0
- package/host/restart.js +158 -0
- package/host/schedule.js +296 -0
- package/host/search.js +182 -0
- package/host/sync.js +593 -0
- package/host/trash.js +738 -0
- package/host/trashsync.js +204 -0
- package/host/webdav.js +429 -0
- package/icon.svg +1 -0
- package/index.js +313 -0
- package/locale/en.json +68 -0
- package/locale/zh.json +68 -0
- package/package.json +71 -4
package/client.js
ADDED
|
@@ -0,0 +1,2876 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH增强 — browser half.
|
|
3
|
+
*
|
|
4
|
+
* Registers four contributions:
|
|
5
|
+
* - one row in a session's "..." menu (delete),
|
|
6
|
+
* - one footer action beside Settings (session recovery),
|
|
7
|
+
* - two frame-wide overlay entries (search panel, dialogs + toast),
|
|
8
|
+
* - one settings section (switches and limits).
|
|
9
|
+
*
|
|
10
|
+
* All host work goes through a single exact Connection fetch route, which is
|
|
11
|
+
* authenticated by the page's own browser session; this module never touches
|
|
12
|
+
* session files or the workspace registry itself.
|
|
13
|
+
*/
|
|
14
|
+
window.__ModuleLoader__.load({
|
|
15
|
+
id: '@xsok/dsh-enhanced',
|
|
16
|
+
factory(require) {
|
|
17
|
+
const React = require('react');
|
|
18
|
+
const h = React.createElement;
|
|
19
|
+
const NS = 'dshEnhanced';
|
|
20
|
+
|
|
21
|
+
let primitives = null;
|
|
22
|
+
try {
|
|
23
|
+
primitives = require('@deepseek-ai/dsh-client-ui-primitives');
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.warn('[dsh-enhanced] ui primitives are unavailable; using fallbacks', error);
|
|
26
|
+
primitives = null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Render into <body> so dialogs cannot cover our panels; optional. */
|
|
30
|
+
let createPortal = null;
|
|
31
|
+
try {
|
|
32
|
+
const ReactDOM = require('react-dom');
|
|
33
|
+
if (typeof ReactDOM?.createPortal === 'function') createPortal = ReactDOM.createPortal;
|
|
34
|
+
} catch {
|
|
35
|
+
createPortal = null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const DEFAULTS = Object.freeze({
|
|
39
|
+
version: 1,
|
|
40
|
+
deleteEnabled: true,
|
|
41
|
+
trashEnabled: true,
|
|
42
|
+
searchEnabled: true,
|
|
43
|
+
moveEnabled: true,
|
|
44
|
+
autoLoadEnabled: true,
|
|
45
|
+
syncEnabled: false,
|
|
46
|
+
syncDir: '',
|
|
47
|
+
syncScript: '',
|
|
48
|
+
syncMachineId: '',
|
|
49
|
+
syncSkipAttachments: false,
|
|
50
|
+
syncIntervalMinutes: 0,
|
|
51
|
+
syncDailyAt: '',
|
|
52
|
+
syncOnIdle: true,
|
|
53
|
+
syncCooldownMinutes: 5,
|
|
54
|
+
syncMode: 'local',
|
|
55
|
+
webdavUrl: '',
|
|
56
|
+
webdavUser: '',
|
|
57
|
+
webdavPassword: '',
|
|
58
|
+
webdavRoot: '',
|
|
59
|
+
webdavAutoCreate: true,
|
|
60
|
+
mirrorDir: '',
|
|
61
|
+
matchTitle: true,
|
|
62
|
+
matchBody: true,
|
|
63
|
+
matchTools: false,
|
|
64
|
+
retentionDays: 60,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const DICT = {
|
|
68
|
+
en: {
|
|
69
|
+
'nav.title': 'DSH Enhanced',
|
|
70
|
+
'env.button': 'Environment check',
|
|
71
|
+
'restart.button': 'Restart app',
|
|
72
|
+
'restart.hint': 'Ctrl+Shift+Alt+R',
|
|
73
|
+
'restart.desc': 'Restart the desktop app now?',
|
|
74
|
+
'restart.confirm': 'Restart',
|
|
75
|
+
'restart.busy': 'A turn is still running. Stop it, then restart.',
|
|
76
|
+
'overwrite.cloud': 'Overwrite cloud',
|
|
77
|
+
'overwrite.local': 'Overwrite this machine',
|
|
78
|
+
'overwrite.awayCloud': 'Replaces the cloud with this machine\'s data. Nothing is merged.',
|
|
79
|
+
'overwrite.awayLocal': 'Replaces this machine with the cloud data. Nothing is merged.',
|
|
80
|
+
'overwrite.confirm': 'Start overwrite',
|
|
81
|
+
'overwrite.running': 'Working…',
|
|
82
|
+
'overwrite.cloudDone': 'Cloud replaced; {n} file(s) uploaded.',
|
|
83
|
+
'overwrite.localDone': 'This machine replaced; {n} area(s) copied.',
|
|
84
|
+
'env.busy': 'Checking…',
|
|
85
|
+
'env.title': 'DSH Enhanced · Environment check',
|
|
86
|
+
'env.ok': 'No problems found',
|
|
87
|
+
'env.risk': '{n} risk(s) found. Export a report?',
|
|
88
|
+
'env.report': 'Export report',
|
|
89
|
+
'env.reported': 'Report saved to {path}',
|
|
90
|
+
'env.versionLine': 'App {app} · plugin V{plugin}',
|
|
91
|
+
'env.update.title': 'DSH Enhanced · host updated',
|
|
92
|
+
'env.update.desc': 'The host application changed ({last} → {app}). Run the environment check to make sure the plugin still works?',
|
|
93
|
+
'env.update.yes': 'Yes',
|
|
94
|
+
'env.update.no': 'No',
|
|
95
|
+
'pause.title': 'DSH Enhanced · automatic sync paused',
|
|
96
|
+
'pause.desc': 'Automatic sync stopped after {n} consecutive failures.',
|
|
97
|
+
'pause.last': 'Last failure: {summary}. {hint}',
|
|
98
|
+
'pause.resume': 'Resume automatic sync',
|
|
99
|
+
'pause.resumed': 'Automatic sync resumed',
|
|
100
|
+
'section.title': 'DSH Enhanced',
|
|
101
|
+
'section.desc': 'Session delete and restore, cross-workspace move, full-corpus search, quoting, auto-load history, and multi-device sync.',
|
|
102
|
+
'section.reading': 'Reading and actions',
|
|
103
|
+
'section.sessions': 'Session management',
|
|
104
|
+
'section.search': 'Content search',
|
|
105
|
+
'section.sync': 'Session sync',
|
|
106
|
+
'sync.interval': 'Interval (minutes)',
|
|
107
|
+
'sync.interval.hint': '0 turns interval sync off.',
|
|
108
|
+
'sync.daily': 'Daily at',
|
|
109
|
+
'sync.daily.hint': 'HH:MM in 24-hour form; empty turns it off.',
|
|
110
|
+
'sync.idle': 'Sync when idle',
|
|
111
|
+
'sync.idle.desc': 'Runs once the first time every session stops working.',
|
|
112
|
+
'sync.cooldown': 'Minimum gap (minutes)',
|
|
113
|
+
'sync.mode': 'Sync target',
|
|
114
|
+
'sync.mode.local': 'Local folder',
|
|
115
|
+
'sync.mode.webdav': 'WebDAV',
|
|
116
|
+
'sync.webdav.url': 'WebDAV address',
|
|
117
|
+
'sync.webdav.presets': 'Saved setups',
|
|
118
|
+
'sync.webdav.presets.hint': 'One click fills the four fields above. Up to three.',
|
|
119
|
+
'sync.webdav.presets.save': 'Save current setup',
|
|
120
|
+
'sync.webdav.presets.modify': 'Edit setup',
|
|
121
|
+
'sync.webdav.presets.commitModify': 'Save changes',
|
|
122
|
+
'sync.webdav.presets.updated': 'Updated "{name}".',
|
|
123
|
+
'sync.webdav.presets.replaced': 'Setup replaced.',
|
|
124
|
+
'sync.webdav.presets.replaceTitle': 'Replace which setup?',
|
|
125
|
+
'sync.webdav.presets.replaceDesc': 'Three setups are already saved. Pick the one this replaces.',
|
|
126
|
+
'sync.webdav.presets.saved': 'Saved "{name}".',
|
|
127
|
+
'sync.webdav.presets.rename': 'Rename',
|
|
128
|
+
'sync.webdav.presets.name': 'Setup name',
|
|
129
|
+
'sync.webdav.presets.confirm': 'Apply the name',
|
|
130
|
+
'sync.webdav.presets.default': 'Default (current fields)',
|
|
131
|
+
'sync.webdav.presets.remove': 'Delete',
|
|
132
|
+
'sync.webdav.presets.unsaved': '(current fields, not saved)',
|
|
133
|
+
'sync.webdav.presets.full': 'Three saved setups are the limit. Remove one first.',
|
|
134
|
+
'sync.webdav.presets.empty': 'Fill in the address first.',
|
|
135
|
+
'sync.webdav.user': 'Account',
|
|
136
|
+
'sync.webdav.password': 'App password',
|
|
137
|
+
'sync.webdav.password.hint': 'Jianguoyun requires an application password from its security page, not the login password.',
|
|
138
|
+
'sync.webdav.root': 'Remote root',
|
|
139
|
+
'sync.webdav.root.hint': 'Full path, e.g. https://dav.jianguoyun.com/dav/我的坚果云/DSH-Sync',
|
|
140
|
+
'sync.webdav.mirror': 'Local mirror folder',
|
|
141
|
+
'sync.webdav.mirror.usage': 'Currently using {size} ({files} files)',
|
|
142
|
+
'sync.webdav.autoCreate': 'Create the remote folder',
|
|
143
|
+
'sync.webdav.autoCreate.desc': 'When the remote path is missing, create it level by level before testing.',
|
|
144
|
+
'sync.webdav.test': 'Test connection',
|
|
145
|
+
'sync.webdav.testing': 'Connecting…',
|
|
146
|
+
'sync.webdav.ok': 'Connected: {message}',
|
|
147
|
+
'sync.webdav.fail': 'Connection failed: {message}',
|
|
148
|
+
'sync.pull': 'Pull once',
|
|
149
|
+
'sync.push': 'Push once',
|
|
150
|
+
'sync.pull.confirm': 'Download from the cloud into the local mirror folder? Nothing is uploaded or deleted remotely.',
|
|
151
|
+
'sync.push.confirm': 'Upload the mirror folder to the cloud? Existing remote files are overwritten only when they differ, never deleted.',
|
|
152
|
+
'sync.pulled': 'Pulled {n} files ({bytes}), skipped {skipped}.',
|
|
153
|
+
'sync.pushed': 'Pushed {n} files ({bytes}), skipped {skipped}.',
|
|
154
|
+
'sync.directionFailed': '{n} files failed',
|
|
155
|
+
'sync.noFailure': 'no failures',
|
|
156
|
+
'switch.delete': 'Delete sessions',
|
|
157
|
+
'switch.delete.desc': 'Adds "Delete session" to the session menu. A running session cannot be deleted.',
|
|
158
|
+
'switch.move': 'Move between workspaces',
|
|
159
|
+
'switch.move.desc': 'Adds "Move to workspace" to the session menu. Moving copies the session and permanently deletes the original.',
|
|
160
|
+
'switch.autoLoad': 'Auto-load earlier messages',
|
|
161
|
+
'switch.autoLoad.desc': 'Scrolling to the top of a conversation loads the next older page automatically, without clicking "Load earlier".',
|
|
162
|
+
'sync.title': 'Session and config sync',
|
|
163
|
+
'sync.desc': 'Runs the bundled sync engine to copy sessions, config and attachments into a shared folder.',
|
|
164
|
+
'sync.needDir': 'Fill in the shared folder before syncing.',
|
|
165
|
+
'sync.needMirror': 'Fill in the local mirror folder before syncing.',
|
|
166
|
+
'sync.enable': 'Automatic sync',
|
|
167
|
+
'sync.enable.hint': 'Idle, interval and daily triggers only; Sync now ignores this switch.',
|
|
168
|
+
'sync.dir': 'Shared folder',
|
|
169
|
+
'sync.machine': 'Machine id',
|
|
170
|
+
'sync.machine.hint': 'Empty uses the Windows user name; a collision with an existing id refuses the sync.',
|
|
171
|
+
'sync.machine.placeholder': 'System default: {id}',
|
|
172
|
+
'sync.attachments': 'Sync attachments',
|
|
173
|
+
'sync.probe': 'Check',
|
|
174
|
+
'sync.run': 'Sync now',
|
|
175
|
+
'sync.running': 'Syncing…',
|
|
176
|
+
'sync.never': 'Not run yet.',
|
|
177
|
+
'sync.last': 'Last run: {time} · {result} · {ms} ms',
|
|
178
|
+
'sync.result.ok': 'ok',
|
|
179
|
+
'sync.result.fail': 'failed',
|
|
180
|
+
'sync.purged': 'trash pruned {n}',
|
|
181
|
+
'sync.paths': 'dirs created {created}, failed {failed}',
|
|
182
|
+
'sync.failed': '{n} files failed',
|
|
183
|
+
'sync.counts': '↑ {up} · ↓ {down} · 🗑 {del}',
|
|
184
|
+
'sync.transport': 'transport: {down} down, {up} up',
|
|
185
|
+
'sync.transportDel': 'transport: {down} down, {up} up, {del} deleted',
|
|
186
|
+
'sync.dirMissing': 'Shared folder not found: {path}',
|
|
187
|
+
'sync.log': 'Show log',
|
|
188
|
+
'sync.logToggle': 'Click to show or hide the run history',
|
|
189
|
+
'sync.more': 'Show more',
|
|
190
|
+
'sync.historyCount': '{n} runs recorded',
|
|
191
|
+
'sync.logHide': 'Hide log',
|
|
192
|
+
'sync.failed': 'Sync failed: {message}',
|
|
193
|
+
'switch.trash': 'Session recovery',
|
|
194
|
+
'switch.trash.desc': 'Shows the recovery entry in the session menu and on this page. Deleted sessions stay in the local recycle bin.',
|
|
195
|
+
'switch.search': 'Content search',
|
|
196
|
+
'switch.search.desc': 'Opens the search panel over any screen and matches titles and messages.',
|
|
197
|
+
'switch.matchTitle': 'Match session titles',
|
|
198
|
+
'switch.matchBody': 'Match user and assistant messages',
|
|
199
|
+
'switch.matchTools': 'Match tool output',
|
|
200
|
+
'switch.limits': 'Search scope',
|
|
201
|
+
'field.retention': 'Keep deleted sessions for (days)',
|
|
202
|
+
'field.retention.hint': '0 keeps them until you remove them by hand.',
|
|
203
|
+
'trash.usage': '{count} sessions, {size}',
|
|
204
|
+
'trash.clear': 'Empty recycle bin',
|
|
205
|
+
'trash.cleared': 'Recycle bin emptied.',
|
|
206
|
+
'delete.label': 'Delete session',
|
|
207
|
+
'delete.running': 'Delete session (running)',
|
|
208
|
+
'delete.title': 'Delete this session?',
|
|
209
|
+
'delete.desc': 'The local session directory, its projection cache shard, and its workspace reference are removed. The session stays recoverable until the retention period ends.',
|
|
210
|
+
'delete.confirm': 'Delete',
|
|
211
|
+
'delete.done': '"{title}" was deleted.',
|
|
212
|
+
'delete.failed': 'Delete failed: {message}',
|
|
213
|
+
'delete.blocked': 'A running session cannot be deleted.',
|
|
214
|
+
'move.label': 'Move to workspace…',
|
|
215
|
+
'move.running': 'Move to workspace (running)',
|
|
216
|
+
'move.title': 'Move to workspace',
|
|
217
|
+
'move.desc': 'Moves the session into the target workspace in place: the session itself is unchanged and only its working directory becomes the target. Later tool calls run there. The new grouping appears after the app restarts.',
|
|
218
|
+
'move.session': 'Session: {title}',
|
|
219
|
+
'move.restarting': 'Moved. Restarting so the new grouping takes effect…',
|
|
220
|
+
'move.current': 'Current workspace: {title}',
|
|
221
|
+
'move.target': 'Target workspace',
|
|
222
|
+
'move.empty': 'No other workspace is available.',
|
|
223
|
+
'move.loading': 'Reading workspaces…',
|
|
224
|
+
'move.busy': 'Copying the session…',
|
|
225
|
+
'move.confirm': 'Move',
|
|
226
|
+
'move.done': 'Moved to "{title}".',
|
|
227
|
+
'move.failed': 'Move failed: {message}',
|
|
228
|
+
'trash.title': 'Session deletions',
|
|
229
|
+
'trash.untitled': 'Untitled',
|
|
230
|
+
'trash.menu': 'Recover sessions in this workspace',
|
|
231
|
+
'trash.desc': 'Sessions deleted in this workspace. Restore one, or remove it permanently.',
|
|
232
|
+
'trash.empty': 'No deleted sessions.',
|
|
233
|
+
'trash.restore': 'Restore',
|
|
234
|
+
'trash.purge': 'Delete permanently',
|
|
235
|
+
'trash.purge.confirm': 'Delete for good?',
|
|
236
|
+
'trash.clear': 'Empty recycle bin',
|
|
237
|
+
'trash.clear.confirm': 'Empty for good?',
|
|
238
|
+
'trash.clearWorkspace': 'Empty workspace',
|
|
239
|
+
'trash.clearWorkspace.confirm': 'Empty for good?',
|
|
240
|
+
'trash.restored': '"{title}" was restored.',
|
|
241
|
+
'trash.purged': '"{title}" was deleted permanently.',
|
|
242
|
+
'trash.loading': 'Loading…',
|
|
243
|
+
'search.placeholder': 'Search session titles and content',
|
|
244
|
+
'search.empty': 'No matches.',
|
|
245
|
+
'search.hint': 'Type to search every session. Enter opens the highlighted result.',
|
|
246
|
+
'search.loading': 'Searching…',
|
|
247
|
+
'search.error': 'Search failed: {message}',
|
|
248
|
+
'search.meta': '{count} sessions, {matches} matches',
|
|
249
|
+
'search.notLocated': 'Opened the session, but the match is not loaded yet. Click "Load earlier" and try again.',
|
|
250
|
+
'search.close': 'Close search',
|
|
251
|
+
'role.user': 'You',
|
|
252
|
+
'role.assistant': 'Assistant',
|
|
253
|
+
'role.tool': 'Tool',
|
|
254
|
+
'role.title': 'Title',
|
|
255
|
+
'common.close': 'Close',
|
|
256
|
+
'common.cancel': 'Cancel',
|
|
257
|
+
'common.retry': 'Retry',
|
|
258
|
+
},
|
|
259
|
+
zh: {
|
|
260
|
+
'nav.title': 'DSH增强',
|
|
261
|
+
'env.button': '环境检测',
|
|
262
|
+
'restart.button': '重启应用',
|
|
263
|
+
'restart.hint': 'Ctrl+Shift+Alt+R',
|
|
264
|
+
'restart.desc': '立即重启桌面应用?',
|
|
265
|
+
'restart.confirm': '重启',
|
|
266
|
+
'restart.busy': '有任务正在运行,结束或停止后再重启。',
|
|
267
|
+
'overwrite.cloud': '覆盖云端',
|
|
268
|
+
'overwrite.local': '覆盖本机',
|
|
269
|
+
'overwrite.awayCloud': '将以本机数据完全替换云端,不做合并。',
|
|
270
|
+
'overwrite.awayLocal': '将以云端数据完全替换本机,不做合并。',
|
|
271
|
+
'overwrite.confirm': '开始覆盖',
|
|
272
|
+
'overwrite.running': '处理中…',
|
|
273
|
+
'overwrite.cloudDone': '云端已覆盖;上传 {n} 个文件。',
|
|
274
|
+
'overwrite.localDone': '本机已覆盖;复制 {n} 个区域。',
|
|
275
|
+
'env.busy': '正在检测…',
|
|
276
|
+
'env.title': 'DSH增强 · 环境检测',
|
|
277
|
+
'env.ok': '环境无异常',
|
|
278
|
+
'env.risk': '发现 {n} 项风险点,是否输出风险报告?',
|
|
279
|
+
'env.report': '输出风险报告',
|
|
280
|
+
'env.reported': '风险报告已保存到 {path}',
|
|
281
|
+
'env.versionLine': '主程序 {app} · 插件 V{plugin}',
|
|
282
|
+
'env.update.title': 'DSH增强 · 主程序已更新',
|
|
283
|
+
'env.update.desc': '发现主程序更新({last} → {app}),请运行“环境检测”确保插件可正确运行,是否立即检测?',
|
|
284
|
+
'env.update.yes': '是',
|
|
285
|
+
'env.update.no': '否',
|
|
286
|
+
'pause.title': 'DSH增强 · 自动同步已暂停',
|
|
287
|
+
'pause.desc': '连续 {n} 次同步失败,自动同步已暂停。',
|
|
288
|
+
'pause.last': '最近一次失败:{summary}。{hint}',
|
|
289
|
+
'pause.resume': '恢复自动同步',
|
|
290
|
+
'pause.resumed': '自动同步已恢复',
|
|
291
|
+
'section.title': 'DSH增强',
|
|
292
|
+
'section.desc': '会话删除与找回、跨工作区移动、全库搜索、文字引用、自动加载历史,以及多设备同步。',
|
|
293
|
+
'section.reading': '阅读与操作',
|
|
294
|
+
'section.sessions': '会话管理',
|
|
295
|
+
'section.search': '内容搜索',
|
|
296
|
+
'section.sync': '会话同步',
|
|
297
|
+
'sync.interval': '间隔同步(分钟)',
|
|
298
|
+
'sync.interval.hint': '填0表示关闭间隔同步。',
|
|
299
|
+
'sync.daily': '每日定时',
|
|
300
|
+
'sync.daily.hint': '24小时制 HH:MM,留空表示关闭。',
|
|
301
|
+
'sync.idle': '对话空闲后同步',
|
|
302
|
+
'sync.idle.desc': '所有会话第一次全部进入空闲时自动同步一次。',
|
|
303
|
+
'sync.cooldown': '最小间隔(分钟)',
|
|
304
|
+
'sync.mode': '同步方式',
|
|
305
|
+
'sync.mode.local': '本地目录',
|
|
306
|
+
'sync.mode.webdav': 'WebDAV',
|
|
307
|
+
'sync.webdav.url': 'WebDAV 地址',
|
|
308
|
+
'sync.webdav.presets': '配置组',
|
|
309
|
+
'sync.webdav.presets.hint': '点一下即填入上面四项;最多保存三组。',
|
|
310
|
+
'sync.webdav.presets.save': '保存当前配置',
|
|
311
|
+
'sync.webdav.presets.modify': '修改配置',
|
|
312
|
+
'sync.webdav.presets.commitModify': '保存配置',
|
|
313
|
+
'sync.webdav.presets.updated': '已更新“{name}”。',
|
|
314
|
+
'sync.webdav.presets.replaced': '配置已替换。',
|
|
315
|
+
'sync.webdav.presets.replaceTitle': '替换哪一组配置?',
|
|
316
|
+
'sync.webdav.presets.replaceDesc': '已保存三组配置,请选择要被替换的一组。',
|
|
317
|
+
'sync.webdav.presets.saved': '已保存“{name}”。',
|
|
318
|
+
'sync.webdav.presets.rename': '重命名',
|
|
319
|
+
'sync.webdav.presets.name': '配置名称',
|
|
320
|
+
'sync.webdav.presets.confirm': '保存名称',
|
|
321
|
+
'sync.webdav.presets.default': '默认配置',
|
|
322
|
+
'sync.webdav.presets.remove': '删除',
|
|
323
|
+
'sync.webdav.presets.unsaved': '(当前填写,未保存)',
|
|
324
|
+
'sync.webdav.presets.full': '最多保存三组,请先删除一组。',
|
|
325
|
+
'sync.webdav.presets.empty': '请先填写地址。',
|
|
326
|
+
'sync.webdav.user': '账号',
|
|
327
|
+
'sync.webdav.password': '应用密码',
|
|
328
|
+
'sync.webdav.password.hint': '坚果云请到网页版“安全选项”生成应用密码,不要填登录密码。',
|
|
329
|
+
'sync.webdav.root': '远程根目录',
|
|
330
|
+
'sync.webdav.root.hint': '填完整路径,例如 https://dav.jianguoyun.com/dav/我的坚果云/DSH-Sync',
|
|
331
|
+
'sync.webdav.mirror': '本地镜像目录',
|
|
332
|
+
'sync.webdav.mirror.usage': '当前占用 {size}({files} 个文件)',
|
|
333
|
+
'sync.webdav.autoCreate': '自动创建远程目录',
|
|
334
|
+
'sync.webdav.autoCreate.desc': '远程路径不存在时,测试连接前会逐级创建。',
|
|
335
|
+
'sync.webdav.test': '测试连接',
|
|
336
|
+
'sync.webdav.testing': '正在连接…',
|
|
337
|
+
'sync.webdav.ok': '连接成功:{message}',
|
|
338
|
+
'sync.webdav.fail': '连接失败:{message}',
|
|
339
|
+
'sync.pull': '拉取一次',
|
|
340
|
+
'sync.push': '推送一次',
|
|
341
|
+
'sync.pull.confirm': '从云端拉取到本地镜像目录?只下载,不会上传或删除云端文件。',
|
|
342
|
+
'sync.push.confirm': '把本地镜像目录推送到云端?只有内容不同时才覆盖,不会删除云端已有文件。',
|
|
343
|
+
'sync.pulled': '已拉取 {n} 个文件({bytes}),跳过 {skipped} 个。',
|
|
344
|
+
'sync.pushed': '已推送 {n} 个文件({bytes}),跳过 {skipped} 个。',
|
|
345
|
+
'sync.directionFailed': '{n} 个文件失败',
|
|
346
|
+
'sync.noFailure': '无失败',
|
|
347
|
+
'switch.delete': '会话删除',
|
|
348
|
+
'switch.delete.desc': '在会话菜单中加入“删除会话”。运行中的会话不可删除。',
|
|
349
|
+
'switch.move': '会话移动',
|
|
350
|
+
'switch.move.desc': '在会话菜单中加入“移动到工作区”。移动会复制成新会话并永久删除原会话。',
|
|
351
|
+
'switch.autoLoad': '自动加载更早消息',
|
|
352
|
+
'switch.autoLoad.desc': '对话滚动到顶部时自动加载上一页历史,不需要再点“加载更早”。',
|
|
353
|
+
'sync.title': '会话与配置同步',
|
|
354
|
+
'sync.desc': '调用插件自带的同步引擎,把会话、配置与附件同步到共享目录。',
|
|
355
|
+
'sync.needDir': '请先填写共享目录。',
|
|
356
|
+
'sync.needMirror': '请先填写本地镜像目录。',
|
|
357
|
+
'sync.enable': '自动同步',
|
|
358
|
+
'sync.enable.hint': '只控制空闲、间隔、定时三种自动触发;“立即同步”不受此开关限制。',
|
|
359
|
+
'sync.dir': '共享目录',
|
|
360
|
+
'sync.machine': '机器标识',
|
|
361
|
+
'sync.machine.hint': '留空则使用系统用户名;若与共享中已有标识冲突,同步会被拒绝。',
|
|
362
|
+
'sync.machine.placeholder': '当前系统默认用户名:{id}',
|
|
363
|
+
'sync.attachments': '同步附件',
|
|
364
|
+
'sync.probe': '检查',
|
|
365
|
+
'sync.run': '立即同步',
|
|
366
|
+
'sync.running': '正在同步…',
|
|
367
|
+
'sync.never': '尚未运行。',
|
|
368
|
+
'sync.last': '上次同步:{time} · {result} · {ms} ms',
|
|
369
|
+
'sync.result.ok': '成功',
|
|
370
|
+
'sync.result.fail': '失败',
|
|
371
|
+
'sync.purged': '清理回收站 {n}',
|
|
372
|
+
'sync.paths': '目录创建 {created}、失败 {failed}',
|
|
373
|
+
'sync.failed': '{n} 个文件失败',
|
|
374
|
+
'sync.counts': '↑ {up} · ↓ {down} · 🗑 {del}',
|
|
375
|
+
'sync.transport': '传输:下载 {down}、上传 {up}',
|
|
376
|
+
'sync.transportDel': '传输:下载 {down}、上传 {up}、删除 {del}',
|
|
377
|
+
'sync.dirMissing': '共享目录不存在:{path}',
|
|
378
|
+
'sync.log': '查看日志',
|
|
379
|
+
'sync.logToggle': '点击展开或收起同步记录',
|
|
380
|
+
'sync.more': '查看更多',
|
|
381
|
+
'sync.historyCount': '共 {n} 次同步记录',
|
|
382
|
+
'sync.logHide': '收起日志',
|
|
383
|
+
'sync.failed': '同步失败:{message}',
|
|
384
|
+
'switch.trash': '会话找回',
|
|
385
|
+
'switch.trash.desc': '在会话菜单和本页显示会话找回入口,已删除会话保留在本机回收站。',
|
|
386
|
+
'switch.search': '内容搜索',
|
|
387
|
+
'switch.search.desc': '按 Ctrl+F 打开搜索面板,匹配标题与消息正文。',
|
|
388
|
+
'switch.matchTitle': '匹配会话标题',
|
|
389
|
+
'switch.matchBody': '匹配用户与助手消息',
|
|
390
|
+
'switch.matchTools': '匹配工具输出',
|
|
391
|
+
'switch.limits': '搜索范围',
|
|
392
|
+
'field.retention': '已删除会话保留天数',
|
|
393
|
+
'field.retention.hint': '填0表示一直保留,直到手动永久删除。',
|
|
394
|
+
'trash.usage': '{count}个会话,占用{size}',
|
|
395
|
+
'trash.clear': '清空回收站',
|
|
396
|
+
'trash.cleared': '回收站已清空。',
|
|
397
|
+
'delete.label': '删除会话',
|
|
398
|
+
'delete.running': '删除会话(运行中)',
|
|
399
|
+
'delete.title': '删除这个会话?',
|
|
400
|
+
'delete.desc': '将删除本机会话目录、会话缓存分片,以及工作区中的引用。会话会保留在回收站,直到超过保留期。',
|
|
401
|
+
'delete.confirm': '删除',
|
|
402
|
+
'delete.done': '“{title}”已删除。',
|
|
403
|
+
'delete.failed': '删除失败:{message}',
|
|
404
|
+
'delete.blocked': '运行中的会话不可删除。',
|
|
405
|
+
'move.label': '移动到工作区…',
|
|
406
|
+
'move.running': '移动到工作区(运行中)',
|
|
407
|
+
'move.title': '移动到工作区',
|
|
408
|
+
'move.desc': '将该会话整体移入目标工作区:会话本身不变,只是工作目录改到目标目录,之后的工具调用会在那里执行。分组变化需要重启应用后完全生效。',
|
|
409
|
+
'move.session': '会话:{title}',
|
|
410
|
+
'move.restarting': '已移动,正在重启以应用新分组…',
|
|
411
|
+
'move.current': '当前工作区:{title}',
|
|
412
|
+
'move.target': '目标工作区',
|
|
413
|
+
'move.empty': '没有其他工作区可移动。',
|
|
414
|
+
'move.loading': '正在读取工作区…',
|
|
415
|
+
'move.busy': '正在复制会话…',
|
|
416
|
+
'move.confirm': '移动',
|
|
417
|
+
'move.done': '已移动到“{title}”。',
|
|
418
|
+
'move.failed': '移动失败:{message}',
|
|
419
|
+
'trash.title': '删除会话管理',
|
|
420
|
+
'trash.untitled': '未命名',
|
|
421
|
+
'trash.menu': '本工作区会话找回',
|
|
422
|
+
'trash.desc': '本工作区中已删除的会话,可恢复或永久删除。',
|
|
423
|
+
'trash.empty': '暂无已删除的会话。',
|
|
424
|
+
'trash.restore': '恢复',
|
|
425
|
+
'trash.purge': '永久删除',
|
|
426
|
+
'trash.purge.confirm': '确认永久删除?',
|
|
427
|
+
'trash.clear': '清空回收站',
|
|
428
|
+
'trash.clear.confirm': '确认清空?',
|
|
429
|
+
'trash.clearWorkspace': '清空该工作区',
|
|
430
|
+
'trash.clearWorkspace.confirm': '确认清空?',
|
|
431
|
+
'trash.restored': '“{title}”已恢复。',
|
|
432
|
+
'trash.purged': '“{title}”已永久删除。',
|
|
433
|
+
'trash.loading': '正在读取…',
|
|
434
|
+
'search.placeholder': '搜索会话标题与内容',
|
|
435
|
+
'search.empty': '没有匹配结果。',
|
|
436
|
+
'search.hint': '输入关键词搜索全部会话,回车打开选中结果。',
|
|
437
|
+
'search.loading': '正在搜索…',
|
|
438
|
+
'search.error': '搜索失败:{message}',
|
|
439
|
+
'search.meta': '{count}个会话,{matches}处匹配',
|
|
440
|
+
'search.notLocated': '已打开会话,但该处尚未加载。可点击“加载更早”后再试。',
|
|
441
|
+
'search.close': '关闭搜索',
|
|
442
|
+
'role.user': '你',
|
|
443
|
+
'role.assistant': '助手',
|
|
444
|
+
'role.tool': '工具',
|
|
445
|
+
'role.title': '标题',
|
|
446
|
+
'common.close': '关闭',
|
|
447
|
+
'common.cancel': '取消',
|
|
448
|
+
'common.retry': '重试',
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const STYLES = `
|
|
453
|
+
.dshe-overlay{position:fixed;inset:0;z-index:2000;display:flex;justify-content:center;align-items:flex-start;pointer-events:none}
|
|
454
|
+
.dshe-overlay-top{z-index:2147482000}
|
|
455
|
+
.dshe-backdrop{position:absolute;inset:0;background:rgba(15,18,26,.42);pointer-events:auto}
|
|
456
|
+
.dshe-search{position:relative;pointer-events:auto;margin-top:6vh;width:min(720px,92vw);max-height:calc(100vh - 90px);display:flex;flex-direction:column;
|
|
457
|
+
background:var(--dsw-alias-bg-overlay,#fff);color:var(--dsw-alias-label-primary,#1b1d22);border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.12));
|
|
458
|
+
border-radius:14px;box-shadow:0 24px 60px rgba(0,0,0,.28);overflow:hidden;font-size:13px}
|
|
459
|
+
.dshe-search-head{display:flex;align-items:center;gap:8px;padding:12px 14px;border-bottom:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.1))}
|
|
460
|
+
.dshe-search-icon{display:inline-flex;color:var(--dsw-alias-label-secondary,#6b7280)}
|
|
461
|
+
.dshe-search-input{flex:1;min-width:0;border:0;outline:0;background:transparent;color:inherit;font-size:14px;line-height:20px;font-family:inherit}
|
|
462
|
+
.dshe-search-input::placeholder{color:var(--dsw-alias-label-secondary,#9aa1ad)}
|
|
463
|
+
.dshe-results{overflow:auto;padding:6px 6px 10px;min-height:64px;max-height:calc(100vh - 220px)}
|
|
464
|
+
.dshe-status{padding:14px;color:var(--dsw-alias-label-secondary,#6b7280);font-size:12px}
|
|
465
|
+
.dshe-error{color:var(--dsw-alias-state-error-primary,#c0392b)}
|
|
466
|
+
.dshe-group{padding:4px 0 8px}
|
|
467
|
+
.dshe-group-title{display:block;width:100%;text-align:left;border:0;background:transparent;color:var(--dsw-alias-label-primary,#1b1d22);
|
|
468
|
+
font:inherit;font-weight:600;padding:6px 10px;border-radius:8px;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
469
|
+
.dshe-group-title:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.05))}
|
|
470
|
+
.dshe-group-meta{color:var(--dsw-alias-label-secondary,#8a919c);font-weight:400;font-size:11px;margin-left:8px}
|
|
471
|
+
.dshe-match{display:flex;gap:8px;width:100%;text-align:left;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#4b5563);
|
|
472
|
+
font:inherit;padding:5px 10px 5px 18px;border-radius:8px;cursor:pointer;line-height:18px}
|
|
473
|
+
.dshe-match:hover,.dshe-match[data-active="true"]{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.06))}
|
|
474
|
+
.dshe-role{flex:none;font-size:11px;padding:0 6px;border-radius:6px;background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.05));
|
|
475
|
+
color:var(--dsw-alias-label-secondary,#6b7280);height:18px;line-height:18px}
|
|
476
|
+
.dshe-snippet{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-primary,#2b2f36)}
|
|
477
|
+
.dshe-mark{background:color-mix(in srgb,var(--dsw-alias-brand-primary,#3b6ef5) 26%,transparent);color:inherit;border-radius:3px;padding:0 1px}
|
|
478
|
+
.dshe-section{display:flex;flex-direction:column;gap:14px;width:100%;font-size:13px}
|
|
479
|
+
.dshe-section-title{margin:0;font-size:15px;font-weight:600;color:var(--dsw-alias-label-primary,#1b1d22)}
|
|
480
|
+
.dshe-subsection-title{margin:4px 0 0;font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#1b1d22);
|
|
481
|
+
padding-top:10px;border-top:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.08))}
|
|
482
|
+
.dshe-section-desc{margin:0;color:var(--dsw-alias-label-secondary,#6b7280);font-size:12px;line-height:18px}
|
|
483
|
+
.dshe-card{border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.1));border-radius:10px;overflow:hidden}
|
|
484
|
+
.dshe-row{display:flex;align-items:center;gap:12px;padding:10px 12px;border-bottom:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.08))}
|
|
485
|
+
.dshe-row:last-child{border-bottom:0}
|
|
486
|
+
.dshe-row-main{flex:1;min-width:0}
|
|
487
|
+
.dshe-row-title{font-size:13px;color:var(--dsw-alias-label-primary,#1b1d22)}
|
|
488
|
+
.dshe-row-desc{font-size:11px;color:var(--dsw-alias-label-secondary,#8a919c);margin-top:2px;line-height:16px}
|
|
489
|
+
.dshe-switch{flex:none;width:36px;height:20px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.2));
|
|
490
|
+
background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.08));position:relative;cursor:pointer;padding:0}
|
|
491
|
+
.dshe-switch[aria-checked="true"]{background:var(--dsw-alias-brand-primary,#3b6ef5);border-color:transparent}
|
|
492
|
+
.dshe-switch span{position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:var(--dsw-alias-label-primary,#1b1d22);transition:transform .12s ease,background .12s ease}
|
|
493
|
+
.dshe-switch[aria-checked="true"] span{transform:translateX(16px);background:#fff}
|
|
494
|
+
.dshe-number{flex:none;width:72px;padding:4px 8px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.2));
|
|
495
|
+
background:var(--dsw-alias-bg-layer-1,transparent);color:var(--dsw-alias-label-primary,#1b1d22);font:inherit;font-size:12px}
|
|
496
|
+
.dshe-text{flex:none;width:240px;max-width:46vw;padding:4px 8px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.2));
|
|
497
|
+
background:var(--dsw-alias-bg-layer-1,transparent);color:var(--dsw-alias-label-primary,#1b1d22);font:inherit;font-size:12px}
|
|
498
|
+
.dshe-sync-log{max-height:220px;overflow:auto;margin:0;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.05));
|
|
499
|
+
color:var(--dsw-alias-label-secondary,#4b5563);font-size:11px;line-height:16px;white-space:pre-wrap;word-break:break-all;font-family:var(--ds-font-family-code,monospace)}
|
|
500
|
+
font-family:var(--ds-font-family-code,monospace);font-size:11px;line-height:18px;color:var(--dsw-alias-label-secondary,#4b5563);word-break:break-all}
|
|
501
|
+
.dshe-counts{display:inline-flex;align-items:center;gap:1px}
|
|
502
|
+
.dshe-log-body{display:block;white-space:normal}
|
|
503
|
+
.dshe-log-line{display:flex;align-items:baseline;line-height:18px}
|
|
504
|
+
.dshe-log-label{flex:0 0 5em;text-align:justify;text-align-last:justify;text-justify:inter-character;white-space:nowrap}
|
|
505
|
+
.dshe-log-colon{flex:0 0 auto;margin:0 1px}
|
|
506
|
+
.dshe-log-text{flex:1 1 auto;white-space:pre-wrap;word-break:break-all}
|
|
507
|
+
.dshe-log-line-plain{display:block;padding-left:0.6em;color:var(--dsw-alias-label-secondary,#6b7280)}
|
|
508
|
+
.dshe-log-line-more{cursor:pointer}
|
|
509
|
+
.dshe-log-line-more:hover .dshe-log-text{color:var(--dsw-alias-label-primary,#1b1d22)}
|
|
510
|
+
.dshe-log-more{margin-left:4px;opacity:.55;font-size:10px}
|
|
511
|
+
.dshe-log-files{margin:2px 0 4px 5.6em;padding-left:6px;border-left:2px solid var(--dsw-alias-border-l1,rgba(0,0,0,.12))}
|
|
512
|
+
.dshe-log-file{font-family:var(--ds-font-family-code,monospace);font-size:10px;line-height:15px;color:var(--dsw-alias-label-secondary,#6b7280);word-break:break-all}
|
|
513
|
+
.dshe-log-line-sub .dshe-log-label{text-align:right;text-align-last:auto;color:var(--dsw-alias-label-secondary,#6b7280)}
|
|
514
|
+
.dshe-log-list{display:flex;flex-direction:column;gap:4px;align-items:stretch}
|
|
515
|
+
.dshe-log-scroll{max-height:42vh;overflow-y:auto;overflow-x:hidden;padding-right:2px;flex:0 0 auto}
|
|
516
|
+
.dshe-log-toggle{background:none;border:0;padding:0;margin:0;text-align:left;cursor:pointer;font:inherit;color:inherit;display:block;width:100%}
|
|
517
|
+
.dshe-log-toggle:hover{color:var(--dsw-alias-label-primary,#1b1d22)}
|
|
518
|
+
.dshe-log-item{border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.08));border-radius:8px;overflow:hidden;flex:0 0 auto}
|
|
519
|
+
.dshe-log-row{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;padding:6px 10px;
|
|
520
|
+
background:transparent;border:0;cursor:pointer;text-align:left;font-size:11px;line-height:16px;
|
|
521
|
+
color:var(--dsw-alias-label-secondary,#4b5563);font-family:var(--ds-font-family-code,monospace)}
|
|
522
|
+
.dshe-log-row:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.04))}
|
|
523
|
+
.dshe-log-row-open{color:var(--dsw-alias-label-primary,#1b1d22)}
|
|
524
|
+
.dshe-log-caret{opacity:.6}
|
|
525
|
+
.dshe-log-item .dshe-sync-log{border-radius:0;margin:0}
|
|
526
|
+
.dshe-hint{font-size:11px;color:var(--dsw-alias-label-secondary,#8a919c);padding:0 12px 10px}
|
|
527
|
+
.dshe-trash-body{max-height:46vh;overflow:auto;display:flex;flex-direction:column;gap:12px;min-height:80px}
|
|
528
|
+
.dshe-trash-group-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:2px 0 6px}
|
|
529
|
+
.dshe-trash-group-title{font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,#6b7280);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
530
|
+
.dshe-trash-group-actions{display:inline-flex;gap:6px;flex:none}
|
|
531
|
+
.dshe-link-danger{border:0;background:transparent;padding:0;font:inherit;font-size:11px;color:var(--dsw-alias-state-error-primary,#c0392b);cursor:pointer;flex:none}
|
|
532
|
+
.dshe-link-danger:hover{text-decoration:underline}
|
|
533
|
+
.dshe-link-danger[disabled]{opacity:.5;cursor:default;text-decoration:none}
|
|
534
|
+
background:var(--dsw-alias-bg-overlay,#fff);border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.12));
|
|
535
|
+
box-shadow:0 10px 30px rgba(0,0,0,.18);display:flex;flex-direction:column;gap:2px}
|
|
536
|
+
font:inherit;font-size:12px;padding:7px 10px;border-radius:6px;cursor:pointer}
|
|
537
|
+
.dshe-move-list{display:flex;flex-direction:column;gap:6px;max-height:40vh;overflow:auto}
|
|
538
|
+
.dshe-move-item{display:flex;align-items:flex-start;gap:8px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.1));border-radius:8px;cursor:pointer}
|
|
539
|
+
.dshe-move-item[data-active="true"]{border-color:var(--dsw-alias-brand-primary,#3b6ef5);background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.04))}
|
|
540
|
+
.dshe-move-item input{margin-top:2px;flex:none}
|
|
541
|
+
.dshe-move-main{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
542
|
+
.dshe-move-title{font-size:13px;color:var(--dsw-alias-label-primary,#1b1d22);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
543
|
+
.dshe-move-meta{font-size:11px;color:var(--dsw-alias-label-secondary,#8a919c);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
544
|
+
.dshe-trash-row{display:flex;align-items:center;gap:10px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.1));border-radius:8px}
|
|
545
|
+
.dshe-trash-main{flex:1;min-width:0}
|
|
546
|
+
.dshe-trash-title{font-size:13px;color:var(--dsw-alias-label-primary,#1b1d22);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
547
|
+
.dshe-trash-id{font-family:var(--ds-font-family-code,monospace);font-size:10px;line-height:14px;color:var(--dsw-alias-label-secondary,#8a919c);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
548
|
+
.dshe-trash-meta{font-size:11px;color:var(--dsw-alias-label-secondary,#8a919c);margin-top:2px}
|
|
549
|
+
.dshe-action{border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.2));background:transparent;color:var(--dsw-alias-label-primary,#1b1d22);
|
|
550
|
+
font:inherit;font-size:12px;padding:4px 10px;border-radius:8px;cursor:pointer}
|
|
551
|
+
.dshe-action:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.06))}
|
|
552
|
+
.dshe-action-active:hover,.dshe-action-active:focus-visible{background:var(--dsw-alias-brand-primary,#3b6ef5);color:#fff;filter:brightness(1.1)}
|
|
553
|
+
.dshe-action-danger:hover,.dshe-action-danger:focus-visible{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#c0392b) 12%,transparent)}
|
|
554
|
+
.dshe-action[disabled]{opacity:.5;cursor:default}
|
|
555
|
+
.dshe-presets{display:flex;flex-direction:column;gap:6px;padding:6px 0 2px}
|
|
556
|
+
.dshe-presets-head{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary,#1b1d22)}
|
|
557
|
+
.dshe-presets-chips{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
|
|
558
|
+
.dshe-select{border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.2));background:var(--dsw-alias-bg-overlay,#fff);
|
|
559
|
+
color:var(--dsw-alias-label-primary,#1b1d22);font:inherit;font-size:12px;padding:4px 8px;border-radius:8px;min-width:160px}
|
|
560
|
+
.dshe-preset-chip{display:inline-flex;align-items:center;gap:4px}
|
|
561
|
+
.dshe-action-active{background:var(--dsw-alias-brand-primary,#3b6ef5);color:#fff;border-color:transparent}
|
|
562
|
+
.dshe-action-danger{color:var(--dsw-alias-state-error-primary,#c0392b);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary,#c0392b) 45%,transparent)}
|
|
563
|
+
.dshe-toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%);pointer-events:auto;z-index:2010; background:var(--dsw-alias-bg-overlay,#fff);color:var(--dsw-alias-label-primary,#1b1d22);border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.12));
|
|
564
|
+
border-radius:10px;padding:8px 14px;font-size:12px;box-shadow:0 10px 30px rgba(0,0,0,.2);max-width:70vw}
|
|
565
|
+
.dshe-toast[data-kind="error"]{color:var(--dsw-alias-state-error-primary,#c0392b)}
|
|
566
|
+
`;
|
|
567
|
+
|
|
568
|
+
// ── store ────────────────────────────────────────────────────────────────
|
|
569
|
+
|
|
570
|
+
function createStore() {
|
|
571
|
+
let state = {
|
|
572
|
+
ready: false,
|
|
573
|
+
settings: { ...DEFAULTS },
|
|
574
|
+
toast: null,
|
|
575
|
+
search: { open: false, query: '', status: 'idle', groups: [], error: null, tookMs: 0, truncated: false, scanned: 0 },
|
|
576
|
+
trash: { open: false, loading: false, groups: [], error: null, busy: null, confirmPurge: null, confirmClear: false, confirmWorkspace: null, count: 0, size: 0, scopeSession: null, scopeWorkspace: null },
|
|
577
|
+
pendingDelete: null,
|
|
578
|
+
deleteBusy: false,
|
|
579
|
+
deleteError: null,
|
|
580
|
+
move: { open: false, sessionId: null, title: '', loading: false, current: null, workspaces: [], targetId: null, error: null, busy: false },
|
|
581
|
+
sync: { loading: false, busy: false, target: null, state: null, error: null, showLog: false, webdav: null, webdavBusy: false, history: [], historyOpen: null, historyLimit: 5, auto: null },
|
|
582
|
+
overwrite: { open: false, direction: 'cloud', busy: false, preview: null, error: null },
|
|
583
|
+
restartConfirm: false,
|
|
584
|
+
presetEdit: null,
|
|
585
|
+
presetReplace: null,
|
|
586
|
+
pauseOpen: false,
|
|
587
|
+
pauseShownAt: null,
|
|
588
|
+
envCheck: { busy: false, open: false, result: null, reportPath: null },
|
|
589
|
+
updatePrompt: { open: false, appVersion: null, lastAppVersion: null },
|
|
590
|
+
};
|
|
591
|
+
const listeners = new Set();
|
|
592
|
+
let toastTimer = null;
|
|
593
|
+
let searchTimer = null;
|
|
594
|
+
let searchController = null;
|
|
595
|
+
let searchSeq = 0;
|
|
596
|
+
|
|
597
|
+
/** Saved setups match only when all four connection fields agree. */
|
|
598
|
+
function matchesPreset(item, settings) {
|
|
599
|
+
const trim = (value) => String(value ?? '').trim().replace(/[\\/]+$/u, '');
|
|
600
|
+
return trim(item.url) === trim(settings.webdavUrl)
|
|
601
|
+
&& String(item.user ?? '').trim() === String(settings.webdavUser ?? '').trim()
|
|
602
|
+
&& String(item.password ?? '') === String(settings.webdavPassword ?? '')
|
|
603
|
+
&& trim(item.root) === trim(settings.webdavRoot);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const store = {
|
|
607
|
+
get: () => state,
|
|
608
|
+
subscribe(listener) {
|
|
609
|
+
listeners.add(listener);
|
|
610
|
+
return () => listeners.delete(listener);
|
|
611
|
+
},
|
|
612
|
+
set(patch) {
|
|
613
|
+
state = { ...state, ...patch };
|
|
614
|
+
for (const listener of listeners) listener();
|
|
615
|
+
},
|
|
616
|
+
patchSearch(patch) {
|
|
617
|
+
store.set({ search: { ...state.search, ...patch } });
|
|
618
|
+
},
|
|
619
|
+
patchTrash(patch) {
|
|
620
|
+
store.set({ trash: { ...state.trash, ...patch } });
|
|
621
|
+
},
|
|
622
|
+
patchTrashState(patch) {
|
|
623
|
+
store.patchTrash(patch);
|
|
624
|
+
},
|
|
625
|
+
toast(kind, text) {
|
|
626
|
+
if (toastTimer !== null) clearTimeout(toastTimer);
|
|
627
|
+
store.set({ toast: { kind, text, id: Date.now() } });
|
|
628
|
+
toastTimer = setTimeout(() => store.set({ toast: null }), kind === 'error' ? 6000 : 3500);
|
|
629
|
+
},
|
|
630
|
+
async init() {
|
|
631
|
+
try {
|
|
632
|
+
const data = await runtime.rpc('state');
|
|
633
|
+
store.set({
|
|
634
|
+
ready: true,
|
|
635
|
+
settings: { ...DEFAULTS, ...data.settings },
|
|
636
|
+
trash: { ...state.trash, count: Number(data.count) || 0, size: Number(data.size) || 0 },
|
|
637
|
+
});
|
|
638
|
+
} catch (error) {
|
|
639
|
+
store.set({ ready: true });
|
|
640
|
+
console.warn('[dsh-enhanced] initial state failed:', error);
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
async refreshCount() {
|
|
644
|
+
try {
|
|
645
|
+
const data = await runtime.rpc('state');
|
|
646
|
+
store.patchTrash({ count: Number(data.count) || 0, size: Number(data.size) || 0 });
|
|
647
|
+
store.set({ settings: { ...DEFAULTS, ...data.settings } });
|
|
648
|
+
} catch {
|
|
649
|
+
// The badge is decorative; a failed refresh changes nothing.
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
async saveSettings(rawPatch) {
|
|
653
|
+
// Master/sub switch coupling:
|
|
654
|
+
// master off + any sub turned on -> master on
|
|
655
|
+
// master turned off -> every sub off
|
|
656
|
+
// master turned on -> subs keep their state
|
|
657
|
+
const patch = { ...rawPatch };
|
|
658
|
+
if (Object.prototype.hasOwnProperty.call(patch, 'syncEnabled')) {
|
|
659
|
+
if (patch.syncEnabled !== true) {
|
|
660
|
+
patch.syncOnIdle = false;
|
|
661
|
+
patch.syncIntervalMinutes = 0;
|
|
662
|
+
patch.syncDailyAt = '';
|
|
663
|
+
}
|
|
664
|
+
} else {
|
|
665
|
+
const merged = { ...state.settings, ...patch };
|
|
666
|
+
const anySub = merged.syncOnIdle === true
|
|
667
|
+
|| Number(merged.syncIntervalMinutes) > 0
|
|
668
|
+
|| (typeof merged.syncDailyAt === 'string' && merged.syncDailyAt.trim() !== '');
|
|
669
|
+
if (anySub && merged.syncEnabled !== true) patch.syncEnabled = true;
|
|
670
|
+
}
|
|
671
|
+
const next = { ...state.settings, ...patch };
|
|
672
|
+
store.set({ settings: next });
|
|
673
|
+
try {
|
|
674
|
+
const data = await runtime.rpc('settings.set', { patch });
|
|
675
|
+
store.set({ settings: { ...DEFAULTS, ...data.settings } });
|
|
676
|
+
} catch (error) {
|
|
677
|
+
store.toast('error', String(error?.message ?? error));
|
|
678
|
+
await store.init();
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
openSearch() {
|
|
682
|
+
store.patchSearch({ open: true });
|
|
683
|
+
const query = state.search.query;
|
|
684
|
+
if (query.trim() !== '' && state.search.status === 'idle') store.runSearch(query);
|
|
685
|
+
},
|
|
686
|
+
closeSearch() {
|
|
687
|
+
if (searchTimer !== null) clearTimeout(searchTimer);
|
|
688
|
+
searchTimer = null;
|
|
689
|
+
if (searchController !== null) searchController.abort();
|
|
690
|
+
searchController = null;
|
|
691
|
+
store.patchSearch({ open: false, status: 'idle' });
|
|
692
|
+
},
|
|
693
|
+
setQuery(query) {
|
|
694
|
+
store.patchSearch({ query });
|
|
695
|
+
if (searchTimer !== null) clearTimeout(searchTimer);
|
|
696
|
+
if (query.trim() === '') {
|
|
697
|
+
if (searchController !== null) searchController.abort();
|
|
698
|
+
searchController = null;
|
|
699
|
+
store.patchSearch({ status: 'idle', groups: [], error: null, scanned: 0 });
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
searchTimer = setTimeout(() => {
|
|
703
|
+
searchTimer = null;
|
|
704
|
+
store.runSearch(query);
|
|
705
|
+
}, 220);
|
|
706
|
+
},
|
|
707
|
+
async runSearch(query) {
|
|
708
|
+
const seq = ++searchSeq;
|
|
709
|
+
if (searchController !== null) searchController.abort();
|
|
710
|
+
const controller = new AbortController();
|
|
711
|
+
searchController = controller;
|
|
712
|
+
store.patchSearch({ status: 'loading', error: null });
|
|
713
|
+
try {
|
|
714
|
+
const data = await runtime.rpc('search', { query }, controller.signal);
|
|
715
|
+
if (seq !== searchSeq) return;
|
|
716
|
+
store.patchSearch({
|
|
717
|
+
status: 'done',
|
|
718
|
+
groups: Array.isArray(data.groups) ? data.groups : [],
|
|
719
|
+
error: null,
|
|
720
|
+
tookMs: Number(data.tookMs) || 0,
|
|
721
|
+
truncated: data.truncated === true,
|
|
722
|
+
scanned: Number(data.scanned) || 0,
|
|
723
|
+
});
|
|
724
|
+
} catch (error) {
|
|
725
|
+
if (seq !== searchSeq || controller.signal.aborted) return;
|
|
726
|
+
store.patchSearch({ status: 'error', error: String(error?.message ?? error), groups: [] });
|
|
727
|
+
} finally {
|
|
728
|
+
if (searchController === controller) searchController = null;
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
requestDelete(sessionId, title, running) {
|
|
732
|
+
store.set({ pendingDelete: { sessionId, title, running: running === true }, deleteError: null, deleteBusy: false });
|
|
733
|
+
},
|
|
734
|
+
cancelDelete() {
|
|
735
|
+
if (state.deleteBusy) return;
|
|
736
|
+
store.set({ pendingDelete: null, deleteError: null });
|
|
737
|
+
},
|
|
738
|
+
async confirmDelete() {
|
|
739
|
+
const pending = state.pendingDelete;
|
|
740
|
+
if (pending === null) return;
|
|
741
|
+
store.set({ deleteBusy: true, deleteError: null });
|
|
742
|
+
try {
|
|
743
|
+
const data = await runtime.rpc('session.delete', { sessionId: pending.sessionId });
|
|
744
|
+
store.set({ pendingDelete: null, deleteBusy: false });
|
|
745
|
+
store.toast('success', runtime.t('delete.done', { title: data?.title ?? pending.title }));
|
|
746
|
+
await store.refreshCount();
|
|
747
|
+
store.restartApp();
|
|
748
|
+
} catch (error) {
|
|
749
|
+
store.set({ deleteBusy: false, deleteError: String(error?.message ?? error) });
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
async openTrash() {
|
|
753
|
+
store.patchTrash({ open: true, loading: true, error: null, scopeSession: null, scopeWorkspace: null, confirmPurge: null, confirmClear: false, confirmWorkspace: null });
|
|
754
|
+
await store.loadTrash();
|
|
755
|
+
},
|
|
756
|
+
async openTrashForSession(sessionId) {
|
|
757
|
+
store.patchTrash({ open: true, loading: true, error: null, scopeSession: sessionId, scopeWorkspace: null, confirmPurge: null, confirmClear: false, confirmWorkspace: null });
|
|
758
|
+
await store.loadTrash();
|
|
759
|
+
},
|
|
760
|
+
closeTrash() {
|
|
761
|
+
if (state.trash.busy !== null) return;
|
|
762
|
+
store.patchTrash({ open: false, confirmPurge: null, confirmClear: false, confirmWorkspace: null, scopeSession: null, scopeWorkspace: null });
|
|
763
|
+
},
|
|
764
|
+
async loadTrash() {
|
|
765
|
+
store.patchTrash({ loading: true, error: null });
|
|
766
|
+
try {
|
|
767
|
+
const scope = { sessionId: state.trash.scopeSession, workspaceId: state.trash.scopeWorkspace };
|
|
768
|
+
const data = await runtime.rpc('trash.list', scope);
|
|
769
|
+
store.patchTrash({
|
|
770
|
+
loading: false,
|
|
771
|
+
groups: Array.isArray(data.groups) ? data.groups : [],
|
|
772
|
+
count: Number(data.count) || 0,
|
|
773
|
+
size: Number(data.size) || 0,
|
|
774
|
+
});
|
|
775
|
+
} catch (error) {
|
|
776
|
+
store.patchTrash({ loading: false, error: String(error?.message ?? error) });
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
requestPurge(sessionId) {
|
|
780
|
+
store.patchTrash({ confirmPurge: sessionId, confirmClear: false, confirmWorkspace: null });
|
|
781
|
+
},
|
|
782
|
+
async restore(sessionId, title) {
|
|
783
|
+
store.patchTrash({ busy: sessionId });
|
|
784
|
+
try {
|
|
785
|
+
const data = await runtime.rpc('trash.restore', { sessionId });
|
|
786
|
+
await store.loadTrash();
|
|
787
|
+
const warning = typeof data?.warning === 'string' && data.warning !== '' ? data.warning : null;
|
|
788
|
+
store.toast(warning === null ? 'success' : 'info', warning ?? runtime.t('trash.restored', { title }));
|
|
789
|
+
store.patchTrash({ open: false, confirmPurge: null, confirmClear: false });
|
|
790
|
+
if (typeof data?.workspaceId === 'string' && data.workspaceId !== '') {
|
|
791
|
+
await runtime.refreshWorkspace(data.workspaceId);
|
|
792
|
+
}
|
|
793
|
+
store.restartApp();
|
|
794
|
+
} catch (error) {
|
|
795
|
+
store.toast('error', String(error?.message ?? error));
|
|
796
|
+
} finally {
|
|
797
|
+
store.patchTrash({ busy: null });
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
async purge(sessionId, title) {
|
|
801
|
+
store.patchTrash({ busy: sessionId, confirmPurge: null });
|
|
802
|
+
try {
|
|
803
|
+
await runtime.rpc('trash.purge', { sessionId });
|
|
804
|
+
await store.loadTrash();
|
|
805
|
+
store.toast('success', runtime.t('trash.purged', { title }));
|
|
806
|
+
} catch (error) {
|
|
807
|
+
store.toast('error', String(error?.message ?? error));
|
|
808
|
+
} finally {
|
|
809
|
+
store.patchTrash({ busy: null });
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
requestClear() {
|
|
813
|
+
store.patchTrash({ confirmClear: true, confirmPurge: null, confirmWorkspace: null });
|
|
814
|
+
},
|
|
815
|
+
async clearTrash() {
|
|
816
|
+
store.patchTrash({ busy: '*', confirmClear: false });
|
|
817
|
+
try {
|
|
818
|
+
await runtime.rpc('trash.clear');
|
|
819
|
+
await store.loadTrash();
|
|
820
|
+
store.toast('success', runtime.t('trash.cleared'));
|
|
821
|
+
} catch (error) {
|
|
822
|
+
store.toast('error', String(error?.message ?? error));
|
|
823
|
+
} finally {
|
|
824
|
+
store.patchTrash({ busy: null });
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
requestClearWorkspace(workspaceId) {
|
|
828
|
+
store.patchTrash({ confirmWorkspace: workspaceId, confirmClear: false, confirmPurge: null });
|
|
829
|
+
}, async clearWorkspace(workspaceId) {
|
|
830
|
+
store.patchTrash({ busy: workspaceId, confirmWorkspace: null });
|
|
831
|
+
try {
|
|
832
|
+
const data = await runtime.rpc('trash.clear', { workspaceId });
|
|
833
|
+
await store.loadTrash();
|
|
834
|
+
store.toast('success', `${runtime.t('trash.clearWorkspace')} · ${String(Number(data?.removed) || 0)}`);
|
|
835
|
+
} catch (error) {
|
|
836
|
+
store.toast('error', String(error?.message ?? error));
|
|
837
|
+
} finally {
|
|
838
|
+
store.patchTrash({ busy: null });
|
|
839
|
+
}
|
|
840
|
+
},
|
|
841
|
+
async openMove(sessionId, title) {
|
|
842
|
+
store.set({
|
|
843
|
+
move: {
|
|
844
|
+
open: true,
|
|
845
|
+
sessionId,
|
|
846
|
+
title: title === '' ? '未命名会话' : title,
|
|
847
|
+
loading: true,
|
|
848
|
+
current: null,
|
|
849
|
+
workspaces: [],
|
|
850
|
+
targetId: null,
|
|
851
|
+
error: null,
|
|
852
|
+
busy: false,
|
|
853
|
+
},
|
|
854
|
+
});
|
|
855
|
+
try {
|
|
856
|
+
const data = await runtime.rpc('workspace.candidates', { sessionId });
|
|
857
|
+
const workspaces = Array.isArray(data.workspaces) ? data.workspaces : [];
|
|
858
|
+
store.set({
|
|
859
|
+
move: { ...state.move, loading: false, current: data.current ?? null, workspaces, targetId: workspaces[0]?.id ?? null },
|
|
860
|
+
});
|
|
861
|
+
} catch (error) {
|
|
862
|
+
store.set({ move: { ...state.move, loading: false, error: String(error?.message ?? error) } });
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
closeMove() {
|
|
866
|
+
if (state.move.busy) return;
|
|
867
|
+
store.set({ move: { ...state.move, open: false } });
|
|
868
|
+
},
|
|
869
|
+
setMoveTarget(targetId) {
|
|
870
|
+
store.set({ move: { ...state.move, targetId } });
|
|
871
|
+
},
|
|
872
|
+
async confirmMove() {
|
|
873
|
+
const move = state.move;
|
|
874
|
+
if (move.busy || move.targetId === null) return;
|
|
875
|
+
store.set({ move: { ...move, busy: true, error: null } });
|
|
876
|
+
try {
|
|
877
|
+
const data = await runtime.rpc('session.move', { sessionId: move.sessionId, workspaceId: move.targetId });
|
|
878
|
+
const target = move.workspaces.find((workspace) => workspace.id === move.targetId);
|
|
879
|
+
store.set({ move: { ...state.move, open: false, busy: false } });
|
|
880
|
+
const warning = typeof data?.warning === 'string' && data.warning !== '' ? data.warning : null;
|
|
881
|
+
store.toast(warning === null ? 'success' : 'info', warning ?? runtime.t('move.done', { title: target?.title ?? '' }));
|
|
882
|
+
await store.refreshCount();
|
|
883
|
+
if (data?.needsRestart === true) store.restartApp();
|
|
884
|
+
} catch (error) {
|
|
885
|
+
store.set({ move: { ...state.move, busy: false, error: String(error?.message ?? error) } });
|
|
886
|
+
}
|
|
887
|
+
},
|
|
888
|
+
async loadSync() {
|
|
889
|
+
try {
|
|
890
|
+
const data = await runtime.rpc('sync.state');
|
|
891
|
+
const auto = data?.auto ?? null;
|
|
892
|
+
if (auto?.paused === true && auto.pausedAt !== null && auto.pausedAt !== state.pauseShownAt) {
|
|
893
|
+
store.set({ pauseOpen: true, pauseShownAt: auto.pausedAt });
|
|
894
|
+
}
|
|
895
|
+
store.set({
|
|
896
|
+
sync: {
|
|
897
|
+
...state.sync,
|
|
898
|
+
loading: false,
|
|
899
|
+
error: null,
|
|
900
|
+
target: data?.target ?? null,
|
|
901
|
+
state: data?.state ?? null,
|
|
902
|
+
auto,
|
|
903
|
+
history: Array.isArray(data?.history) ? data.history : [],
|
|
904
|
+
},
|
|
905
|
+
});
|
|
906
|
+
} catch (error) {
|
|
907
|
+
store.set({ sync: { ...state.sync, loading: false, error: String(error?.message ?? error) } });
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
async probeSync() {
|
|
911
|
+
if (state.sync.busy) return;
|
|
912
|
+
store.set({ sync: { ...state.sync, busy: true, error: null } });
|
|
913
|
+
try {
|
|
914
|
+
const data = await runtime.rpc('sync.probe');
|
|
915
|
+
store.set({
|
|
916
|
+
sync: { ...state.sync, busy: false, state: data, error: data?.ok === false ? String(data?.summary?.error ?? runtime.t('sync.result.fail')) : null },
|
|
917
|
+
});
|
|
918
|
+
} catch (error) {
|
|
919
|
+
store.set({ sync: { ...state.sync, busy: false, error: String(error?.message ?? error) } });
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
async runSyncNow() {
|
|
923
|
+
if (state.sync.busy) return;
|
|
924
|
+
store.set({ sync: { ...state.sync, busy: true, error: null } });
|
|
925
|
+
try {
|
|
926
|
+
const data = await runtime.rpc('sync.run');
|
|
927
|
+
store.set({ sync: { ...state.sync, busy: false, state: data, error: null } });
|
|
928
|
+
store.toast(
|
|
929
|
+
data?.ok === false ? 'error' : 'success',
|
|
930
|
+
data?.ok === false
|
|
931
|
+
? runtime.t('sync.failed', { message: String(data?.summary?.error ?? data?.exitCode ?? '?') })
|
|
932
|
+
: runtime.t('sync.result.ok'),
|
|
933
|
+
);
|
|
934
|
+
await store.loadSync();
|
|
935
|
+
const pulled = Number(data?.summary?.sessions?.pulled) || Number(data?.summary?.sessions?.created) || 0;
|
|
936
|
+
if (pulled > 0) {
|
|
937
|
+
store.toast('success', `${runtime.t('sync.result.ok')}${runtime.t('sync.restartingSoon')}`);
|
|
938
|
+
store.restartApp();
|
|
939
|
+
}
|
|
940
|
+
} catch (error) {
|
|
941
|
+
store.set({ sync: { ...state.sync, busy: false, error: String(error?.message ?? error) } });
|
|
942
|
+
store.toast('error', String(error?.message ?? error));
|
|
943
|
+
await store.loadSync();
|
|
944
|
+
}
|
|
945
|
+
},
|
|
946
|
+
/** Restart the app so a structural change becomes visible. */
|
|
947
|
+
restartApp() {
|
|
948
|
+
window.setTimeout(() => {
|
|
949
|
+
void runtime.rpc('app.restart').catch((error) => {
|
|
950
|
+
const message = String(error?.message ?? error);
|
|
951
|
+
// The host refuses while a turn is running; say so instead of
|
|
952
|
+
// looking like the button did nothing.
|
|
953
|
+
store.toast('error', message.includes('restart-busy')
|
|
954
|
+
? runtime.t('restart.busy')
|
|
955
|
+
: message);
|
|
956
|
+
});
|
|
957
|
+
}, 400);
|
|
958
|
+
},
|
|
959
|
+
openRestart() {
|
|
960
|
+
store.set({ restartConfirm: true });
|
|
961
|
+
},
|
|
962
|
+
startPresetRename() {
|
|
963
|
+
const settings = state.settings ?? {};
|
|
964
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
965
|
+
const active = presets.find((item) => matchesPreset(item, settings)) ?? null;
|
|
966
|
+
if (active === null) return;
|
|
967
|
+
store.set({ presetEdit: { mode: 'rename', id: active.id, name: active.name } });
|
|
968
|
+
},
|
|
969
|
+
startPresetSave() {
|
|
970
|
+
const settings = state.settings ?? {};
|
|
971
|
+
const url = String(settings.webdavUrl ?? '').trim();
|
|
972
|
+
if (url === '') return;
|
|
973
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
974
|
+
if (presets.length >= 3) {
|
|
975
|
+
store.set({ presetReplace: { open: true } });
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
store.set({ presetEdit: { mode: 'save', id: null, name: '' } });
|
|
979
|
+
},
|
|
980
|
+
startPresetModify() {
|
|
981
|
+
const settings = state.settings ?? {};
|
|
982
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
983
|
+
const active = presets.find((item) => matchesPreset(item, settings)) ?? null;
|
|
984
|
+
if (active === null) return;
|
|
985
|
+
store.set({ presetEdit: { mode: 'modify', id: active.id, name: active.name } });
|
|
986
|
+
},
|
|
987
|
+
commitPresetModify() {
|
|
988
|
+
const current = state.presetEdit;
|
|
989
|
+
if (current === null) return;
|
|
990
|
+
const settings = state.settings ?? {};
|
|
991
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
992
|
+
const list = presets.map((item) => (item.id === current.id
|
|
993
|
+
? {
|
|
994
|
+
...item,
|
|
995
|
+
url: settings.webdavUrl ?? '',
|
|
996
|
+
user: settings.webdavUser ?? '',
|
|
997
|
+
password: settings.webdavPassword ?? '',
|
|
998
|
+
root: settings.webdavRoot ?? '',
|
|
999
|
+
}
|
|
1000
|
+
: item));
|
|
1001
|
+
store.set({ presetEdit: null });
|
|
1002
|
+
void runtime.store.saveSettings({ webdavProfiles: list })
|
|
1003
|
+
.then(() => runtime.store.toast('success', runtime.t('sync.webdav.presets.updated', { name: current.name })))
|
|
1004
|
+
.catch((error) => runtime.store.toast('error', String(error?.message ?? error)));
|
|
1005
|
+
},
|
|
1006
|
+
closePresetReplace() {
|
|
1007
|
+
store.set({ presetReplace: null });
|
|
1008
|
+
},
|
|
1009
|
+
confirmPresetReplace(id) {
|
|
1010
|
+
const settings = state.settings ?? {};
|
|
1011
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
1012
|
+
const list = presets.map((item) => (item.id === id
|
|
1013
|
+
? {
|
|
1014
|
+
...item,
|
|
1015
|
+
url: settings.webdavUrl ?? '',
|
|
1016
|
+
user: settings.webdavUser ?? '',
|
|
1017
|
+
password: settings.webdavPassword ?? '',
|
|
1018
|
+
root: settings.webdavRoot ?? '',
|
|
1019
|
+
custom: true,
|
|
1020
|
+
}
|
|
1021
|
+
: item));
|
|
1022
|
+
store.set({ presetReplace: null });
|
|
1023
|
+
void runtime.store.saveSettings({ webdavProfiles: list })
|
|
1024
|
+
.then(() => runtime.store.toast('success', runtime.t('sync.webdav.presets.replaced')))
|
|
1025
|
+
.catch((error) => runtime.store.toast('error', String(error?.message ?? error)));
|
|
1026
|
+
},
|
|
1027
|
+
setPresetName(name) {
|
|
1028
|
+
const current = state.presetEdit;
|
|
1029
|
+
if (current === null) return;
|
|
1030
|
+
store.set({ presetEdit: { ...current, name } });
|
|
1031
|
+
},
|
|
1032
|
+
cancelPresetEdit() {
|
|
1033
|
+
store.set({ presetEdit: null });
|
|
1034
|
+
},
|
|
1035
|
+
dropActivePreset() {
|
|
1036
|
+
const settings = state.settings ?? {};
|
|
1037
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
1038
|
+
const active = presets.find((item) => matchesPreset(item, settings)) ?? null;
|
|
1039
|
+
if (active === null) return;
|
|
1040
|
+
const rest = presets.filter((item) => item.id !== active.id);
|
|
1041
|
+
const next = rest[0];
|
|
1042
|
+
void runtime.store.saveSettings(next === undefined
|
|
1043
|
+
? { webdavProfiles: rest }
|
|
1044
|
+
: { webdavProfiles: rest, webdavUrl: next.url, webdavUser: next.user, webdavPassword: next.password, webdavRoot: next.root });
|
|
1045
|
+
},
|
|
1046
|
+
commitPresetEdit() {
|
|
1047
|
+
const current = state.presetEdit;
|
|
1048
|
+
if (current === null) return;
|
|
1049
|
+
let name = String(current.name ?? '').trim();
|
|
1050
|
+
if (name === '') {
|
|
1051
|
+
const url = String(state.settings?.webdavUrl ?? '').trim();
|
|
1052
|
+
let host = 'WebDAV';
|
|
1053
|
+
try { host = new URL(url).host; } catch { host = url.replace(/^https?:\/\//u, '').split('/')[0] || 'WebDAV'; }
|
|
1054
|
+
const root = String(state.settings?.webdavRoot ?? '').trim();
|
|
1055
|
+
name = root === '' || root === '/' ? host : `${host} · ${root}`;
|
|
1056
|
+
}
|
|
1057
|
+
const settings = state.settings ?? {};
|
|
1058
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
1059
|
+
if (current.mode === 'rename') {
|
|
1060
|
+
const list = presets.map((item) => (item.id === current.id ? { ...item, name, custom: true } : item));
|
|
1061
|
+
store.set({ presetEdit: null });
|
|
1062
|
+
void runtime.store.saveSettings({ webdavProfiles: list });
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
const entry = {
|
|
1066
|
+
id: `p${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`,
|
|
1067
|
+
name,
|
|
1068
|
+
url: settings.webdavUrl ?? '',
|
|
1069
|
+
user: settings.webdavUser ?? '',
|
|
1070
|
+
password: settings.webdavPassword ?? '',
|
|
1071
|
+
root: settings.webdavRoot ?? '',
|
|
1072
|
+
custom: true,
|
|
1073
|
+
};
|
|
1074
|
+
if (presets.length >= 3) {
|
|
1075
|
+
runtime.store.toast('error', runtime.t('sync.webdav.presets.full'));
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
store.set({ presetEdit: null });
|
|
1079
|
+
void runtime.store.saveSettings({ webdavProfiles: [...presets, entry] })
|
|
1080
|
+
.then(() => runtime.store.toast('success', runtime.t('sync.webdav.presets.saved', { name })))
|
|
1081
|
+
.catch((error) => runtime.store.toast('error', String(error?.message ?? error)));
|
|
1082
|
+
},
|
|
1083
|
+
closeRestart() {
|
|
1084
|
+
store.set({ restartConfirm: false });
|
|
1085
|
+
},
|
|
1086
|
+
confirmRestart() {
|
|
1087
|
+
store.set({ restartConfirm: false });
|
|
1088
|
+
store.restartApp();
|
|
1089
|
+
},
|
|
1090
|
+
openOverwrite(direction) {
|
|
1091
|
+
store.set({ overwrite: { open: true, direction, busy: false, preview: null, error: null } });
|
|
1092
|
+
},
|
|
1093
|
+
closeOverwrite() {
|
|
1094
|
+
if (state.overwrite.busy === true) return;
|
|
1095
|
+
store.set({ overwrite: { ...state.overwrite, open: false } });
|
|
1096
|
+
},
|
|
1097
|
+
async confirmOverwrite() {
|
|
1098
|
+
const direction = state.overwrite.direction;
|
|
1099
|
+
store.set({ overwrite: { ...state.overwrite, busy: true, error: null } });
|
|
1100
|
+
try {
|
|
1101
|
+
const result = await runtime.rpc('sync.overwrite', { direction, apply: true });
|
|
1102
|
+
store.set({ overwrite: { ...state.overwrite, open: false, busy: false } });
|
|
1103
|
+
store.toast('success', direction === 'cloud'
|
|
1104
|
+
? runtime.t('overwrite.cloudDone', { n: String(result?.uploaded ?? 0) })
|
|
1105
|
+
: runtime.t('overwrite.localDone', { n: String(result?.copied ?? 0) }));
|
|
1106
|
+
await store.loadSync();
|
|
1107
|
+
// Replacing this machine wholesale only takes effect after a restart.
|
|
1108
|
+
if (direction === 'local') store.restartApp();
|
|
1109
|
+
} catch (error) {
|
|
1110
|
+
store.set({ overwrite: { ...state.overwrite, busy: false, error: String(error?.message ?? error) } });
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
dismissPauseNotice() {
|
|
1114
|
+
store.set({ pauseOpen: false });
|
|
1115
|
+
},
|
|
1116
|
+
async resumeAutoSync() {
|
|
1117
|
+
try {
|
|
1118
|
+
const data = await runtime.rpc('sync.resume');
|
|
1119
|
+
store.set({ pauseOpen: false, sync: { ...state.sync, auto: data?.auto ?? null } });
|
|
1120
|
+
store.toast('success', runtime.t('pause.resumed'));
|
|
1121
|
+
} catch (error) {
|
|
1122
|
+
store.toast('error', String(error?.message ?? error));
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
async runEnvCheck() {
|
|
1126
|
+
store.set({ envCheck: { ...state.envCheck, busy: true, open: true, result: null, reportPath: null } });
|
|
1127
|
+
try {
|
|
1128
|
+
const result = await runtime.rpc('env.check');
|
|
1129
|
+
store.set({ envCheck: { ...state.envCheck, busy: false, open: true, result } });
|
|
1130
|
+
// A deliberate check counts as "I have seen this version".
|
|
1131
|
+
void runtime.rpc('env.ack').catch(() => {});
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
store.set({ envCheck: { ...state.envCheck, busy: false, open: true, result: { ok: false, failedCount: 1, checks: [{ label: '检测失败', ok: false, detail: String(error?.message ?? error), severity: 'high' }] } } });
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
closeEnvCheck() {
|
|
1137
|
+
store.set({ envCheck: { ...state.envCheck, open: false } });
|
|
1138
|
+
},
|
|
1139
|
+
async writeEnvReport() {
|
|
1140
|
+
try {
|
|
1141
|
+
const written = await runtime.rpc('env.report');
|
|
1142
|
+
store.set({ envCheck: { ...state.envCheck, open: false, reportPath: written?.path ?? null } });
|
|
1143
|
+
store.toast('success', runtime.t('env.reported', { path: written?.path ?? '' }));
|
|
1144
|
+
} catch (error) {
|
|
1145
|
+
store.toast('error', String(error?.message ?? error));
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1148
|
+
async checkAppVersion() {
|
|
1149
|
+
try {
|
|
1150
|
+
const info = await runtime.rpc('env.version');
|
|
1151
|
+
if (info?.changed === true) {
|
|
1152
|
+
store.set({ updatePrompt: { open: true, appVersion: info.appVersion, lastAppVersion: info.lastAppVersion } });
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
if (info?.appVersion !== null && info?.appVersion !== undefined) {
|
|
1156
|
+
await runtime.rpc('env.ack');
|
|
1157
|
+
}
|
|
1158
|
+
} catch {
|
|
1159
|
+
// Version probing is advisory only.
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
async acceptUpdatePrompt() {
|
|
1163
|
+
store.set({ updatePrompt: { ...state.updatePrompt, open: false } });
|
|
1164
|
+
await store.runEnvCheck();
|
|
1165
|
+
},
|
|
1166
|
+
dismissUpdatePrompt() {
|
|
1167
|
+
// No ack: the reminder returns on the next start until a check runs.
|
|
1168
|
+
store.set({ updatePrompt: { ...state.updatePrompt, open: false } });
|
|
1169
|
+
},
|
|
1170
|
+
toggleSyncLog() {
|
|
1171
|
+
const open = state.sync.showLog !== true;
|
|
1172
|
+
store.set({ sync: { ...state.sync, showLog: open, historyOpen: open ? 0 : null, historyLimit: 5 } });
|
|
1173
|
+
},
|
|
1174
|
+
showMoreHistory() {
|
|
1175
|
+
store.set({ sync: { ...state.sync, historyLimit: (Number(state.sync.historyLimit) || 5) + 50 } });
|
|
1176
|
+
},
|
|
1177
|
+
openHistory(index) {
|
|
1178
|
+
const next = state.sync.historyOpen === index ? null : index;
|
|
1179
|
+
store.set({ sync: { ...state.sync, historyOpen: next } });
|
|
1180
|
+
},
|
|
1181
|
+
async testWebdav() {
|
|
1182
|
+
if (state.sync.webdavBusy === true) return;
|
|
1183
|
+
store.set({ sync: { ...state.sync, webdavBusy: true, webdav: null } });
|
|
1184
|
+
try {
|
|
1185
|
+
const data = await runtime.rpc('sync.webdavTest');
|
|
1186
|
+
store.set({ sync: { ...state.sync, webdavBusy: false, webdav: data } });
|
|
1187
|
+
} catch (error) {
|
|
1188
|
+
store.set({ sync: { ...state.sync, webdavBusy: false, webdav: { ok: false, message: String(error?.message ?? error) } } });
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
};
|
|
1192
|
+
return store;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
const runtime = {
|
|
1196
|
+
store: null,
|
|
1197
|
+
t: (key) => key,
|
|
1198
|
+
rpc: async () => {
|
|
1199
|
+
throw new Error('DSH增强尚未初始化。');
|
|
1200
|
+
},
|
|
1201
|
+
openSession: () => {},
|
|
1202
|
+
jumpToAnchor: () => {},
|
|
1203
|
+
focusMatch: () => {},
|
|
1204
|
+
composer: null,
|
|
1205
|
+
composerDraft: '',
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
function useStore() {
|
|
1209
|
+
const store = runtime.store;
|
|
1210
|
+
return React.useSyncExternalStore(store.subscribe, store.get, store.get);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
// ── shared pieces ────────────────────────────────────────────────────────
|
|
1214
|
+
|
|
1215
|
+
function icon(name, props) {
|
|
1216
|
+
const Component = primitives?.[name];
|
|
1217
|
+
if (Component === undefined) return null;
|
|
1218
|
+
return h(Component, props ?? {});
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
function MenuRow(props) {
|
|
1222
|
+
const { danger, disabled, separatorBefore, iconName, onSelect, children } = props;
|
|
1223
|
+
if (primitives?.MenuItemButton !== undefined) {
|
|
1224
|
+
return h(primitives.MenuItemButton, {
|
|
1225
|
+
danger,
|
|
1226
|
+
disabled,
|
|
1227
|
+
separatorBefore,
|
|
1228
|
+
icon: icon(iconName ?? 'IconTrashOutlineRegular', { size: 14 }),
|
|
1229
|
+
onSelect,
|
|
1230
|
+
}, children);
|
|
1231
|
+
}
|
|
1232
|
+
return h('button', {
|
|
1233
|
+
type: 'button',
|
|
1234
|
+
role: 'menuitem',
|
|
1235
|
+
disabled,
|
|
1236
|
+
className: `dshe-match${danger === true ? ' dshe-action-danger' : ''}`,
|
|
1237
|
+
onClick: onSelect,
|
|
1238
|
+
}, children);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
function Switch(props) {
|
|
1242
|
+
return h('button', {
|
|
1243
|
+
type: 'button',
|
|
1244
|
+
role: 'switch',
|
|
1245
|
+
className: 'dshe-switch',
|
|
1246
|
+
'aria-checked': props.checked === true,
|
|
1247
|
+
'aria-label': props.label,
|
|
1248
|
+
disabled: props.disabled === true,
|
|
1249
|
+
onClick: () => props.onChange(!(props.checked === true)),
|
|
1250
|
+
}, h('span', {}));
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function formatSize(bytes) {
|
|
1254
|
+
const value = Number(bytes) || 0;
|
|
1255
|
+
if (value < 1024) return `${String(value)} B`;
|
|
1256
|
+
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`;
|
|
1257
|
+
return `${(value / (1024 * 1024)).toFixed(1)} MB`;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
function formatWhen(iso) {
|
|
1261
|
+
const time = typeof iso === 'string' ? Date.parse(iso) : Number.NaN;
|
|
1262
|
+
if (!Number.isFinite(time)) return '';
|
|
1263
|
+
return new Date(time).toLocaleString();
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
function highlight(text, query) {
|
|
1267
|
+
const needle = typeof query === 'string' ? query.trim() : '';
|
|
1268
|
+
if (needle === '') return text;
|
|
1269
|
+
const lower = text.toLowerCase();
|
|
1270
|
+
const target = needle.toLowerCase();
|
|
1271
|
+
const parts = [];
|
|
1272
|
+
let from = 0;
|
|
1273
|
+
let index = lower.indexOf(target);
|
|
1274
|
+
let key = 0;
|
|
1275
|
+
while (index >= 0) {
|
|
1276
|
+
if (index > from) parts.push(text.slice(from, index));
|
|
1277
|
+
parts.push(h('mark', { className: 'dshe-mark', key: `m${String(key)}` }, text.slice(index, index + target.length)));
|
|
1278
|
+
key += 1;
|
|
1279
|
+
from = index + target.length;
|
|
1280
|
+
index = lower.indexOf(target, from);
|
|
1281
|
+
}
|
|
1282
|
+
if (from < text.length) parts.push(text.slice(from));
|
|
1283
|
+
return parts;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// ── session menu row ─────────────────────────────────────────────────────
|
|
1287
|
+
|
|
1288
|
+
function SessionTrashRow(props) {
|
|
1289
|
+
const state = useStore();
|
|
1290
|
+
const { sessionId, useMenuOpenState } = props;
|
|
1291
|
+
const closeMenu = typeof useMenuOpenState === 'function' ? useMenuOpenState()[1] : null;
|
|
1292
|
+
if (state.settings.trashEnabled !== true) return null;
|
|
1293
|
+
return h(MenuRow, {
|
|
1294
|
+
disabled: false,
|
|
1295
|
+
separatorBefore: false,
|
|
1296
|
+
iconName: 'IconArchiveOutlineRegular',
|
|
1297
|
+
onSelect: () => {
|
|
1298
|
+
if (typeof closeMenu === 'function') closeMenu(false);
|
|
1299
|
+
runtime.store.openTrashForSession(sessionId);
|
|
1300
|
+
},
|
|
1301
|
+
}, runtime.t('trash.menu'));
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
function SessionMoveRow(props) {
|
|
1305
|
+
const state = useStore();
|
|
1306
|
+
const { sessionId, displayTitle, useMenuOpenState } = props;
|
|
1307
|
+
const closeMenu = typeof useMenuOpenState === 'function' ? useMenuOpenState()[1] : null;
|
|
1308
|
+
const statuses = typeof props.useSessionStatus === 'function' ? props.useSessionStatus((value) => value) : null;
|
|
1309
|
+
let running = false;
|
|
1310
|
+
try {
|
|
1311
|
+
running = statuses?.get?.(sessionId)?.running === true;
|
|
1312
|
+
} catch {
|
|
1313
|
+
running = false;
|
|
1314
|
+
}
|
|
1315
|
+
if (state.settings.moveEnabled !== true) return null;
|
|
1316
|
+
return h(MenuRow, {
|
|
1317
|
+
disabled: running,
|
|
1318
|
+
separatorBefore: false,
|
|
1319
|
+
iconName: 'IconFolderOpenRegular',
|
|
1320
|
+
onSelect: () => {
|
|
1321
|
+
if (typeof closeMenu === 'function') closeMenu(false);
|
|
1322
|
+
runtime.store.openMove(sessionId, displayTitle);
|
|
1323
|
+
},
|
|
1324
|
+
}, running ? runtime.t('move.running') : runtime.t('move.label'));
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function SessionDeleteRow(props) { const state = useStore();
|
|
1328
|
+
const { sessionId, displayTitle, useMenuOpenState } = props;
|
|
1329
|
+
const closeMenu = typeof useMenuOpenState === 'function' ? useMenuOpenState()[1] : null;
|
|
1330
|
+
const statuses = typeof props.useSessionStatus === 'function' ? props.useSessionStatus((value) => value) : null;
|
|
1331
|
+
let running = false;
|
|
1332
|
+
try {
|
|
1333
|
+
running = statuses?.get?.(sessionId)?.running === true;
|
|
1334
|
+
} catch {
|
|
1335
|
+
running = false;
|
|
1336
|
+
}
|
|
1337
|
+
if (state.settings.deleteEnabled !== true) return null;
|
|
1338
|
+
return h(MenuRow, {
|
|
1339
|
+
danger: true,
|
|
1340
|
+
disabled: running,
|
|
1341
|
+
separatorBefore: true,
|
|
1342
|
+
onSelect: () => {
|
|
1343
|
+
if (typeof closeMenu === 'function') closeMenu(false);
|
|
1344
|
+
runtime.store.requestDelete(sessionId, displayTitle, running);
|
|
1345
|
+
},
|
|
1346
|
+
}, running ? runtime.t('delete.running') : runtime.t('delete.label'));
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// ── delete confirmation ──────────────────────────────────────────────────
|
|
1350
|
+
|
|
1351
|
+
const displayName = (value) => {
|
|
1352
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
1353
|
+
if (text === '' || /^session-[0-9a-f-]{8,}$/iu.test(text)) return runtime.t('trash.untitled');
|
|
1354
|
+
return text;
|
|
1355
|
+
};
|
|
1356
|
+
|
|
1357
|
+
function DeleteDialog() {
|
|
1358
|
+
const state = useStore();
|
|
1359
|
+
const pending = state.pendingDelete;
|
|
1360
|
+
if (pending === null) return null;
|
|
1361
|
+
const body = h('div', { className: 'dshe-section' },
|
|
1362
|
+
h('div', { className: 'dshe-card' },
|
|
1363
|
+
h('div', { className: 'dshe-row' },
|
|
1364
|
+
h('div', { className: 'dshe-row-main' },
|
|
1365
|
+
h('div', { className: 'dshe-row-title' }, displayName(pending.title)),
|
|
1366
|
+
h('div', { className: 'dshe-row-desc' }, runtime.t('delete.desc')),
|
|
1367
|
+
),
|
|
1368
|
+
),
|
|
1369
|
+
),
|
|
1370
|
+
state.deleteError === null ? null : h('div', { className: 'dshe-status dshe-error', role: 'alert' }, state.deleteError),
|
|
1371
|
+
state.deleteBusy === true ? h('div', { className: 'dshe-status', role: 'status' }, `${runtime.t('delete.confirm')}…`) : null,
|
|
1372
|
+
);
|
|
1373
|
+
const footer = h(React.Fragment, {},
|
|
1374
|
+
h('button', { type: 'button', className: 'dshe-action', disabled: state.deleteBusy, onClick: () => runtime.store.cancelDelete() }, runtime.t('common.cancel')),
|
|
1375
|
+
h('button', {
|
|
1376
|
+
type: 'button',
|
|
1377
|
+
className: 'dshe-action dshe-action-danger',
|
|
1378
|
+
disabled: state.deleteBusy,
|
|
1379
|
+
onClick: () => runtime.store.confirmDelete(),
|
|
1380
|
+
}, runtime.t('delete.confirm')),
|
|
1381
|
+
);
|
|
1382
|
+
if (primitives?.Modal === undefined) return null;
|
|
1383
|
+
return h(primitives.Modal, {
|
|
1384
|
+
open: true,
|
|
1385
|
+
onClose: () => runtime.store.cancelDelete(),
|
|
1386
|
+
closeLabel: runtime.t('common.close'),
|
|
1387
|
+
title: runtime.t('delete.title'),
|
|
1388
|
+
footer,
|
|
1389
|
+
}, body);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// ── composer bridge ──────────────────────────────────────────────────────
|
|
1393
|
+
|
|
1394
|
+
function ComposerBridge(props) {
|
|
1395
|
+
const { inputActions, useInput } = props;
|
|
1396
|
+
const input = typeof useInput === 'function' ? useInput((value) => value) : undefined;
|
|
1397
|
+
const draft = typeof input?.draft === 'string' ? input.draft : '';
|
|
1398
|
+
React.useEffect(() => {
|
|
1399
|
+
runtime.composer = inputActions ?? null;
|
|
1400
|
+
runtime.composerDraft = draft;
|
|
1401
|
+
return () => {
|
|
1402
|
+
if (runtime.composer === inputActions) runtime.composer = null;
|
|
1403
|
+
};
|
|
1404
|
+
}, [inputActions, draft]);
|
|
1405
|
+
return null;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
// ── move dialog ──────────────────────────────────────────────────────────
|
|
1409
|
+
|
|
1410
|
+
function MoveDialog() {
|
|
1411
|
+
const state = useStore();
|
|
1412
|
+
const move = state.move;
|
|
1413
|
+
if (move.open !== true) return null;
|
|
1414
|
+
if (primitives?.Modal === undefined) return null;
|
|
1415
|
+
const body = h('div', { className: 'dshe-section' },
|
|
1416
|
+
h('div', { className: 'dshe-row-desc' }, runtime.t('move.session', { title: move.title })),
|
|
1417
|
+
move.current === null ? null : h('div', { className: 'dshe-row-desc' }, runtime.t('move.current', { title: move.current.title })),
|
|
1418
|
+
move.loading === true
|
|
1419
|
+
? h('div', { className: 'dshe-status', role: 'status' }, runtime.t('move.loading'))
|
|
1420
|
+
: move.error !== null
|
|
1421
|
+
? h('div', { className: 'dshe-status dshe-error', role: 'alert' }, runtime.t('move.failed', { message: move.error }))
|
|
1422
|
+
: move.workspaces.length === 0
|
|
1423
|
+
? h('div', { className: 'dshe-status' }, runtime.t('move.empty'))
|
|
1424
|
+
: h('div', { className: 'dshe-move-list', role: 'radiogroup', 'aria-label': runtime.t('move.target') },
|
|
1425
|
+
move.workspaces.map((workspace) => h('label', {
|
|
1426
|
+
className: 'dshe-move-item',
|
|
1427
|
+
key: workspace.id,
|
|
1428
|
+
'data-active': move.targetId === workspace.id ? 'true' : 'false',
|
|
1429
|
+
},
|
|
1430
|
+
h('input', {
|
|
1431
|
+
type: 'radio',
|
|
1432
|
+
name: 'dshe-move-target',
|
|
1433
|
+
checked: move.targetId === workspace.id,
|
|
1434
|
+
disabled: move.busy === true,
|
|
1435
|
+
onChange: () => runtime.store.setMoveTarget(workspace.id),
|
|
1436
|
+
}),
|
|
1437
|
+
h('span', { className: 'dshe-move-main' },
|
|
1438
|
+
h('span', { className: 'dshe-move-title' }, workspace.title),
|
|
1439
|
+
h('span', { className: 'dshe-move-meta' }, `${workspace.path} · ${String(workspace.sessionCount)}`),
|
|
1440
|
+
),
|
|
1441
|
+
)),
|
|
1442
|
+
),
|
|
1443
|
+
move.busy === true ? h('div', { className: 'dshe-status', role: 'status' }, runtime.t('move.busy')) : null,
|
|
1444
|
+
);
|
|
1445
|
+
const footer = h(React.Fragment, {},
|
|
1446
|
+
h('button', {
|
|
1447
|
+
type: 'button',
|
|
1448
|
+
className: 'dshe-action',
|
|
1449
|
+
disabled: move.busy === true,
|
|
1450
|
+
onClick: () => runtime.store.closeMove(),
|
|
1451
|
+
}, runtime.t('common.cancel')),
|
|
1452
|
+
h('button', {
|
|
1453
|
+
type: 'button',
|
|
1454
|
+
className: 'dshe-action dshe-action-danger',
|
|
1455
|
+
disabled: move.busy === true || move.loading === true || move.targetId === null,
|
|
1456
|
+
onClick: () => runtime.store.confirmMove(),
|
|
1457
|
+
}, runtime.t('move.confirm')),
|
|
1458
|
+
);
|
|
1459
|
+
return h(primitives.Modal, {
|
|
1460
|
+
open: true,
|
|
1461
|
+
onClose: () => runtime.store.closeMove(),
|
|
1462
|
+
closeLabel: runtime.t('common.close'),
|
|
1463
|
+
title: runtime.t('move.title'),
|
|
1464
|
+
footer,
|
|
1465
|
+
}, body);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// ── trash dialog ─────────────────────────────────────────────────────────
|
|
1469
|
+
|
|
1470
|
+
function TrashDialog() {
|
|
1471
|
+
const state = useStore();
|
|
1472
|
+
const trash = state.trash;
|
|
1473
|
+
if (trash.open !== true) return null;
|
|
1474
|
+
if (primitives?.Modal === undefined) return null;
|
|
1475
|
+
const groups = trash.groups ?? [];
|
|
1476
|
+
const body = h('div', { className: 'dshe-section' },
|
|
1477
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('trash.desc')),
|
|
1478
|
+
trash.loading === true
|
|
1479
|
+
? h('div', { className: 'dshe-status', role: 'status' }, runtime.t('trash.loading'))
|
|
1480
|
+
: trash.error !== null
|
|
1481
|
+
? h('div', { className: 'dshe-status dshe-error', role: 'alert' }, trash.error)
|
|
1482
|
+
: groups.length === 0
|
|
1483
|
+
? h('div', { className: 'dshe-status' }, runtime.t('trash.empty'))
|
|
1484
|
+
: h('div', { className: 'dshe-trash-body' }, groups.map((group) => h('div', { key: group.workspaceId },
|
|
1485
|
+
h('div', { className: 'dshe-trash-group-head' },
|
|
1486
|
+
h('span', { className: 'dshe-trash-group-title' }, group.workspaceTitle === '' || group.workspaceTitle === undefined ? '未分组' : group.workspaceTitle),
|
|
1487
|
+
trash.confirmWorkspace === group.workspaceId
|
|
1488
|
+
? h('span', { className: 'dshe-trash-group-actions' },
|
|
1489
|
+
h('button', {
|
|
1490
|
+
type: 'button',
|
|
1491
|
+
className: 'dshe-action',
|
|
1492
|
+
disabled: trash.busy !== null,
|
|
1493
|
+
onClick: () => runtime.store.patchTrashState({ confirmWorkspace: null }),
|
|
1494
|
+
}, runtime.t('common.cancel')),
|
|
1495
|
+
h('button', {
|
|
1496
|
+
type: 'button',
|
|
1497
|
+
className: 'dshe-action dshe-action-danger',
|
|
1498
|
+
disabled: trash.busy !== null,
|
|
1499
|
+
onClick: () => runtime.store.clearWorkspace(group.workspaceId),
|
|
1500
|
+
}, runtime.t('trash.clearWorkspace.confirm')),
|
|
1501
|
+
)
|
|
1502
|
+
: group.workspaceId === '_ungrouped'
|
|
1503
|
+
? null
|
|
1504
|
+
: h('button', {
|
|
1505
|
+
type: 'button',
|
|
1506
|
+
className: 'dshe-link-danger',
|
|
1507
|
+
disabled: trash.busy !== null,
|
|
1508
|
+
onClick: () => runtime.store.requestClearWorkspace(group.workspaceId),
|
|
1509
|
+
}, runtime.t('trash.clearWorkspace')),
|
|
1510
|
+
),
|
|
1511
|
+
(group.items ?? []).map((item) => {
|
|
1512
|
+
const confirming = trash.confirmPurge === item.sessionId;
|
|
1513
|
+
return h('div', { className: 'dshe-trash-row', key: item.sessionId },
|
|
1514
|
+
h('div', { className: 'dshe-trash-main' },
|
|
1515
|
+
h('div', { className: 'dshe-trash-title', title: displayName(item.title) }, displayName(item.title)),
|
|
1516
|
+
h('div', { className: 'dshe-trash-id', title: item.sessionId }, item.sessionId),
|
|
1517
|
+
h('div', { className: 'dshe-trash-meta' }, `${formatWhen(item.deletedAt)} · ${formatSize(item.sizeBytes)}`),
|
|
1518
|
+
),
|
|
1519
|
+
confirming
|
|
1520
|
+
? h(React.Fragment, {},
|
|
1521
|
+
h('button', {
|
|
1522
|
+
type: 'button',
|
|
1523
|
+
className: 'dshe-action',
|
|
1524
|
+
disabled: trash.busy !== null,
|
|
1525
|
+
onClick: () => runtime.store.patchTrashState({ confirmPurge: null }),
|
|
1526
|
+
}, runtime.t('common.cancel')),
|
|
1527
|
+
h('button', {
|
|
1528
|
+
type: 'button',
|
|
1529
|
+
className: 'dshe-action dshe-action-danger',
|
|
1530
|
+
disabled: trash.busy !== null,
|
|
1531
|
+
onClick: () => runtime.store.purge(item.sessionId, item.title),
|
|
1532
|
+
}, runtime.t('trash.purge.confirm')),
|
|
1533
|
+
)
|
|
1534
|
+
: h(React.Fragment, {},
|
|
1535
|
+
h('button', {
|
|
1536
|
+
type: 'button',
|
|
1537
|
+
className: 'dshe-action',
|
|
1538
|
+
disabled: trash.busy !== null,
|
|
1539
|
+
onClick: () => runtime.store.restore(item.sessionId, item.title),
|
|
1540
|
+
}, runtime.t('trash.restore')),
|
|
1541
|
+
h('button', {
|
|
1542
|
+
type: 'button',
|
|
1543
|
+
className: 'dshe-action dshe-action-danger',
|
|
1544
|
+
disabled: trash.busy !== null,
|
|
1545
|
+
onClick: () => runtime.store.requestPurge(item.sessionId),
|
|
1546
|
+
}, runtime.t('trash.purge')),
|
|
1547
|
+
),
|
|
1548
|
+
);
|
|
1549
|
+
}),
|
|
1550
|
+
))),
|
|
1551
|
+
);
|
|
1552
|
+
const footer = h(React.Fragment, {},
|
|
1553
|
+
trash.confirmClear === true
|
|
1554
|
+
? h(React.Fragment, {},
|
|
1555
|
+
h('button', {
|
|
1556
|
+
type: 'button',
|
|
1557
|
+
className: 'dshe-action',
|
|
1558
|
+
disabled: trash.busy !== null,
|
|
1559
|
+
onClick: () => runtime.store.patchTrashState({ confirmClear: false }),
|
|
1560
|
+
}, runtime.t('common.cancel')),
|
|
1561
|
+
h('button', {
|
|
1562
|
+
type: 'button',
|
|
1563
|
+
className: 'dshe-action dshe-action-danger',
|
|
1564
|
+
disabled: trash.busy !== null,
|
|
1565
|
+
onClick: () => runtime.store.clearTrash(),
|
|
1566
|
+
}, runtime.t('trash.clear.confirm')),
|
|
1567
|
+
)
|
|
1568
|
+
: h('button', {
|
|
1569
|
+
type: 'button',
|
|
1570
|
+
className: 'dshe-action dshe-action-danger',
|
|
1571
|
+
disabled: trash.busy !== null || trash.count === 0 || trash.scopeSession !== null,
|
|
1572
|
+
onClick: () => runtime.store.requestClear(),
|
|
1573
|
+
style: trash.scopeSession === null ? undefined : { display: 'none' },
|
|
1574
|
+
}, runtime.t('trash.clear')),
|
|
1575
|
+
h('button', {
|
|
1576
|
+
type: 'button',
|
|
1577
|
+
className: 'dshe-action',
|
|
1578
|
+
disabled: trash.busy !== null,
|
|
1579
|
+
onClick: () => runtime.store.closeTrash(),
|
|
1580
|
+
}, runtime.t('common.close')),
|
|
1581
|
+
);
|
|
1582
|
+
return h(primitives.Modal, {
|
|
1583
|
+
open: true,
|
|
1584
|
+
onClose: () => runtime.store.closeTrash(),
|
|
1585
|
+
closeLabel: runtime.t('common.close'),
|
|
1586
|
+
title: runtime.t('trash.title'),
|
|
1587
|
+
footer,
|
|
1588
|
+
}, body);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// ── search overlay ───────────────────────────────────────────────────────
|
|
1592
|
+
|
|
1593
|
+
/** Height of the shell's caption strip, which the page must not cover. */
|
|
1594
|
+
function captionHeight() {
|
|
1595
|
+
let bottom = 0;
|
|
1596
|
+
let nodes = [];
|
|
1597
|
+
try {
|
|
1598
|
+
nodes = Array.from(document.querySelectorAll('*'));
|
|
1599
|
+
} catch {
|
|
1600
|
+
return 0;
|
|
1601
|
+
}
|
|
1602
|
+
for (const node of nodes) {
|
|
1603
|
+
let style;
|
|
1604
|
+
try {
|
|
1605
|
+
style = window.getComputedStyle(node);
|
|
1606
|
+
} catch {
|
|
1607
|
+
continue;
|
|
1608
|
+
}
|
|
1609
|
+
if (style.webkitAppRegion !== 'drag') continue;
|
|
1610
|
+
const rect = node.getBoundingClientRect();
|
|
1611
|
+
if (rect.top > 80) continue;
|
|
1612
|
+
if (rect.bottom > bottom) bottom = rect.bottom;
|
|
1613
|
+
}
|
|
1614
|
+
return Math.max(0, Math.round(bottom));
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
function SearchOverlay() {
|
|
1618
|
+
const state = useStore();
|
|
1619
|
+
const search = state.search;
|
|
1620
|
+
const inputRef = React.useRef(null);
|
|
1621
|
+
const resultsRef = React.useRef(null);
|
|
1622
|
+
const [active, setActive] = React.useState(0);
|
|
1623
|
+
|
|
1624
|
+
React.useEffect(() => {
|
|
1625
|
+
if (search.open !== true) return undefined;
|
|
1626
|
+
const focus = () => {
|
|
1627
|
+
const node = inputRef.current;
|
|
1628
|
+
if (node !== null) {
|
|
1629
|
+
node.focus();
|
|
1630
|
+
node.select();
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
focus();
|
|
1634
|
+
const timer = setTimeout(focus, 0);
|
|
1635
|
+
return () => clearTimeout(timer);
|
|
1636
|
+
}, [search.open]);
|
|
1637
|
+
|
|
1638
|
+
React.useEffect(() => {
|
|
1639
|
+
if (search.open !== true) return undefined;
|
|
1640
|
+
const onKeyDown = (event) => {
|
|
1641
|
+
if (event.key !== 'Escape') return;
|
|
1642
|
+
event.preventDefault();
|
|
1643
|
+
event.stopPropagation();
|
|
1644
|
+
runtime.store.closeSearch();
|
|
1645
|
+
};
|
|
1646
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
1647
|
+
return () => window.removeEventListener('keydown', onKeyDown, true);
|
|
1648
|
+
}, [search.open]);
|
|
1649
|
+
|
|
1650
|
+
const flat = React.useMemo(() => {
|
|
1651
|
+
const rows = [];
|
|
1652
|
+
for (const group of search.groups ?? []) {
|
|
1653
|
+
for (const match of group.matches ?? []) rows.push({ group, match });
|
|
1654
|
+
}
|
|
1655
|
+
return rows;
|
|
1656
|
+
}, [search.groups]);
|
|
1657
|
+
|
|
1658
|
+
const offsets = React.useMemo(() => {
|
|
1659
|
+
const map = new Map();
|
|
1660
|
+
let cursor = 0;
|
|
1661
|
+
for (const group of search.groups ?? []) {
|
|
1662
|
+
map.set(group.sessionId, cursor);
|
|
1663
|
+
cursor += (group.matches ?? []).length;
|
|
1664
|
+
}
|
|
1665
|
+
return map;
|
|
1666
|
+
}, [search.groups]);
|
|
1667
|
+
|
|
1668
|
+
React.useEffect(() => {
|
|
1669
|
+
setActive(0);
|
|
1670
|
+
}, [search.groups]);
|
|
1671
|
+
|
|
1672
|
+
React.useEffect(() => {
|
|
1673
|
+
if (active >= flat.length) setActive(flat.length === 0 ? 0 : flat.length - 1);
|
|
1674
|
+
}, [flat.length, active]);
|
|
1675
|
+
|
|
1676
|
+
React.useEffect(() => {
|
|
1677
|
+
const node = resultsRef.current?.querySelector('.dshe-match[data-active="true"]');
|
|
1678
|
+
if (node !== null && node !== undefined && typeof node.scrollIntoView === 'function') {
|
|
1679
|
+
node.scrollIntoView({ block: 'nearest' });
|
|
1680
|
+
}
|
|
1681
|
+
}, [active, search.groups]);
|
|
1682
|
+
|
|
1683
|
+
if (search.open !== true) return null;
|
|
1684
|
+
|
|
1685
|
+
const open = (sessionId, match) => {
|
|
1686
|
+
const query = search.query;
|
|
1687
|
+
runtime.store.closeSearch();
|
|
1688
|
+
runtime.openSession(sessionId);
|
|
1689
|
+
runtime.focusMatch(sessionId, match, query);
|
|
1690
|
+
};
|
|
1691
|
+
|
|
1692
|
+
const onKeyDown = (event) => {
|
|
1693
|
+
if (event.key === 'Escape') {
|
|
1694
|
+
event.preventDefault();
|
|
1695
|
+
runtime.store.closeSearch();
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
1699
|
+
if (flat.length === 0) return;
|
|
1700
|
+
event.preventDefault();
|
|
1701
|
+
const delta = event.key === 'ArrowDown' ? 1 : -1;
|
|
1702
|
+
setActive((current) => (current + delta + flat.length) % flat.length);
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
if (event.key === 'Enter') {
|
|
1706
|
+
const row = flat[active];
|
|
1707
|
+
if (row === undefined) return;
|
|
1708
|
+
event.preventDefault();
|
|
1709
|
+
open(row.group.sessionId, row.match);
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
const totalMatches = flat.length;
|
|
1714
|
+
const meta = search.status === 'done'
|
|
1715
|
+
? runtime.t('search.meta', { count: (search.groups ?? []).length, matches: totalMatches })
|
|
1716
|
+
: '';
|
|
1717
|
+
|
|
1718
|
+
const panel = h('div', { className: 'dshe-overlay dshe-overlay-top', role: 'presentation', style: { top: `${String(captionHeight())}px` } },
|
|
1719
|
+
h('div', { className: 'dshe-backdrop', 'aria-hidden': 'true', onClick: () => runtime.store.closeSearch() }),
|
|
1720
|
+
h('div', {
|
|
1721
|
+
className: 'dshe-search',
|
|
1722
|
+
role: 'dialog',
|
|
1723
|
+
'aria-modal': 'true',
|
|
1724
|
+
'aria-label': runtime.t('search.placeholder'),
|
|
1725
|
+
onKeyDown,
|
|
1726
|
+
},
|
|
1727
|
+
h('div', { className: 'dshe-search-head' },
|
|
1728
|
+
h('span', { className: 'dshe-search-icon' }, icon('IconSearchOutlineRegular', { size: 16 })),
|
|
1729
|
+
h('input', {
|
|
1730
|
+
ref: inputRef,
|
|
1731
|
+
className: 'dshe-search-input',
|
|
1732
|
+
type: 'text',
|
|
1733
|
+
value: search.query,
|
|
1734
|
+
placeholder: runtime.t('search.placeholder'),
|
|
1735
|
+
'aria-label': runtime.t('search.placeholder'),
|
|
1736
|
+
onChange: (event) => runtime.store.setQuery(event.target.value),
|
|
1737
|
+
}),
|
|
1738
|
+
h('span', { className: 'dshe-group-meta' }, meta),
|
|
1739
|
+
h('button', {
|
|
1740
|
+
type: 'button',
|
|
1741
|
+
className: 'dshe-action',
|
|
1742
|
+
onClick: () => runtime.store.closeSearch(),
|
|
1743
|
+
}, runtime.t('common.close')),
|
|
1744
|
+
),
|
|
1745
|
+
h('div', { className: 'dshe-results', ref: resultsRef },
|
|
1746
|
+
search.status === 'loading' ? h('div', { className: 'dshe-status', role: 'status' }, runtime.t('search.loading')) : null,
|
|
1747
|
+
search.status === 'error' ? h('div', { className: 'dshe-status dshe-error', role: 'alert' }, runtime.t('search.error', { message: search.error })) : null,
|
|
1748
|
+
search.status === 'idle' ? h('div', { className: 'dshe-status' }, runtime.t('search.hint')) : null,
|
|
1749
|
+
search.status === 'done' && totalMatches === 0 ? h('div', { className: 'dshe-status' }, runtime.t('search.empty')) : null,
|
|
1750
|
+
search.status === 'done'
|
|
1751
|
+
? (search.groups ?? []).map((group) => h('div', { className: 'dshe-group', key: group.sessionId },
|
|
1752
|
+
h('button', {
|
|
1753
|
+
type: 'button',
|
|
1754
|
+
className: 'dshe-group-title',
|
|
1755
|
+
title: group.title,
|
|
1756
|
+
onClick: () => open(group.sessionId),
|
|
1757
|
+
}, group.title, h('span', { className: 'dshe-group-meta' }, (group.matches ?? []).length + '')),
|
|
1758
|
+
(group.matches ?? []).map((match, index) => {
|
|
1759
|
+
const rowIndex = (offsets.get(group.sessionId) ?? 0) + index;
|
|
1760
|
+
return h('button', {
|
|
1761
|
+
type: 'button',
|
|
1762
|
+
className: 'dshe-match',
|
|
1763
|
+
key: `${group.sessionId}-${String(match.seq ?? 'title')}-${String(index)}`,
|
|
1764
|
+
'data-active': rowIndex === active ? 'true' : 'false',
|
|
1765
|
+
onClick: () => open(group.sessionId, match),
|
|
1766
|
+
},
|
|
1767
|
+
h('span', { className: 'dshe-role' }, runtime.t(`role.${match.role ?? 'body'}`)),
|
|
1768
|
+
h('span', { className: 'dshe-snippet' }, highlight(match.snippet ?? '', search.query)),
|
|
1769
|
+
);
|
|
1770
|
+
}),
|
|
1771
|
+
))
|
|
1772
|
+
: null,
|
|
1773
|
+
),
|
|
1774
|
+
),
|
|
1775
|
+
);
|
|
1776
|
+
return panel;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
// ── settings section ─────────────────────────────────────────────────────
|
|
1780
|
+
|
|
1781
|
+
function NumberField(props) {
|
|
1782
|
+
const [draft, setDraft] = React.useState(String(props.value));
|
|
1783
|
+
React.useEffect(() => setDraft(String(props.value)), [props.value]);
|
|
1784
|
+
const commit = () => {
|
|
1785
|
+
const parsed = Number.parseInt(draft, 10);
|
|
1786
|
+
if (!Number.isFinite(parsed)) {
|
|
1787
|
+
setDraft(String(props.value));
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
const clamped = Math.min(props.max, Math.max(props.min, parsed));
|
|
1791
|
+
setDraft(String(clamped));
|
|
1792
|
+
if (clamped !== props.value) props.onChange(clamped);
|
|
1793
|
+
};
|
|
1794
|
+
return h('input', {
|
|
1795
|
+
className: 'dshe-number',
|
|
1796
|
+
type: 'number',
|
|
1797
|
+
min: props.min,
|
|
1798
|
+
max: props.max,
|
|
1799
|
+
value: draft,
|
|
1800
|
+
'aria-label': props.label,
|
|
1801
|
+
onChange: (event) => setDraft(event.target.value),
|
|
1802
|
+
onBlur: commit,
|
|
1803
|
+
onKeyDown: (event) => {
|
|
1804
|
+
if (event.key === 'Enter') {
|
|
1805
|
+
event.preventDefault();
|
|
1806
|
+
commit();
|
|
1807
|
+
}
|
|
1808
|
+
},
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
function TextField(props) {
|
|
1813
|
+
const [draft, setDraft] = React.useState(props.value ?? '');
|
|
1814
|
+
React.useEffect(() => setDraft(props.value ?? ''), [props.value]);
|
|
1815
|
+
const commit = () => {
|
|
1816
|
+
const next = draft.trim();
|
|
1817
|
+
if (next !== (props.value ?? '')) props.onChange(next);
|
|
1818
|
+
};
|
|
1819
|
+
return h('input', {
|
|
1820
|
+
className: 'dshe-text',
|
|
1821
|
+
type: props.type ?? 'text',
|
|
1822
|
+
value: draft,
|
|
1823
|
+
placeholder: props.placeholder ?? '',
|
|
1824
|
+
'aria-label': props.label ?? props.title,
|
|
1825
|
+
onChange: (event) => setDraft(event.target.value),
|
|
1826
|
+
onBlur: commit,
|
|
1827
|
+
onKeyDown: (event) => {
|
|
1828
|
+
if (event.key === 'Enter') {
|
|
1829
|
+
event.preventDefault();
|
|
1830
|
+
commit();
|
|
1831
|
+
}
|
|
1832
|
+
},
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
function Row(props) {
|
|
1837
|
+
return h('div', { className: 'dshe-row' },
|
|
1838
|
+
h('div', { className: 'dshe-row-main' },
|
|
1839
|
+
h('div', { className: 'dshe-row-title' }, props.title),
|
|
1840
|
+
props.desc === undefined ? null : h('div', { className: 'dshe-row-desc' }, props.desc),
|
|
1841
|
+
),
|
|
1842
|
+
props.control,
|
|
1843
|
+
);
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
function SettingsSection() {
|
|
1847
|
+
const state = useStore();
|
|
1848
|
+
const settings = state.settings;
|
|
1849
|
+
const set = (patch) => runtime.store.saveSettings(patch);
|
|
1850
|
+
const presets = Array.isArray(settings.webdavProfiles) ? settings.webdavProfiles : [];
|
|
1851
|
+
const trimTail = (value) => String(value ?? '').trim().replace(/[\\/]+$/u, '');
|
|
1852
|
+
const currentFields = {
|
|
1853
|
+
url: settings.webdavUrl ?? '',
|
|
1854
|
+
user: settings.webdavUser ?? '',
|
|
1855
|
+
password: settings.webdavPassword ?? '',
|
|
1856
|
+
root: settings.webdavRoot ?? '',
|
|
1857
|
+
};
|
|
1858
|
+
const sameFields = (a, b) => trimTail(a.url) === trimTail(b.url)
|
|
1859
|
+
&& String(a.user ?? '').trim() === String(b.user ?? '').trim()
|
|
1860
|
+
&& String(a.password ?? '') === String(b.password ?? '')
|
|
1861
|
+
&& trimTail(a.root) === trimTail(b.root);
|
|
1862
|
+
const activePreset = presets.find((item) => sameFields(item, currentFields)) ?? null;
|
|
1863
|
+
const canSavePreset = trimTail(currentFields.url) !== ''
|
|
1864
|
+
&& presets.every((item) => sameFields(item, currentFields) === false);
|
|
1865
|
+
const applyPreset = (item) => {
|
|
1866
|
+
runtime.store.cancelPresetEdit();
|
|
1867
|
+
set({ webdavUrl: item.url, webdavUser: item.user, webdavPassword: item.password, webdavRoot: item.root });
|
|
1868
|
+
};
|
|
1869
|
+
const syncDirValue = typeof settings.syncDir === 'string' ? settings.syncDir : '';
|
|
1870
|
+
const webdavUrlValue = typeof settings.webdavUrl === 'string' ? settings.webdavUrl : '';
|
|
1871
|
+
const effectiveDir = settings.syncMode === 'webdav'
|
|
1872
|
+
? (typeof settings.mirrorDir === 'string' ? settings.mirrorDir : '')
|
|
1873
|
+
: syncDirValue;
|
|
1874
|
+
React.useEffect(() => {
|
|
1875
|
+
runtime.store.refreshCount();
|
|
1876
|
+
runtime.store.loadSync();
|
|
1877
|
+
}, []);
|
|
1878
|
+
return h('div', { className: 'dshe-section' },
|
|
1879
|
+
h('h2', { className: 'dshe-section-title' }, runtime.t('section.title')),
|
|
1880
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('section.desc')),
|
|
1881
|
+
|
|
1882
|
+
h('h3', { className: 'dshe-subsection-title' }, runtime.t('section.reading')),
|
|
1883
|
+
h('div', { className: 'dshe-card' },
|
|
1884
|
+
h(Row, {
|
|
1885
|
+
title: runtime.t('switch.autoLoad'),
|
|
1886
|
+
desc: runtime.t('switch.autoLoad.desc'),
|
|
1887
|
+
control: h(Switch, { label: runtime.t('switch.autoLoad'), checked: settings.autoLoadEnabled, onChange: (value) => set({ autoLoadEnabled: value }) }),
|
|
1888
|
+
}),
|
|
1889
|
+
h(Row, {
|
|
1890
|
+
title: runtime.t('switch.move'),
|
|
1891
|
+
desc: runtime.t('switch.move.desc'),
|
|
1892
|
+
control: h(Switch, { label: runtime.t('switch.move'), checked: settings.moveEnabled, onChange: (value) => set({ moveEnabled: value }) }),
|
|
1893
|
+
}),
|
|
1894
|
+
),
|
|
1895
|
+
|
|
1896
|
+
h('h3', { className: 'dshe-subsection-title' }, runtime.t('section.sessions')),
|
|
1897
|
+
h('div', { className: 'dshe-card' },
|
|
1898
|
+
h(Row, {
|
|
1899
|
+
title: runtime.t('switch.delete'),
|
|
1900
|
+
desc: runtime.t('switch.delete.desc'),
|
|
1901
|
+
control: h(Switch, { label: runtime.t('switch.delete'), checked: settings.deleteEnabled, onChange: (value) => set({ deleteEnabled: value }) }),
|
|
1902
|
+
}),
|
|
1903
|
+
h(Row, {
|
|
1904
|
+
title: runtime.t('switch.trash'),
|
|
1905
|
+
desc: runtime.t('switch.trash.desc'),
|
|
1906
|
+
control: h(Switch, { label: runtime.t('switch.trash'), checked: settings.trashEnabled, onChange: (value) => set({ trashEnabled: value }) }),
|
|
1907
|
+
}),
|
|
1908
|
+
),
|
|
1909
|
+
h('div', { className: 'dshe-card' },
|
|
1910
|
+
h(Row, {
|
|
1911
|
+
title: runtime.t('field.retention'),
|
|
1912
|
+
desc: runtime.t('field.retention.hint'),
|
|
1913
|
+
control: h(NumberField, { label: runtime.t('field.retention'), value: settings.retentionDays, min: 0, max: 3650, onChange: (value) => set({ retentionDays: value }) }),
|
|
1914
|
+
}),
|
|
1915
|
+
),
|
|
1916
|
+
h('div', { className: 'dshe-section' },
|
|
1917
|
+
settings.trashEnabled === true
|
|
1918
|
+
? h('button', {
|
|
1919
|
+
type: 'button',
|
|
1920
|
+
className: 'dshe-action',
|
|
1921
|
+
onClick: () => runtime.store.openTrash(),
|
|
1922
|
+
}, h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '6px' } },
|
|
1923
|
+
icon('IconArchiveOutlineRegular', { size: 14 }),
|
|
1924
|
+
runtime.t('trash.title'),
|
|
1925
|
+
))
|
|
1926
|
+
: null,
|
|
1927
|
+
h('div', { className: 'dshe-row-desc' }, runtime.t('trash.usage', { count: state.trash.count, size: formatSize(state.trash.size) })),
|
|
1928
|
+
),
|
|
1929
|
+
|
|
1930
|
+
h('h3', { className: 'dshe-subsection-title' }, runtime.t('section.search')),
|
|
1931
|
+
h('div', { className: 'dshe-card' },
|
|
1932
|
+
h(Row, {
|
|
1933
|
+
title: runtime.t('switch.search'),
|
|
1934
|
+
desc: runtime.t('switch.search.desc'),
|
|
1935
|
+
control: h(Switch, { label: runtime.t('switch.search'), checked: settings.searchEnabled, onChange: (value) => set({ searchEnabled: value }) }),
|
|
1936
|
+
}),
|
|
1937
|
+
),
|
|
1938
|
+
h('div', { className: 'dshe-card' },
|
|
1939
|
+
h(Row, {
|
|
1940
|
+
title: runtime.t('switch.matchTitle'),
|
|
1941
|
+
control: h(Switch, { label: runtime.t('switch.matchTitle'), checked: settings.matchTitle, onChange: (value) => set({ matchTitle: value }) }),
|
|
1942
|
+
}),
|
|
1943
|
+
h(Row, {
|
|
1944
|
+
title: runtime.t('switch.matchBody'),
|
|
1945
|
+
control: h(Switch, { label: runtime.t('switch.matchBody'), checked: settings.matchBody, onChange: (value) => set({ matchBody: value }) }),
|
|
1946
|
+
}),
|
|
1947
|
+
h(Row, {
|
|
1948
|
+
title: runtime.t('switch.matchTools'),
|
|
1949
|
+
control: h(Switch, { label: runtime.t('switch.matchTools'), checked: settings.matchTools, onChange: (value) => set({ matchTools: value }) }),
|
|
1950
|
+
}),
|
|
1951
|
+
|
|
1952
|
+
),
|
|
1953
|
+
|
|
1954
|
+
h('h3', { className: 'dshe-subsection-title' }, runtime.t('section.sync')),
|
|
1955
|
+
h('div', { className: 'dshe-card' },
|
|
1956
|
+
h(Row, {
|
|
1957
|
+
title: runtime.t('sync.enable'),
|
|
1958
|
+
desc: runtime.t('sync.enable.hint'),
|
|
1959
|
+
control: h(Switch, { label: runtime.t('sync.enable'), checked: settings.syncEnabled, onChange: (value) => set({ syncEnabled: value }) }),
|
|
1960
|
+
}),
|
|
1961
|
+
h(Row, {
|
|
1962
|
+
title: runtime.t('sync.mode'),
|
|
1963
|
+
control: h('span', { style: { display: 'inline-flex', gap: '6px' } },
|
|
1964
|
+
h('button', {
|
|
1965
|
+
type: 'button',
|
|
1966
|
+
className: `dshe-action${settings.syncMode === 'webdav' ? ' dshe-action-active' : ''}`,
|
|
1967
|
+
onClick: () => set({ syncMode: 'webdav' }),
|
|
1968
|
+
}, runtime.t('sync.mode.webdav')),
|
|
1969
|
+
h('button', {
|
|
1970
|
+
type: 'button',
|
|
1971
|
+
className: `dshe-action${settings.syncMode === 'webdav' ? '' : ' dshe-action-active'}`,
|
|
1972
|
+
onClick: () => set({ syncMode: 'local' }),
|
|
1973
|
+
}, runtime.t('sync.mode.local')),
|
|
1974
|
+
),
|
|
1975
|
+
}),
|
|
1976
|
+
settings.syncMode === 'webdav'
|
|
1977
|
+
? h(React.Fragment, {},
|
|
1978
|
+
h('div', { className: 'dshe-presets' },
|
|
1979
|
+
h('div', { className: 'dshe-presets-head' }, runtime.t('sync.webdav.presets')),
|
|
1980
|
+
h('div', { className: 'dshe-presets-chips' },
|
|
1981
|
+
h('select', {
|
|
1982
|
+
className: 'dshe-select',
|
|
1983
|
+
value: activePreset === null ? '' : activePreset.id,
|
|
1984
|
+
onChange: (event) => {
|
|
1985
|
+
const picked = presets.find((item) => item.id === event.target.value);
|
|
1986
|
+
if (picked !== undefined) applyPreset(picked);
|
|
1987
|
+
},
|
|
1988
|
+
},
|
|
1989
|
+
activePreset === null ? h('option', { value: '' }, runtime.t('sync.webdav.presets.default')) : null,
|
|
1990
|
+
presets.map((item) => h('option', { key: item.id, value: item.id }, item.name)),
|
|
1991
|
+
),
|
|
1992
|
+
state.presetEdit !== null && state.presetEdit.mode === 'modify'
|
|
1993
|
+
? h(React.Fragment, null,
|
|
1994
|
+
h('button', { key: 'commit', type: 'button', className: 'dshe-action dshe-action-active', onClick: () => runtime.store.commitPresetModify() }, runtime.t('sync.webdav.presets.commitModify')),
|
|
1995
|
+
h('button', { key: 'cancel', type: 'button', className: 'dshe-action', onClick: () => runtime.store.cancelPresetEdit() }, runtime.t('common.cancel')),
|
|
1996
|
+
)
|
|
1997
|
+
: state.presetEdit === null
|
|
1998
|
+
? h(React.Fragment, null,
|
|
1999
|
+
h('button', { key: 'rename', type: 'button', className: 'dshe-action', disabled: activePreset === null, onClick: () => runtime.store.startPresetRename() }, runtime.t('sync.webdav.presets.rename')),
|
|
2000
|
+
h('button', { key: 'modify', type: 'button', className: 'dshe-action', disabled: activePreset === null, onClick: () => runtime.store.startPresetModify() }, runtime.t('sync.webdav.presets.modify')),
|
|
2001
|
+
h('button', { key: 'remove', type: 'button', className: 'dshe-action dshe-action-danger', disabled: activePreset === null, onClick: () => runtime.store.dropActivePreset() }, runtime.t('sync.webdav.presets.remove')),
|
|
2002
|
+
h('button', { key: 'save', type: 'button', className: 'dshe-action dshe-action-active', disabled: canSavePreset === false, onClick: () => runtime.store.startPresetSave() }, runtime.t('sync.webdav.presets.save')),
|
|
2003
|
+
)
|
|
2004
|
+
: h(React.Fragment, null,
|
|
2005
|
+
h(TextField, { key: 'name', title: runtime.t('sync.webdav.presets.name'), value: state.presetEdit.name, onChange: (value) => runtime.store.setPresetName(value) }),
|
|
2006
|
+
h('button', { key: 'ok', type: 'button', className: 'dshe-action dshe-action-active', onClick: () => runtime.store.commitPresetEdit() }, '✓'),
|
|
2007
|
+
h('button', { key: 'cancel', type: 'button', className: 'dshe-action', onClick: () => runtime.store.cancelPresetEdit() }, '×'),
|
|
2008
|
+
),
|
|
2009
|
+
),
|
|
2010
|
+
),
|
|
2011
|
+
h(Row, {
|
|
2012
|
+
title: runtime.t('sync.webdav.url'),
|
|
2013
|
+
control: h(TextField, { title: runtime.t('sync.webdav.url'), value: webdavUrlValue, placeholder: 'https://dav.jianguoyun.com/dav/', onChange: (value) => set({ webdavUrl: value }) }),
|
|
2014
|
+
}),
|
|
2015
|
+
h(Row, {
|
|
2016
|
+
title: runtime.t('sync.webdav.user'),
|
|
2017
|
+
control: h(TextField, { title: runtime.t('sync.webdav.user'), value: settings.webdavUser, placeholder: 'user@example.com', onChange: (value) => set({ webdavUser: value }) }),
|
|
2018
|
+
}),
|
|
2019
|
+
h(Row, {
|
|
2020
|
+
title: runtime.t('sync.webdav.password'),
|
|
2021
|
+
desc: runtime.t('sync.webdav.password.hint'),
|
|
2022
|
+
control: h(TextField, { title: runtime.t('sync.webdav.password'), type: 'password', value: settings.webdavPassword, onChange: (value) => set({ webdavPassword: value }) }),
|
|
2023
|
+
}),
|
|
2024
|
+
h(Row, {
|
|
2025
|
+
title: runtime.t('sync.webdav.root'),
|
|
2026
|
+
desc: runtime.t('sync.webdav.root.hint'),
|
|
2027
|
+
control: h(TextField, { title: runtime.t('sync.webdav.root'), value: settings.webdavRoot, placeholder: '/我的坚果云/DSH-Sync', onChange: (value) => set({ webdavRoot: value }) }),
|
|
2028
|
+
}),
|
|
2029
|
+
h(Row, {
|
|
2030
|
+
title: runtime.t('sync.webdav.mirror'),
|
|
2031
|
+
desc: state.sync.target !== null && state.sync.target.usage !== null && state.sync.target.usage !== undefined
|
|
2032
|
+
? runtime.t('sync.webdav.mirror.usage', { size: formatSize(state.sync.target.usage.bytes), files: state.sync.target.usage.files })
|
|
2033
|
+
: undefined,
|
|
2034
|
+
control: h(TextField, { title: runtime.t('sync.webdav.mirror'), value: settings.mirrorDir, onChange: (value) => set({ mirrorDir: value }) }),
|
|
2035
|
+
}),
|
|
2036
|
+
h(Row, {
|
|
2037
|
+
title: runtime.t('sync.webdav.autoCreate'),
|
|
2038
|
+
desc: runtime.t('sync.webdav.autoCreate.desc'),
|
|
2039
|
+
control: h(Switch, { label: runtime.t('sync.webdav.autoCreate'), checked: settings.webdavAutoCreate, onChange: (value) => set({ webdavAutoCreate: value }) }),
|
|
2040
|
+
}),
|
|
2041
|
+
h(Row, {
|
|
2042
|
+
title: runtime.t('sync.webdav.test'),
|
|
2043
|
+
desc: state.sync.webdav === null
|
|
2044
|
+
? undefined
|
|
2045
|
+
: (state.sync.webdav.ok === true
|
|
2046
|
+
? runtime.t('sync.webdav.ok', { message: state.sync.webdav.message })
|
|
2047
|
+
: runtime.t('sync.webdav.fail', { message: state.sync.webdav.message })),
|
|
2048
|
+
control: h('button', {
|
|
2049
|
+
type: 'button',
|
|
2050
|
+
className: 'dshe-action',
|
|
2051
|
+
disabled: state.sync.webdavBusy === true,
|
|
2052
|
+
onClick: () => runtime.store.testWebdav(),
|
|
2053
|
+
}, state.sync.webdavBusy === true ? runtime.t('sync.webdav.testing') : runtime.t('sync.webdav.test')),
|
|
2054
|
+
}),
|
|
2055
|
+
)
|
|
2056
|
+
: h(Row, {
|
|
2057
|
+
title: runtime.t('sync.dir'),
|
|
2058
|
+
control: h(TextField, { title: runtime.t('sync.dir'), value: syncDirValue, placeholder: 'D:\\Synced\\DSH', onChange: (value) => set({ syncDir: value }) }),
|
|
2059
|
+
}),
|
|
2060
|
+
h(Row, {
|
|
2061
|
+
title: runtime.t('sync.machine'),
|
|
2062
|
+
desc: runtime.t('sync.machine.hint'),
|
|
2063
|
+
control: h(TextField, {
|
|
2064
|
+
title: runtime.t('sync.machine'),
|
|
2065
|
+
value: settings.syncMachineId,
|
|
2066
|
+
placeholder: state.sync.target === null || state.sync.target.machineId === undefined
|
|
2067
|
+
? ''
|
|
2068
|
+
: runtime.t('sync.machine.placeholder', { id: state.sync.target.machineId }),
|
|
2069
|
+
onChange: (value) => set({ syncMachineId: value }),
|
|
2070
|
+
}),
|
|
2071
|
+
}),
|
|
2072
|
+
h(Row, {
|
|
2073
|
+
title: runtime.t('sync.attachments'),
|
|
2074
|
+
control: h(Switch, { label: runtime.t('sync.attachments'), checked: settings.syncSkipAttachments !== true, onChange: (value) => set({ syncSkipAttachments: !value }) }),
|
|
2075
|
+
}),
|
|
2076
|
+
h(Row, {
|
|
2077
|
+
title: runtime.t('sync.idle'),
|
|
2078
|
+
desc: runtime.t('sync.idle.desc'),
|
|
2079
|
+
control: h(Switch, { label: runtime.t('sync.idle'), checked: settings.syncOnIdle, onChange: (value) => set({ syncOnIdle: value }) }),
|
|
2080
|
+
}),
|
|
2081
|
+
h(Row, {
|
|
2082
|
+
title: runtime.t('sync.interval'),
|
|
2083
|
+
desc: runtime.t('sync.interval.hint'),
|
|
2084
|
+
control: h(NumberField, { label: runtime.t('sync.interval'), value: settings.syncIntervalMinutes, min: 0, max: 1440, onChange: (value) => set({ syncIntervalMinutes: value }) }),
|
|
2085
|
+
}),
|
|
2086
|
+
h(Row, {
|
|
2087
|
+
title: runtime.t('sync.daily'),
|
|
2088
|
+
desc: runtime.t('sync.daily.hint'),
|
|
2089
|
+
control: h(TextField, { title: runtime.t('sync.daily'), value: settings.syncDailyAt, placeholder: 'HH:MM', onChange: (value) => set({ syncDailyAt: value }) }),
|
|
2090
|
+
}),
|
|
2091
|
+
h(Row, {
|
|
2092
|
+
title: runtime.t('sync.cooldown'),
|
|
2093
|
+
control: h(NumberField, { label: runtime.t('sync.cooldown'), value: settings.syncCooldownMinutes, min: 1, max: 240, onChange: (value) => set({ syncCooldownMinutes: value }) }),
|
|
2094
|
+
}),
|
|
2095
|
+
),
|
|
2096
|
+
h('div', { className: 'dshe-section' },
|
|
2097
|
+
h('div', { style: { display: 'flex', gap: '8px', flexWrap: 'wrap' } },
|
|
2098
|
+
h('button', {
|
|
2099
|
+
type: 'button',
|
|
2100
|
+
className: 'dshe-action',
|
|
2101
|
+
disabled: state.sync.busy === true,
|
|
2102
|
+
onClick: () => runtime.store.runSyncNow(),
|
|
2103
|
+
}, runtime.t('sync.run')),
|
|
2104
|
+
h('button', {
|
|
2105
|
+
type: 'button',
|
|
2106
|
+
className: 'dshe-action',
|
|
2107
|
+
disabled: state.sync.busy === true,
|
|
2108
|
+
onClick: () => runtime.store.openOverwrite('cloud'),
|
|
2109
|
+
}, runtime.t('overwrite.cloud')),
|
|
2110
|
+
h('button', {
|
|
2111
|
+
type: 'button',
|
|
2112
|
+
className: 'dshe-action',
|
|
2113
|
+
disabled: state.sync.busy === true,
|
|
2114
|
+
onClick: () => runtime.store.openOverwrite('local'),
|
|
2115
|
+
}, runtime.t('overwrite.local')),
|
|
2116
|
+
h('button', {
|
|
2117
|
+
type: 'button',
|
|
2118
|
+
className: 'dshe-action',
|
|
2119
|
+
onClick: () => runtime.store.toggleSyncLog(),
|
|
2120
|
+
}, state.sync.showLog === true ? runtime.t('sync.logHide') : runtime.t('sync.log')),
|
|
2121
|
+
h('button', {
|
|
2122
|
+
type: 'button',
|
|
2123
|
+
className: 'dshe-action',
|
|
2124
|
+
disabled: state.envCheck.busy === true,
|
|
2125
|
+
onClick: () => runtime.store.runEnvCheck(),
|
|
2126
|
+
}, state.envCheck.busy === true ? runtime.t('env.busy') : runtime.t('env.button')),
|
|
2127
|
+
h('button', {
|
|
2128
|
+
type: 'button',
|
|
2129
|
+
className: 'dshe-action',
|
|
2130
|
+
title: runtime.t('restart.hint'),
|
|
2131
|
+
onClick: () => runtime.store.openRestart(),
|
|
2132
|
+
}, runtime.t('restart.button')),
|
|
2133
|
+
),
|
|
2134
|
+
h('button', {
|
|
2135
|
+
type: 'button',
|
|
2136
|
+
className: 'dshe-row-desc dshe-log-toggle',
|
|
2137
|
+
title: runtime.t('sync.logToggle'),
|
|
2138
|
+
onClick: () => runtime.store.toggleSyncLog(),
|
|
2139
|
+
}, syncStatusLine(state, settings)),
|
|
2140
|
+
effectiveDir === ''
|
|
2141
|
+
? h('div', { className: 'dshe-row-desc dshe-error' }, runtime.t(settings.syncMode === 'webdav' ? 'sync.needMirror' : 'sync.needDir'))
|
|
2142
|
+
: null,
|
|
2143
|
+
state.sync.target !== null
|
|
2144
|
+
&& settings.syncMode !== 'webdav'
|
|
2145
|
+
&& state.sync.target.syncDirConfigured === true
|
|
2146
|
+
&& state.sync.target.syncDirExists === false
|
|
2147
|
+
? h('div', { className: 'dshe-row-desc dshe-error' }, runtime.t('sync.dirMissing', { path: state.sync.target.syncDir }))
|
|
2148
|
+
: null,
|
|
2149
|
+
state.sync.error === null
|
|
2150
|
+
? null
|
|
2151
|
+
: h('div', { className: 'dshe-row-desc dshe-error', role: 'alert' }, String(state.sync.error)),
|
|
2152
|
+
state.sync.showLog === true
|
|
2153
|
+
? h('div', {},
|
|
2154
|
+
h('div', { className: 'dshe-row-desc' }, runtime.t('sync.historyCount', { n: logEntries(state).length })),
|
|
2155
|
+
h('div', { className: 'dshe-log-list dshe-log-scroll' },
|
|
2156
|
+
logEntries(state).slice(0, Number(state.sync.historyLimit) || 5).map((item, index) => {
|
|
2157
|
+
const open = state.sync.historyOpen === index;
|
|
2158
|
+
return h('div', { key: item.at ?? String(index), className: 'dshe-log-item' },
|
|
2159
|
+
h('button', {
|
|
2160
|
+
type: 'button',
|
|
2161
|
+
className: `dshe-log-row${open ? ' dshe-log-row-open' : ''}`,
|
|
2162
|
+
onClick: () => runtime.store.openHistory(index),
|
|
2163
|
+
},
|
|
2164
|
+
h('span', {}, historyLine(item.entry)),
|
|
2165
|
+
h('span', { className: 'dshe-log-caret' }, open ? '▾' : '▸')),
|
|
2166
|
+
open ? h('div', { className: 'dshe-sync-log dshe-log-body' }, (item.log ?? []).map((line, lineIndex) => h(LogLine, { key: lineIndex, line, files: item.details?.[lineIndex] ?? [] }))) : null);
|
|
2167
|
+
}),
|
|
2168
|
+
),
|
|
2169
|
+
logEntries(state).length > (Number(state.sync.historyLimit) || 5)
|
|
2170
|
+
? h('button', { type: 'button', className: 'dshe-action', onClick: () => runtime.store.showMoreHistory() }, runtime.t('sync.more'))
|
|
2171
|
+
: null,
|
|
2172
|
+
)
|
|
2173
|
+
: null,
|
|
2174
|
+
),
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/** One log line: label column justified, rest flows normally. */
|
|
2179
|
+
function LogLine(props) {
|
|
2180
|
+
const [open, setOpen] = React.useState(false);
|
|
2181
|
+
const files = Array.isArray(props.files) ? props.files : [];
|
|
2182
|
+
const raw = String(props.line ?? '');
|
|
2183
|
+
const indent = raw.length - raw.trimStart().length;
|
|
2184
|
+
const text = raw.trimStart();
|
|
2185
|
+
const cut = text.indexOf(':');
|
|
2186
|
+
if (cut <= 0) {
|
|
2187
|
+
return h('div', { key: props.key, className: 'dshe-log-line dshe-log-line-plain' }, text);
|
|
2188
|
+
}
|
|
2189
|
+
const sub = indent > 0;
|
|
2190
|
+
const detail = files.length === 0
|
|
2191
|
+
? null
|
|
2192
|
+
: h('div', { className: 'dshe-log-files' }, files.slice(0, 200).map((file, index) => h('div', { key: index, className: 'dshe-log-file' }, file)));
|
|
2193
|
+
return h('div', { key: props.key, className: 'dshe-log-entry' },
|
|
2194
|
+
h('div', {
|
|
2195
|
+
className: `dshe-log-line${sub ? ' dshe-log-line-sub' : ''}${files.length > 0 ? ' dshe-log-line-more' : ''}`,
|
|
2196
|
+
title: files.length === 0 ? undefined : files.slice(0, 15).join('\n') + (files.length > 15 ? `\n…共 ${String(files.length)} 项` : ''),
|
|
2197
|
+
onClick: files.length === 0 ? undefined : () => setOpen((value) => !value),
|
|
2198
|
+
},
|
|
2199
|
+
h('span', { className: 'dshe-log-label' }, text.slice(0, cut)),
|
|
2200
|
+
h('span', { className: 'dshe-log-colon' }, ':'),
|
|
2201
|
+
h('span', { className: 'dshe-log-text' }, text.slice(cut + 1)),
|
|
2202
|
+
files.length === 0 ? null : h('span', { className: 'dshe-log-more' }, open ? '▾' : '▸')),
|
|
2203
|
+
open && detail !== null ? detail : null);
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
/** Outline trash glyph used in the counter line (inherits text colour). */
|
|
2207
|
+
function TrashIcon() {
|
|
2208
|
+
return h('svg', {
|
|
2209
|
+
width: 12,
|
|
2210
|
+
height: 12,
|
|
2211
|
+
viewBox: '0 0 24 24',
|
|
2212
|
+
fill: 'none',
|
|
2213
|
+
stroke: 'currentColor',
|
|
2214
|
+
strokeWidth: 2,
|
|
2215
|
+
strokeLinecap: 'round',
|
|
2216
|
+
strokeLinejoin: 'round',
|
|
2217
|
+
'aria-hidden': 'true',
|
|
2218
|
+
style: { verticalAlign: '-2px', margin: '0 1px' },
|
|
2219
|
+
},
|
|
2220
|
+
h('path', { d: 'M4 7h16' }),
|
|
2221
|
+
h('path', { d: 'M9 7V5h6v2' }),
|
|
2222
|
+
h('path', { d: 'M18 7l-1 13H7L6 7' }),
|
|
2223
|
+
h('path', { d: 'M10 11v6' }),
|
|
2224
|
+
h('path', { d: 'M14 11v6' }));
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
/** ↑ pushed · ↓ pulled · 🗑 deleted, with the icon drawn as SVG. */
|
|
2228
|
+
function countsNode(up, down, deleted, details) {
|
|
2229
|
+
const tip = (list, label) => {
|
|
2230
|
+
if (!Array.isArray(list) || list.length === 0) return undefined;
|
|
2231
|
+
const head = list.slice(0, 15).join('\n');
|
|
2232
|
+
return list.length > 15 ? `${label}\n${head}\n…共 ${String(list.length)} 项` : `${label}\n${head}`;
|
|
2233
|
+
};
|
|
2234
|
+
return h('span', { className: 'dshe-counts' },
|
|
2235
|
+
h('span', { title: tip(details?.up, '上传') }, `⬆ ${String(Number(up) || 0)}`),
|
|
2236
|
+
' · ',
|
|
2237
|
+
h('span', { title: tip(details?.down, '下载') }, `⬇ ${String(Number(down) || 0)}`),
|
|
2238
|
+
' · ',
|
|
2239
|
+
h(TrashIcon, {}),
|
|
2240
|
+
h('span', { title: tip(details?.del, '删除') }, ` ${String(Number(deleted) || 0)}`));
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
/** Latest run first, then the stored history, each with its own log slice. */
|
|
2244
|
+
function logEntries(state) {
|
|
2245
|
+
const list = [];
|
|
2246
|
+
const current = state.sync.state;
|
|
2247
|
+
const history = Array.isArray(state.sync.history) ? state.sync.history : [];
|
|
2248
|
+
const detailOf = (...candidates) => {
|
|
2249
|
+
for (const candidate of candidates) {
|
|
2250
|
+
if (Array.isArray(candidate?.details)) return candidate.details;
|
|
2251
|
+
}
|
|
2252
|
+
return [];
|
|
2253
|
+
};
|
|
2254
|
+
if (current !== null && current !== undefined) {
|
|
2255
|
+
const same = history[0] !== undefined && history[0].at === current.at;
|
|
2256
|
+
list.push({
|
|
2257
|
+
at: current.at,
|
|
2258
|
+
entry: same ? { ...current, ...history[0] } : current,
|
|
2259
|
+
log: Array.isArray(current.log) ? current.log : [],
|
|
2260
|
+
details: detailOf(current, history[0]),
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
for (const item of history) {
|
|
2264
|
+
if (list.length > 0 && item.at === list[0].at) continue;
|
|
2265
|
+
list.push({ at: item.at, entry: item, log: Array.isArray(item.log) ? item.log : [], details: detailOf(item) });
|
|
2266
|
+
}
|
|
2267
|
+
return list;
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
/** One compact line for one stored run. */
|
|
2271
|
+
function historyLine(item) {
|
|
2272
|
+
const when = typeof item.at === 'string' ? new Date(item.at).toLocaleString() : '';
|
|
2273
|
+
const result = item.ok === true ? runtime.t('sync.result.ok') : runtime.t('sync.result.fail');
|
|
2274
|
+
const up = Number(item.counts?.up ?? item.pushed ?? item.uploaded ?? 0) || 0;
|
|
2275
|
+
const down = Number(item.counts?.down ?? item.pulled ?? item.downloaded ?? 0) || 0;
|
|
2276
|
+
const del = Number(item.counts?.del ?? item.deleted ?? 0) || 0;
|
|
2277
|
+
const failed = Number(item.failed) > 0 ? ` · ✗${String(item.failed)}` : '';
|
|
2278
|
+
const label = typeof item.targetLabel === 'string' && item.targetLabel !== '' ? `${item.targetLabel} · ` : '';
|
|
2279
|
+
return h('span', {}, `${when} · ${result} · ${label}${String(Number(item.durationMs) || 0)} ms · `, countsNode(up, down, del, item.countDetails), failed);
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
|
|
2283
|
+
/** Width of the settings panel this page is rendered in, for relative sizing. */
|
|
2284
|
+
function measureSettingsPanel() {
|
|
2285
|
+
let node = document.querySelector('.dshe-section');
|
|
2286
|
+
while (node !== null && node !== document.body) {
|
|
2287
|
+
const width = node.getBoundingClientRect().width;
|
|
2288
|
+
if (width > 600) return Math.round(width);
|
|
2289
|
+
node = node.parentElement;
|
|
2290
|
+
}
|
|
2291
|
+
return 0;
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
|
|
2295
|
+
function syncStatusLine(state, settings) {
|
|
2296
|
+
const record = state.sync.state;
|
|
2297
|
+
if (record === null || record === undefined) return runtime.t('sync.never');
|
|
2298
|
+
const when = typeof record.at === 'string' ? new Date(record.at).toLocaleString() : '';
|
|
2299
|
+
const base = runtime.t('sync.last', {
|
|
2300
|
+
time: when,
|
|
2301
|
+
result: record.ok === true ? runtime.t('sync.result.ok') : runtime.t('sync.result.fail'),
|
|
2302
|
+
ms: Number(record.durationMs) || 0,
|
|
2303
|
+
});
|
|
2304
|
+
// One shape everywhere: ↑ pushed · ↓ pulled · 🗑 deleted.
|
|
2305
|
+
const pushed = record.counts?.up ?? record.summary?.sessions?.pushed ?? record.transport?.pushed?.uploaded ?? 0;
|
|
2306
|
+
const pulled = record.counts?.down ?? record.summary?.sessions?.pulled ?? record.transport?.pulled?.downloaded ?? 0;
|
|
2307
|
+
const removed = record.counts?.del ?? record.transport?.pushed?.deleted ?? record.summary?.prune?.sharedDeleted ?? 0;
|
|
2308
|
+
|
|
2309
|
+
const transport = record.transport;
|
|
2310
|
+
const extras = [];
|
|
2311
|
+
if (Number(record.trashPurged) > 0) extras.push(runtime.t('sync.purged', { n: Number(record.trashPurged) }));
|
|
2312
|
+
const paths = record.summary?.paths;
|
|
2313
|
+
if (paths !== null && paths !== undefined && (Number(paths.created) > 0 || Number(paths.failed) > 0)) {
|
|
2314
|
+
extras.push(runtime.t('sync.paths', { created: Number(paths.created) || 0, failed: Number(paths.failed) || 0 }));
|
|
2315
|
+
}
|
|
2316
|
+
const failures = (record.transport?.pushed?.failed?.length ?? 0) + (record.transport?.pulled?.failed?.length ?? 0);
|
|
2317
|
+
if (failures > 0) extras.push(runtime.t('sync.failed', { n: failures }));
|
|
2318
|
+
const tail = extras.length === 0 ? '' : ` · ${extras.join(' · ')}`;
|
|
2319
|
+
const skipped = transport?.pushed?.deleteSkipped;
|
|
2320
|
+
const note = typeof skipped === 'string' && skipped !== '' ? ` · ${skipped}` : '';
|
|
2321
|
+
return h('span', {}, `${base} · 传输:`, countsNode(pushed, pulled, removed, record.countDetails), `${tail}${note}`);
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
// ── toast ────────────────────────────────────────────────────────────────
|
|
2325
|
+
|
|
2326
|
+
/**
|
|
2327
|
+
* Writes the toast straight into <body>.
|
|
2328
|
+
*
|
|
2329
|
+
* The overlay slot sits inside the settings dialog's stacking context, so a
|
|
2330
|
+
* fixed child still renders under that dialog. Appending to body escapes it.
|
|
2331
|
+
*/
|
|
2332
|
+
function Toasts() {
|
|
2333
|
+
const state = useStore();
|
|
2334
|
+
const toast = state.toast;
|
|
2335
|
+
React.useEffect(() => {
|
|
2336
|
+
let host = document.getElementById('dshe-toast-host');
|
|
2337
|
+
if (host === null) {
|
|
2338
|
+
host = document.createElement('div');
|
|
2339
|
+
host.id = 'dshe-toast-host';
|
|
2340
|
+
host.style.cssText = 'position:fixed;left:0;right:0;bottom:28px;display:flex;justify-content:center;pointer-events:none;z-index:2147483000';
|
|
2341
|
+
document.body.appendChild(host);
|
|
2342
|
+
}
|
|
2343
|
+
host.textContent = '';
|
|
2344
|
+
if (toast === null || toast === undefined) return;
|
|
2345
|
+
const node = document.createElement('div');
|
|
2346
|
+
node.className = 'dshe-toast';
|
|
2347
|
+
node.dataset.kind = String(toast.kind ?? 'info');
|
|
2348
|
+
node.setAttribute('role', toast.kind === 'error' ? 'alert' : 'status');
|
|
2349
|
+
node.style.position = 'static';
|
|
2350
|
+
node.style.transform = 'none';
|
|
2351
|
+
node.style.left = 'auto';
|
|
2352
|
+
node.style.bottom = 'auto';
|
|
2353
|
+
node.textContent = String(toast.text ?? '');
|
|
2354
|
+
host.appendChild(node);
|
|
2355
|
+
}, [toast]);
|
|
2356
|
+
return null;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
/** Environment check result, including the "export report" path. */
|
|
2360
|
+
function EnvDialog() {
|
|
2361
|
+
const state = useStore();
|
|
2362
|
+
if (state.envCheck.open !== true) return null;
|
|
2363
|
+
if (primitives?.Modal === undefined) return null;
|
|
2364
|
+
const result = state.envCheck.result;
|
|
2365
|
+
const busy = state.envCheck.busy === true;
|
|
2366
|
+
const close = () => runtime.store.closeEnvCheck();
|
|
2367
|
+
if (busy) {
|
|
2368
|
+
return h(primitives.Modal, { open: true, onClose: close, closeLabel: runtime.t('common.close'), title: runtime.t('env.title') },
|
|
2369
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('env.busy')));
|
|
2370
|
+
}
|
|
2371
|
+
if (result?.ok === true) {
|
|
2372
|
+
return h(primitives.Modal, { open: true, onClose: close, closeLabel: runtime.t('common.close'), title: runtime.t('env.title') },
|
|
2373
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('env.ok')),
|
|
2374
|
+
h('div', { className: 'dshe-row-desc' }, runtime.t('env.versionLine', { app: result.appVersion ?? '未知', plugin: result.pluginVersion })));
|
|
2375
|
+
}
|
|
2376
|
+
const rows = (result?.checks ?? []).filter((item) => item.ok !== true);
|
|
2377
|
+
return h(primitives.Modal, {
|
|
2378
|
+
open: true,
|
|
2379
|
+
onClose: close,
|
|
2380
|
+
closeLabel: runtime.t('common.close'),
|
|
2381
|
+
title: runtime.t('env.title'),
|
|
2382
|
+
footer: h(React.Fragment, {},
|
|
2383
|
+
h('button', { type: 'button', className: 'dshe-action', onClick: close }, runtime.t('common.cancel')),
|
|
2384
|
+
h('button', { type: 'button', className: 'dshe-action dshe-action-danger', onClick: () => runtime.store.writeEnvReport() }, runtime.t('env.report'))),
|
|
2385
|
+
},
|
|
2386
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('env.risk', { n: Number(result?.failedCount) || rows.length })),
|
|
2387
|
+
h('div', { className: 'dshe-log-body' }, rows.slice(0, 12).map((item, index) => h('div', { key: index, className: 'dshe-log-line' },
|
|
2388
|
+
h('span', { className: 'dshe-log-label' }, item.label),
|
|
2389
|
+
h('span', { className: 'dshe-log-colon' }, ':'),
|
|
2390
|
+
h('span', { className: 'dshe-log-text' }, String(item.detail ?? ''))))));
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
/** Confirm an application restart (a running turn would be interrupted). */
|
|
2394
|
+
function RestartDialog() {
|
|
2395
|
+
const state = useStore();
|
|
2396
|
+
if (state.restartConfirm !== true) return null;
|
|
2397
|
+
if (primitives?.Modal === undefined) return null;
|
|
2398
|
+
return h(primitives.Modal, {
|
|
2399
|
+
open: true,
|
|
2400
|
+
onClose: () => runtime.store.closeRestart(),
|
|
2401
|
+
closeLabel: runtime.t('common.close'),
|
|
2402
|
+
title: runtime.t('restart.button'),
|
|
2403
|
+
footer: h(React.Fragment, {},
|
|
2404
|
+
h('button', { type: 'button', className: 'dshe-action', onClick: () => runtime.store.closeRestart() }, runtime.t('common.cancel')),
|
|
2405
|
+
h('button', { type: 'button', className: 'dshe-action dshe-action-danger', onClick: () => runtime.store.confirmRestart() }, runtime.t('restart.confirm'))),
|
|
2406
|
+
},
|
|
2407
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('restart.desc')));
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
/** Pick which saved setup a new one replaces when all three slots are taken. */
|
|
2411
|
+
function PresetReplaceDialog() {
|
|
2412
|
+
const state = useStore();
|
|
2413
|
+
if (state.presetReplace === null || state.presetReplace.open !== true) return null;
|
|
2414
|
+
if (primitives?.Modal === undefined) return null;
|
|
2415
|
+
const presets = Array.isArray(state.settings.webdavProfiles) ? state.settings.webdavProfiles : [];
|
|
2416
|
+
return h(primitives.Modal, {
|
|
2417
|
+
open: true,
|
|
2418
|
+
onClose: () => runtime.store.closePresetReplace(),
|
|
2419
|
+
closeLabel: runtime.t('common.close'),
|
|
2420
|
+
title: runtime.t('sync.webdav.presets.replaceTitle'),
|
|
2421
|
+
footer: h(React.Fragment, {},
|
|
2422
|
+
h('button', { type: 'button', className: 'dshe-action', onClick: () => runtime.store.closePresetReplace() }, runtime.t('common.cancel'))),
|
|
2423
|
+
},
|
|
2424
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('sync.webdav.presets.replaceDesc')),
|
|
2425
|
+
h('div', { className: 'dshe-presets-chips' },
|
|
2426
|
+
presets.map((item) => h('button', {
|
|
2427
|
+
key: item.id,
|
|
2428
|
+
type: 'button',
|
|
2429
|
+
className: 'dshe-action dshe-action-danger',
|
|
2430
|
+
onClick: () => runtime.store.confirmPresetReplace(item.id),
|
|
2431
|
+
}, item.name))));
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
/** Confirm a one-way overwrite of the cloud or of this machine. */
|
|
2435
|
+
function OverwriteDialog() {
|
|
2436
|
+
const state = useStore();
|
|
2437
|
+
const overwrite = state.overwrite;
|
|
2438
|
+
if (overwrite.open !== true) return null;
|
|
2439
|
+
if (primitives?.Modal === undefined) return null;
|
|
2440
|
+
const toCloud = overwrite.direction === 'cloud';
|
|
2441
|
+
const away = toCloud ? runtime.t('overwrite.awayCloud') : runtime.t('overwrite.awayLocal');
|
|
2442
|
+
return h(primitives.Modal, {
|
|
2443
|
+
open: true,
|
|
2444
|
+
onClose: () => runtime.store.closeOverwrite(),
|
|
2445
|
+
closeLabel: runtime.t('common.close'),
|
|
2446
|
+
title: toCloud ? runtime.t('overwrite.cloud') : runtime.t('overwrite.local'),
|
|
2447
|
+
footer: h(React.Fragment, {},
|
|
2448
|
+
h('button', { type: 'button', className: 'dshe-action', onClick: () => runtime.store.closeOverwrite() }, runtime.t('common.cancel')),
|
|
2449
|
+
h('button', {
|
|
2450
|
+
type: 'button',
|
|
2451
|
+
className: 'dshe-action dshe-action-danger',
|
|
2452
|
+
disabled: overwrite.busy === true,
|
|
2453
|
+
onClick: () => runtime.store.confirmOverwrite(),
|
|
2454
|
+
}, overwrite.busy === true ? runtime.t('overwrite.running') : runtime.t('overwrite.confirm'))),
|
|
2455
|
+
},
|
|
2456
|
+
h('p', { className: 'dshe-section-desc' }, away),
|
|
2457
|
+
overwrite.error === null
|
|
2458
|
+
? null
|
|
2459
|
+
: h('div', { className: 'dshe-row-desc dshe-error', role: 'alert' }, overwrite.error));
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
/** Shown when automatic sync paused after repeated failures. */
|
|
2463
|
+
function PauseDialog() {
|
|
2464
|
+
const state = useStore();
|
|
2465
|
+
if (state.pauseOpen !== true) return null;
|
|
2466
|
+
if (primitives?.Modal === undefined) return null;
|
|
2467
|
+
const auto = state.sync.auto;
|
|
2468
|
+
const last = state.sync.state?.diagnosis;
|
|
2469
|
+
return h(primitives.Modal, {
|
|
2470
|
+
open: true,
|
|
2471
|
+
onClose: () => runtime.store.dismissPauseNotice(),
|
|
2472
|
+
closeLabel: runtime.t('common.close'),
|
|
2473
|
+
title: runtime.t('pause.title'),
|
|
2474
|
+
footer: h(React.Fragment, {},
|
|
2475
|
+
h('button', { type: 'button', className: 'dshe-action', onClick: () => runtime.store.dismissPauseNotice() }, runtime.t('common.close')),
|
|
2476
|
+
h('button', { type: 'button', className: 'dshe-action dshe-action-active', onClick: () => runtime.store.resumeAutoSync() }, runtime.t('pause.resume'))),
|
|
2477
|
+
},
|
|
2478
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('pause.desc', { n: Number(auto?.failures) || 0 })),
|
|
2479
|
+
last === null || last === undefined
|
|
2480
|
+
? null
|
|
2481
|
+
: h('div', { className: 'dshe-row-desc' }, runtime.t('pause.last', { summary: last.summary, hint: last.hint })));
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
/** Shown once when the host application version changed since the last run. */
|
|
2485
|
+
function UpdateDialog() {
|
|
2486
|
+
const state = useStore();
|
|
2487
|
+
if (state.updatePrompt.open !== true) return null;
|
|
2488
|
+
if (primitives?.Modal === undefined) return null;
|
|
2489
|
+
return h(primitives.Modal, {
|
|
2490
|
+
open: true,
|
|
2491
|
+
onClose: () => runtime.store.dismissUpdatePrompt(),
|
|
2492
|
+
closeLabel: runtime.t('common.close'),
|
|
2493
|
+
title: runtime.t('env.update.title'),
|
|
2494
|
+
footer: h(React.Fragment, {},
|
|
2495
|
+
h('button', { type: 'button', className: 'dshe-action', onClick: () => runtime.store.dismissUpdatePrompt() }, runtime.t('env.update.no')),
|
|
2496
|
+
h('button', { type: 'button', className: 'dshe-action dshe-action-active', onClick: () => runtime.store.acceptUpdatePrompt() }, runtime.t('env.update.yes'))),
|
|
2497
|
+
},
|
|
2498
|
+
h('p', { className: 'dshe-section-desc' }, runtime.t('env.update.desc', {
|
|
2499
|
+
app: state.updatePrompt.appVersion ?? '',
|
|
2500
|
+
last: state.updatePrompt.lastAppVersion ?? '',
|
|
2501
|
+
})));
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
function OverlayStack() {
|
|
2505
|
+
return h(React.Fragment, {}, h(DeleteDialog, {}), h(MoveDialog, {}), h(TrashDialog, {}), h(EnvDialog, {}), h(UpdateDialog, {}), h(PauseDialog, {}), h(OverwriteDialog, {}), h(RestartDialog, {}), h(PresetReplaceDialog, {}), h(Toasts, {}));
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
// ── plugin ───────────────────────────────────────────────────────────────
|
|
2509
|
+
|
|
2510
|
+
return {
|
|
2511
|
+
inject: ['slots', 'locale', 'uiWorkspace'],
|
|
2512
|
+
apply(ctx) {
|
|
2513
|
+
const store = createStore();
|
|
2514
|
+
runtime.store = store;
|
|
2515
|
+
const t = ctx.locale.bind(NS);
|
|
2516
|
+
runtime.t = t;
|
|
2517
|
+
runtime.openSession = (sessionId) => {
|
|
2518
|
+
try {
|
|
2519
|
+
ctx.uiWorkspace.openSession(sessionId);
|
|
2520
|
+
} catch (error) {
|
|
2521
|
+
console.warn('[dsh-enhanced] opening the session failed:', error);
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
/**
|
|
2525
|
+
* Reconnect a workspace so its session list is rebuilt by the host.
|
|
2526
|
+
* Reloading the page cannot be used here: a reload right after a data
|
|
2527
|
+
* change makes the next boot fail to import this plugin's entry.
|
|
2528
|
+
*/
|
|
2529
|
+
runtime.refreshWorkspace = async (workspaceId) => {
|
|
2530
|
+
if (typeof workspaceId !== 'string' || workspaceId === '') return;
|
|
2531
|
+
try {
|
|
2532
|
+
await ctx.uiWorkspace.openWorkspace(workspaceId);
|
|
2533
|
+
} catch (error) {
|
|
2534
|
+
console.warn('[dsh-enhanced] refreshing the workspace failed:', error);
|
|
2535
|
+
}
|
|
2536
|
+
};
|
|
2537
|
+
const normalizeAnchor = (text) => (typeof text === 'string'
|
|
2538
|
+
? text.replace(/[`*_#>~[\]()]/g, ' ').replace(/…/g, ' ').replace(/\s+/g, ' ').trim()
|
|
2539
|
+
: '');
|
|
2540
|
+
|
|
2541
|
+
runtime.jumpToAnchor = (options) => {
|
|
2542
|
+
const needleQuery = normalizeAnchor(options?.query);
|
|
2543
|
+
const needleSnippet = normalizeAnchor(options?.snippet);
|
|
2544
|
+
const turn = Number.isInteger(options?.turn) ? options.turn : null;
|
|
2545
|
+
const candidates = [];
|
|
2546
|
+
for (const source of [needleSnippet, needleQuery]) {
|
|
2547
|
+
if (source === '') continue;
|
|
2548
|
+
for (const size of [36, 24, 16, 10]) {
|
|
2549
|
+
if (source.length < size && source !== needleQuery) continue;
|
|
2550
|
+
const value = source.length > size ? source.slice(0, size) : source;
|
|
2551
|
+
if (value !== '' && !candidates.includes(value)) candidates.push(value);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
if (candidates.length === 0) return;
|
|
2555
|
+
let attempts = 0;
|
|
2556
|
+
const tick = () => {
|
|
2557
|
+
attempts += 1;
|
|
2558
|
+
const flow = document.querySelector('[data-chat-flow]');
|
|
2559
|
+
if (flow !== null) {
|
|
2560
|
+
const nodes = turn === null
|
|
2561
|
+
? flow.querySelectorAll('[data-chat-flow-key]')
|
|
2562
|
+
: (() => {
|
|
2563
|
+
const scoped = flow.querySelectorAll(`[data-chat-turn="${String(turn)}"]`);
|
|
2564
|
+
return scoped.length > 0 ? scoped : flow.querySelectorAll('[data-chat-flow-key]');
|
|
2565
|
+
})();
|
|
2566
|
+
for (const needle of candidates) {
|
|
2567
|
+
for (const node of nodes) {
|
|
2568
|
+
const text = normalizeAnchor(node.textContent ?? '');
|
|
2569
|
+
if (text.includes(needle)) {
|
|
2570
|
+
node.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
if (attempts < 25) window.setTimeout(tick, 140);
|
|
2577
|
+
else runtime.store.toast('info', runtime.t('search.notLocated'));
|
|
2578
|
+
};
|
|
2579
|
+
window.setTimeout(tick, 60);
|
|
2580
|
+
};
|
|
2581
|
+
|
|
2582
|
+
runtime.focusMatch = async (sessionId, match, query) => {
|
|
2583
|
+
let turn = null;
|
|
2584
|
+
if (match !== null && match !== undefined && Number.isInteger(match.seq)) {
|
|
2585
|
+
try {
|
|
2586
|
+
const data = await runtime.rpc('locate.event', { sessionId, seq: match.seq });
|
|
2587
|
+
if (Number.isInteger(data?.turn)) turn = data.turn;
|
|
2588
|
+
} catch (error) {
|
|
2589
|
+
console.warn('[dsh-enhanced] locating the event failed:', error);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
runtime.jumpToAnchor({ snippet: match?.snippet ?? '', query, turn });
|
|
2593
|
+
};
|
|
2594
|
+
runtime.rpc = async (action, payload, signal) => {
|
|
2595
|
+
const url = new URL('api/dsh-enhanced/rpc', document.baseURI);
|
|
2596
|
+
const response = await fetch(url, {
|
|
2597
|
+
method: 'POST',
|
|
2598
|
+
headers: { 'content-type': 'application/json' },
|
|
2599
|
+
credentials: 'same-origin',
|
|
2600
|
+
signal,
|
|
2601
|
+
body: JSON.stringify({ action, ...(payload ?? {}) }),
|
|
2602
|
+
});
|
|
2603
|
+
if (!response.ok) throw new Error(`请求失败(HTTP ${String(response.status)})`);
|
|
2604
|
+
const body = await response.json();
|
|
2605
|
+
if (body === null || typeof body !== 'object' || body.ok !== true) {
|
|
2606
|
+
throw new Error(body?.error?.message ?? '请求失败');
|
|
2607
|
+
}
|
|
2608
|
+
return body.data;
|
|
2609
|
+
};
|
|
2610
|
+
|
|
2611
|
+
ctx.effect(() => ctx.locale.register(NS, DICT), 'dsh-enhanced: dictionaries');
|
|
2612
|
+
|
|
2613
|
+
ctx.effect(() => {
|
|
2614
|
+
const id = '@xsok/dsh-enhanced/styles';
|
|
2615
|
+
if (document.querySelector(`style[data-plugin-css="${id}"]`) !== null) return () => {};
|
|
2616
|
+
const tag = document.createElement('style');
|
|
2617
|
+
tag.dataset.plugin = '@xsok/dsh-enhanced';
|
|
2618
|
+
tag.dataset.pluginCss = id;
|
|
2619
|
+
tag.textContent = STYLES;
|
|
2620
|
+
document.head.appendChild(tag);
|
|
2621
|
+
return () => tag.remove();
|
|
2622
|
+
}, 'dsh-enhanced: styles');
|
|
2623
|
+
|
|
2624
|
+
ctx.effect(() => {
|
|
2625
|
+
const onKeyDown = (event) => {
|
|
2626
|
+
if (!(event.ctrlKey || event.metaKey) || event.altKey || event.shiftKey) return;
|
|
2627
|
+
if (event.key !== 'f' && event.key !== 'F') return;
|
|
2628
|
+
if (runtime.store.get().settings.searchEnabled !== true) return;
|
|
2629
|
+
event.preventDefault();
|
|
2630
|
+
event.stopPropagation();
|
|
2631
|
+
runtime.store.openSearch();
|
|
2632
|
+
};
|
|
2633
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
2634
|
+
return () => window.removeEventListener('keydown', onKeyDown, true);
|
|
2635
|
+
}, 'dsh-enhanced: ctrl+f');
|
|
2636
|
+
|
|
2637
|
+
|
|
2638
|
+
ctx.effect(() => {
|
|
2639
|
+
const onKeyDown = (event) => {
|
|
2640
|
+
if (event.ctrlKey !== true || event.shiftKey !== true || event.altKey !== true) return;
|
|
2641
|
+
if (String(event.key).toLowerCase() !== 'r') return;
|
|
2642
|
+
event.preventDefault();
|
|
2643
|
+
event.stopPropagation();
|
|
2644
|
+
if (runtime.store.get().restartConfirm !== true) runtime.store.openRestart();
|
|
2645
|
+
};
|
|
2646
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
2647
|
+
return () => window.removeEventListener('keydown', onKeyDown, true);
|
|
2648
|
+
}, 'dsh-enhanced: restart shortcut');
|
|
2649
|
+
|
|
2650
|
+
ctx.effect(() => {
|
|
2651
|
+
// Prefetch distance from the top of the loaded history, in pixels.
|
|
2652
|
+
const PREFETCH_PX = 800;
|
|
2653
|
+
// Do not stack requests closer than this, so one flick loads one page.
|
|
2654
|
+
const MIN_GAP_MS = 120;
|
|
2655
|
+
let cachedScroller = null;
|
|
2656
|
+
let loading = null;
|
|
2657
|
+
let scheduled = null;
|
|
2658
|
+
let lastStartAt = 0;
|
|
2659
|
+
|
|
2660
|
+
const flowNode = () => document.querySelector('[data-chat-flow]');
|
|
2661
|
+
|
|
2662
|
+
const followingTail = () => document.querySelector('[data-chat-following-tail]') !== null;
|
|
2663
|
+
|
|
2664
|
+
const scrollerFor = () => {
|
|
2665
|
+
if (cachedScroller !== null && cachedScroller.isConnected === true) return cachedScroller;
|
|
2666
|
+
cachedScroller = null;
|
|
2667
|
+
const node = flowNode();
|
|
2668
|
+
if (node !== null) {
|
|
2669
|
+
let current = node.parentElement;
|
|
2670
|
+
while (current !== null && current !== document.body) {
|
|
2671
|
+
const style = window.getComputedStyle(current);
|
|
2672
|
+
if ((style.overflowY === 'auto' || style.overflowY === 'scroll') && current.scrollHeight > current.clientHeight + 4) {
|
|
2673
|
+
cachedScroller = current;
|
|
2674
|
+
return current;
|
|
2675
|
+
}
|
|
2676
|
+
current = current.parentElement;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
const doc = document.scrollingElement;
|
|
2680
|
+
if (doc instanceof Element) cachedScroller = doc;
|
|
2681
|
+
return cachedScroller;
|
|
2682
|
+
};
|
|
2683
|
+
|
|
2684
|
+
const findOlderButton = () => {
|
|
2685
|
+
for (const button of document.querySelectorAll('button')) {
|
|
2686
|
+
if (button.closest('[data-chat-flow-key]') !== null) continue;
|
|
2687
|
+
const parent = button.parentElement;
|
|
2688
|
+
const className = parent === null ? '' : String(parent.className ?? '');
|
|
2689
|
+
const label = (button.textContent ?? '').trim();
|
|
2690
|
+
if (/(?:^|_)older(?:_|$)/u.test(className) || label === 'Load earlier' || label.startsWith('加载更早')) return button;
|
|
2691
|
+
}
|
|
2692
|
+
return null;
|
|
2693
|
+
};
|
|
2694
|
+
|
|
2695
|
+
const scrollHeightOf = (scroller) => (scroller === null ? 0 : scroller.scrollHeight);
|
|
2696
|
+
|
|
2697
|
+
/**
|
|
2698
|
+
* Load one page without moving the viewport.
|
|
2699
|
+
*
|
|
2700
|
+
* The click inserts content above; the reader keeps the same messages on
|
|
2701
|
+
* screen because scrollTop grows by exactly the height that was added.
|
|
2702
|
+
*/
|
|
2703
|
+
const loadPage = () => {
|
|
2704
|
+
if (loading !== null) return;
|
|
2705
|
+
if (Date.now() - lastStartAt < MIN_GAP_MS) return;
|
|
2706
|
+
if (runtime.store.get().settings.autoLoadEnabled !== true) return;
|
|
2707
|
+
if (followingTail()) return;
|
|
2708
|
+
const button = findOlderButton();
|
|
2709
|
+
if (button === null || button.disabled === true) return;
|
|
2710
|
+
|
|
2711
|
+
const scroller = scrollerFor();
|
|
2712
|
+
if (scroller === null) return;
|
|
2713
|
+
const before = { height: scroller.scrollHeight, top: scroller.scrollTop };
|
|
2714
|
+
|
|
2715
|
+
loading = { height: before.height, top: before.top, at: Date.now() };
|
|
2716
|
+
lastStartAt = Date.now();
|
|
2717
|
+
try {
|
|
2718
|
+
button.blur();
|
|
2719
|
+
} catch {
|
|
2720
|
+
// A button without focus support is fine.
|
|
2721
|
+
}
|
|
2722
|
+
button.click();
|
|
2723
|
+
|
|
2724
|
+
const settle = () => {
|
|
2725
|
+
if (loading === null) return;
|
|
2726
|
+
const heightNow = scroller.scrollHeight;
|
|
2727
|
+
const grown = heightNow - before.height;
|
|
2728
|
+
const elapsed = Date.now() - loading.at;
|
|
2729
|
+
if (grown <= 0 && elapsed < 8000) {
|
|
2730
|
+
window.setTimeout(settle, 100);
|
|
2731
|
+
return;
|
|
2732
|
+
}
|
|
2733
|
+
// The browser may already have anchored the view; only correct when it
|
|
2734
|
+
// did not, or the two compensations would add up into a jump.
|
|
2735
|
+
const moved = Math.abs(scroller.scrollTop - before.top) > 4;
|
|
2736
|
+
if (grown > 0 && !moved) scroller.scrollTop = before.top + grown;
|
|
2737
|
+
loading = null;
|
|
2738
|
+
// Chain straight into the next page while the reader is still near the top.
|
|
2739
|
+
schedule(80);
|
|
2740
|
+
};
|
|
2741
|
+
window.setTimeout(settle, 100);
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2744
|
+
const schedule = (delay) => {
|
|
2745
|
+
if (scheduled !== null) window.clearTimeout(scheduled);
|
|
2746
|
+
scheduled = window.setTimeout(() => {
|
|
2747
|
+
scheduled = null;
|
|
2748
|
+
const scroller = scrollerFor();
|
|
2749
|
+
if (scroller === null) return;
|
|
2750
|
+
if (scroller.scrollTop > PREFETCH_PX) return;
|
|
2751
|
+
loadPage();
|
|
2752
|
+
}, delay);
|
|
2753
|
+
};
|
|
2754
|
+
|
|
2755
|
+
let framePending = false;
|
|
2756
|
+
let lastTop = null;
|
|
2757
|
+
const onScroll = () => {
|
|
2758
|
+
if (framePending) return;
|
|
2759
|
+
framePending = true;
|
|
2760
|
+
window.requestAnimationFrame(() => {
|
|
2761
|
+
framePending = false;
|
|
2762
|
+
if (runtime.store.get().settings.autoLoadEnabled !== true) return;
|
|
2763
|
+
if (followingTail()) return;
|
|
2764
|
+
const scroller = scrollerFor();
|
|
2765
|
+
if (scroller === null) return;
|
|
2766
|
+
const top = scroller.scrollTop;
|
|
2767
|
+
const goingUp = lastTop !== null && top < lastTop - 2;
|
|
2768
|
+
lastTop = top;
|
|
2769
|
+
if (!goingUp) return;
|
|
2770
|
+
if (top > PREFETCH_PX) return;
|
|
2771
|
+
loadPage();
|
|
2772
|
+
});
|
|
2773
|
+
};
|
|
2774
|
+
|
|
2775
|
+
const onWheel = (event) => {
|
|
2776
|
+
if (event.deltaY >= 0) return;
|
|
2777
|
+
const scroller = scrollerFor();
|
|
2778
|
+
if (scroller === null) return;
|
|
2779
|
+
if (scroller.scrollTop > PREFETCH_PX) return;
|
|
2780
|
+
schedule(0);
|
|
2781
|
+
};
|
|
2782
|
+
|
|
2783
|
+
window.addEventListener('scroll', onScroll, { capture: true, passive: true });
|
|
2784
|
+
window.addEventListener('wheel', onWheel, { capture: true, passive: true });
|
|
2785
|
+
return () => {
|
|
2786
|
+
window.removeEventListener('scroll', onScroll, true);
|
|
2787
|
+
window.removeEventListener('wheel', onWheel, true);
|
|
2788
|
+
if (scheduled !== null) window.clearTimeout(scheduled);
|
|
2789
|
+
};
|
|
2790
|
+
}, 'dsh-enhanced: auto load earlier');
|
|
2791
|
+
|
|
2792
|
+
ctx.effect(() => {
|
|
2793
|
+
let pending = null;
|
|
2794
|
+
try {
|
|
2795
|
+
pending = window.sessionStorage.getItem('dsh-enhanced.pendingOpen');
|
|
2796
|
+
if (pending !== null) window.sessionStorage.removeItem('dsh-enhanced.pendingOpen');
|
|
2797
|
+
} catch {
|
|
2798
|
+
pending = null;
|
|
2799
|
+
}
|
|
2800
|
+
if (pending === null || pending === '') return () => {};
|
|
2801
|
+
const openWhenReady = (attempt) => {
|
|
2802
|
+
try {
|
|
2803
|
+
runtime.openSession(pending);
|
|
2804
|
+
} catch {
|
|
2805
|
+
if (attempt < 4) window.setTimeout(() => openWhenReady(attempt + 1), 500);
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
const timer = window.setTimeout(() => openWhenReady(0), 800);
|
|
2809
|
+
return () => window.clearTimeout(timer);
|
|
2810
|
+
}, 'dsh-enhanced: open session after reload');
|
|
2811
|
+
|
|
2812
|
+
|
|
2813
|
+
ctx.effect(() => {
|
|
2814
|
+
runtime.store.init();
|
|
2815
|
+
return () => {};
|
|
2816
|
+
}, 'dsh-enhanced: initial state');
|
|
2817
|
+
|
|
2818
|
+
ctx.effect(() => {
|
|
2819
|
+
const timer = setTimeout(() => { void runtime.store.checkAppVersion(); }, 1500);
|
|
2820
|
+
return () => clearTimeout(timer);
|
|
2821
|
+
}, 'dsh-enhanced: app version probe');
|
|
2822
|
+
|
|
2823
|
+
ctx.slots.inject('sidebar.workspaces.session.menu.item', () => ctx.slots.register({
|
|
2824
|
+
name: 'sidebar.workspaces.session.menu.item',
|
|
2825
|
+
id: 'dsh-enhanced.delete-session',
|
|
2826
|
+
order: 500,
|
|
2827
|
+
locale: NS,
|
|
2828
|
+
}, SessionDeleteRow));
|
|
2829
|
+
|
|
2830
|
+
ctx.slots.inject('sidebar.workspaces.session.menu.item', () => ctx.slots.register({
|
|
2831
|
+
name: 'sidebar.workspaces.session.menu.item',
|
|
2832
|
+
id: 'dsh-enhanced.trash-for-session',
|
|
2833
|
+
order: 510,
|
|
2834
|
+
locale: NS,
|
|
2835
|
+
}, SessionTrashRow));
|
|
2836
|
+
|
|
2837
|
+
ctx.slots.inject('sidebar.workspaces.session.menu.item', () => ctx.slots.register({
|
|
2838
|
+
name: 'sidebar.workspaces.session.menu.item',
|
|
2839
|
+
id: 'dsh-enhanced.move-session',
|
|
2840
|
+
order: 520,
|
|
2841
|
+
locale: NS,
|
|
2842
|
+
}, SessionMoveRow));
|
|
2843
|
+
|
|
2844
|
+
|
|
2845
|
+
ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
2846
|
+
name: 'shell.overlay',
|
|
2847
|
+
id: 'dsh-enhanced.search',
|
|
2848
|
+
order: 900,
|
|
2849
|
+
locale: NS,
|
|
2850
|
+
}, SearchOverlay));
|
|
2851
|
+
|
|
2852
|
+
ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
2853
|
+
name: 'shell.overlay',
|
|
2854
|
+
id: 'dsh-enhanced.dialogs',
|
|
2855
|
+
order: 910,
|
|
2856
|
+
locale: NS,
|
|
2857
|
+
}, OverlayStack));
|
|
2858
|
+
|
|
2859
|
+
ctx.slots.inject('conversation.input.left', () => ctx.slots.register({
|
|
2860
|
+
name: 'conversation.input.left',
|
|
2861
|
+
id: 'dsh-enhanced.composer-bridge',
|
|
2862
|
+
order: 1000,
|
|
2863
|
+
locale: NS,
|
|
2864
|
+
}, ComposerBridge));
|
|
2865
|
+
|
|
2866
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
2867
|
+
name: 'settings.section',
|
|
2868
|
+
id: 'dsh-enhanced',
|
|
2869
|
+
order: 30,
|
|
2870
|
+
label: () => runtime.t('nav.title'),
|
|
2871
|
+
locale: NS,
|
|
2872
|
+
}, SettingsSection));
|
|
2873
|
+
},
|
|
2874
|
+
};
|
|
2875
|
+
},
|
|
2876
|
+
});
|