@wangyf397/session_del 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/client.js +144 -245
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ DSH 自带的能力只有「归档」:归档只是把会话从侧栏隐藏,
|
|
|
7
7
|
|
|
8
8
|
| 入口 | 用法 |
|
|
9
9
|
|---|---|
|
|
10
|
-
| 侧栏菜单 | 会话行「…」→ **彻底删除会话** →
|
|
10
|
+
| 侧栏菜单 | 会话行「…」→ **彻底删除会话** → 再点一次确认 → 删除 |
|
|
11
11
|
| 人类命令 | `/session-del list`、`/session-del delete <会话ID…>` |
|
|
12
12
|
| Agent 工具 | `session_del({ action: "list" })`、`session_del({ action: "delete", session_ids: [...] })` |
|
|
13
13
|
|
|
@@ -54,8 +54,11 @@ dsh plugin --profile web add link:/Users/wangyf/code/dsh-plugins/session_del
|
|
|
54
54
|
- 删除通过 `ctx.remote.commands.execute(sessionId, "/session-del delete …")` 落到 Host,
|
|
55
55
|
因此需要一个**当前打开的会话**作为命令的执行者(正在看的那个会话本身删不掉)。
|
|
56
56
|
命令会在当前会话里留下两条 log-only 的 `command/run`、`command/done` 记录,便于审计。
|
|
57
|
-
-
|
|
58
|
-
|
|
57
|
+
- 侧栏菜单采用「点两下 + 行内反馈」:第一下变成「再点一次,彻底删除」,第二下执行,
|
|
58
|
+
成功/失败信息都显示在那一行里(不弹窗、不写全局 DOM/样式)。
|
|
59
|
+
- 侧栏列表由客户端会话列表驱动:删除成功后该行要刷新页面才会消失;磁盘与索引在删除当刻就干净了。
|
|
60
|
+
- 工作区注册表里那条会话的排序占位 id 没有公开删除 API:显示时已被过滤,下次该工作区有任何变更时
|
|
61
|
+
会连带清掉。
|
|
59
62
|
|
|
60
63
|
## 发布
|
|
61
64
|
|
package/client.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* session_del — Client half.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 由 Host 端执行真正的删除(会话日志 + 投影缓存 + 归档/置顶记录)。
|
|
4
|
+
* 在侧栏每个会话的「…」菜单里加一行「彻底删除会话」。点一下变成确认态,
|
|
5
|
+
* 再点一下才真正执行;执行结果(成功 / Host 拒绝的原因)直接显示在这一行里。
|
|
7
6
|
*
|
|
8
|
-
*
|
|
7
|
+
* 删除动作通过 ctx.remote.commands.execute(sessionId, "/session-del delete <id>")
|
|
8
|
+
* 交给 Host 的 /session-del 命令完成——UI 与 Agent 工具共用同一套操作。
|
|
9
|
+
*
|
|
10
|
+
* 不引用任何 @deepseek-ai 客户端包,也不写全局 DOM/样式:视觉全部用内联样式
|
|
11
|
+
* 和主题 token(--dsw-alias-*),把出错面压到最小。
|
|
9
12
|
*
|
|
10
13
|
* @module @wangyf397/session_del/client
|
|
11
14
|
*/
|
|
@@ -19,83 +22,30 @@ window.__ModuleLoader__.load({
|
|
|
19
22
|
/** 运行时 locale 命名空间(同时用于插件元数据)。 */
|
|
20
23
|
const NS = 'session_del'
|
|
21
24
|
|
|
22
|
-
/** 仅本插件使用的全局样式(随 shell.overlay 入口长期挂载)。 */
|
|
23
|
-
const CSS = `
|
|
24
|
-
.sd-menu-item{display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:28px;padding:0 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary);font-family:inherit;font-size:13px;font-weight:400;line-height:18px;text-align:left;cursor:pointer}
|
|
25
|
-
.sd-menu-item:hover{background:color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent)}
|
|
26
|
-
.sd-menu-item:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-alias-brand-primary);outline-offset:-2px}
|
|
27
|
-
.sd-menu-item-icon{display:inline-flex;flex:none;width:14px;height:14px;color:var(--dsw-alias-state-error-primary)}
|
|
28
|
-
.sd-dialog{box-sizing:border-box;width:min(460px,calc(100vw - 40px));margin:auto;padding:0;border:0;border-radius:12px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-family:inherit;box-shadow:0 16px 48px rgba(0,0,0,.35);pointer-events:auto}
|
|
29
|
-
.sd-dialog::backdrop{background:rgba(0,0,0,.42);pointer-events:auto}
|
|
30
|
-
.sd-dialog-body{display:flex;flex-direction:column;gap:10px;padding:18px 20px 4px}
|
|
31
|
-
.sd-dialog-title{font-size:15px;font-weight:600;line-height:22px}
|
|
32
|
-
.sd-dialog-desc{margin:0;font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
33
|
-
.sd-dialog-note{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
|
|
34
|
-
.sd-dialog-status{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
|
|
35
|
-
.sd-dialog-result{margin:0;max-height:180px;overflow:auto;font-family:inherit;font-size:12px;line-height:18px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
36
|
-
.sd-dialog-result.sd-err{color:var(--dsw-alias-state-error-primary)}
|
|
37
|
-
.sd-dialog-result.sd-ok{color:var(--dsw-alias-state-success-primary)}
|
|
38
|
-
.sd-dialog-footer{display:flex;justify-content:flex-end;gap:8px;padding:14px 20px 18px}
|
|
39
|
-
.sd-btn{height:28px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l2);border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary);font-family:inherit;font-size:13px;line-height:18px;cursor:pointer}
|
|
40
|
-
.sd-btn:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent)}
|
|
41
|
-
.sd-btn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
42
|
-
.sd-btn:disabled{opacity:.5;cursor:default}
|
|
43
|
-
.sd-btn.sd-danger:not(:disabled){color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}
|
|
44
|
-
`
|
|
45
|
-
|
|
46
25
|
/** 中英文案。 */
|
|
47
26
|
const zh = {
|
|
48
27
|
'menu.delete': '彻底删除会话',
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'done': '完成',
|
|
57
|
-
'error.noRunner': '没有可用的会话来执行删除。请先打开任意一个会话,再回来重试。',
|
|
58
|
-
'error.noRemote': '当前界面无法连接 Host(ctx.remote.commands 不可用)。',
|
|
59
|
-
'error.unknownCommand': 'Host 上没有 /session-del 命令:插件可能未生效,或 Host 版本不匹配。',
|
|
60
|
-
'error.current': '这是当前正在查看的会话,无法删除。请先切到别的会话。',
|
|
28
|
+
'menu.confirm': '再点一次,彻底删除',
|
|
29
|
+
'menu.busy': '正在删除…',
|
|
30
|
+
'menu.done': '已彻底删除',
|
|
31
|
+
'menu.failed': '删除失败:{reason}',
|
|
32
|
+
'error.noRunner': '没有可执行删除的会话,请先打开任意会话',
|
|
33
|
+
'error.noRemote': '无法连接 Host(ctx.remote.commands 不可用)',
|
|
34
|
+
'error.unknownCommand': 'Host 上没有 /session-del 命令(插件未生效?)',
|
|
61
35
|
}
|
|
62
36
|
|
|
63
37
|
const en = {
|
|
64
38
|
'menu.delete': 'Delete session permanently',
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'done': 'Done',
|
|
73
|
-
'error.noRunner': 'No session is available to run the deletion. Open any session and try again.',
|
|
74
|
-
'error.noRemote': 'This page cannot reach the Host (ctx.remote.commands is unavailable).',
|
|
75
|
-
'error.unknownCommand': 'The Host has no /session-del command: the plugin may not be active, or the Host version does not match.',
|
|
76
|
-
'error.current': 'This is the session you are viewing; it cannot be deleted. Switch to another session first.',
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** 极小的可观察快照存储(供 slots 的 hooks 使用)。 */
|
|
80
|
-
function createStore(initial) {
|
|
81
|
-
let value = initial
|
|
82
|
-
const listeners = new Set()
|
|
83
|
-
return {
|
|
84
|
-
getSnapshot: () => value,
|
|
85
|
-
subscribe: (listener) => {
|
|
86
|
-
listeners.add(listener)
|
|
87
|
-
return () => {
|
|
88
|
-
listeners.delete(listener)
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
set: (next) => {
|
|
92
|
-
value = next
|
|
93
|
-
for (const listener of [...listeners]) listener()
|
|
94
|
-
},
|
|
95
|
-
}
|
|
39
|
+
'menu.confirm': 'Click again to delete permanently',
|
|
40
|
+
'menu.busy': 'Deleting…',
|
|
41
|
+
'menu.done': 'Deleted permanently',
|
|
42
|
+
'menu.failed': 'Delete failed: {reason}',
|
|
43
|
+
'error.noRunner': 'No session available to run the deletion; open any session first',
|
|
44
|
+
'error.noRemote': 'Cannot reach the Host (ctx.remote.commands is unavailable)',
|
|
45
|
+
'error.unknownCommand': 'The Host has no /session-del command (is the plugin active?)',
|
|
96
46
|
}
|
|
97
47
|
|
|
98
|
-
/** 当前主视图里的会话 id
|
|
48
|
+
/** 当前主视图里的会话 id:命令需要一个 agent 作为执行者。 */
|
|
99
49
|
function mainViewSessionId(state, excludeId) {
|
|
100
50
|
const byId = state?.byId ?? {}
|
|
101
51
|
for (const row of Object.values(byId)) {
|
|
@@ -127,184 +77,155 @@ window.__ModuleLoader__.load({
|
|
|
127
77
|
}
|
|
128
78
|
|
|
129
79
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @param {object}
|
|
80
|
+
* 从命令执行结果里取出要展示的文字。
|
|
81
|
+
* @param {object|undefined} result ctx.remote.commands.execute 的返回值
|
|
82
|
+
* @param {Function} t 翻译函数
|
|
83
|
+
* @returns {{ok: boolean, text: string}}
|
|
132
84
|
*/
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
className: 'sd-menu-item',
|
|
143
|
-
onClick: () => {
|
|
144
|
-
setMenuOpen(false)
|
|
145
|
-
requestDelete({
|
|
146
|
-
sessionId: String(sessionId),
|
|
147
|
-
displayTitle: displayTitle || undefined,
|
|
148
|
-
runnerSessionId: mainViewSessionId(sessionState, sessionId),
|
|
149
|
-
})
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
h('span', { className: 'sd-menu-item-icon', key: 'icon' }, TrashIcon()),
|
|
153
|
-
h('span', { key: 'label' }, t('menu.delete'))
|
|
154
|
-
)
|
|
85
|
+
function readResult(result, t) {
|
|
86
|
+
if (!result || result.ok !== true) {
|
|
87
|
+
const message = result?.error?.message ?? t('error.noRemote')
|
|
88
|
+
const code = result?.error?.code ? ` (${result.error.code})` : ''
|
|
89
|
+
return { ok: false, text: `${message}${code}` }
|
|
90
|
+
}
|
|
91
|
+
if (result.value === undefined) return { ok: false, text: t('error.unknownCommand') }
|
|
92
|
+
const execution = result.value.result ?? {}
|
|
93
|
+
return { ok: execution.kind === 'success', text: String(execution.text ?? '') }
|
|
155
94
|
}
|
|
156
95
|
|
|
157
96
|
/**
|
|
158
|
-
*
|
|
159
|
-
* @param {object} props
|
|
97
|
+
* 侧栏会话菜单里的一行:idle → confirm → busy → done/failed。
|
|
98
|
+
* @param {object} props sessionId / displayTitle / useMenuOpenState / useSessions / t
|
|
160
99
|
*/
|
|
161
|
-
function
|
|
162
|
-
const {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
null,
|
|
167
|
-
h('style', { key: 'sd-style' }, CSS),
|
|
168
|
-
request
|
|
169
|
-
? h(DeleteDialog, {
|
|
170
|
-
key: `${request.sessionId}-${request.at}`,
|
|
171
|
-
request,
|
|
172
|
-
settleDelete,
|
|
173
|
-
t,
|
|
174
|
-
})
|
|
175
|
-
: null
|
|
176
|
-
)
|
|
177
|
-
}
|
|
100
|
+
function DeleteMenuItem(props) {
|
|
101
|
+
const { sessionId, displayTitle, useMenuOpenState, useSessions, t } = props
|
|
102
|
+
const translate = typeof t === 'function' ? t : (key, vars) => (vars ? `${key} ${JSON.stringify(vars)}` : key)
|
|
103
|
+
const [, setMenuOpen] = useMenuOpenState()
|
|
104
|
+
const sessionState = useSessions((state) => state)
|
|
178
105
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const { request, settleDelete, t } = props
|
|
185
|
-
const dialogRef = React.useRef(null)
|
|
186
|
-
const [busy, setBusy] = React.useState(false)
|
|
187
|
-
const [outcome, setOutcome] = React.useState(null)
|
|
106
|
+
const [phase, setPhase] = React.useState('idle')
|
|
107
|
+
const [reason, setReason] = React.useState('')
|
|
108
|
+
const [hover, setHover] = React.useState(false)
|
|
109
|
+
const [focused, setFocused] = React.useState(false)
|
|
110
|
+
const timerRef = React.useRef(null)
|
|
188
111
|
|
|
189
|
-
React.useEffect(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
dialog.showModal()
|
|
196
|
-
} catch {
|
|
197
|
-
/* 已经在文档里打开时忽略 */
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
dialog.setAttribute('open', '')
|
|
202
|
-
}
|
|
203
|
-
return () => {
|
|
204
|
-
if (dialog.open) dialog.close()
|
|
205
|
-
}
|
|
206
|
-
}, [])
|
|
207
|
-
|
|
208
|
-
const close = () => {
|
|
209
|
-
if (busy) return
|
|
210
|
-
settleDelete()
|
|
211
|
-
}
|
|
112
|
+
React.useEffect(
|
|
113
|
+
() => () => {
|
|
114
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current)
|
|
115
|
+
},
|
|
116
|
+
[]
|
|
117
|
+
)
|
|
212
118
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (!request.runnerSessionId) {
|
|
216
|
-
setOutcome({ kind: 'error', text: t('error.noRunner') })
|
|
217
|
-
return
|
|
218
|
-
}
|
|
119
|
+
/** 执行删除。 */
|
|
120
|
+
const run = async () => {
|
|
219
121
|
const remote = ctxRef?.get?.('remote') ?? ctxRef?.remote
|
|
220
122
|
if (!remote?.commands?.execute) {
|
|
221
|
-
|
|
123
|
+
setPhase('failed')
|
|
124
|
+
setReason(translate('error.noRemote'))
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
const runner = mainViewSessionId(sessionState, sessionId)
|
|
128
|
+
if (!runner) {
|
|
129
|
+
setPhase('failed')
|
|
130
|
+
setReason(translate('error.noRunner'))
|
|
222
131
|
return
|
|
223
132
|
}
|
|
224
|
-
|
|
225
|
-
setOutcome(null)
|
|
133
|
+
setPhase('busy')
|
|
226
134
|
try {
|
|
227
|
-
const result = await remote.commands.execute(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
} else if (result.value === undefined) {
|
|
237
|
-
setOutcome({ kind: 'error', text: t('error.unknownCommand') })
|
|
135
|
+
const result = await remote.commands.execute(runner, `/session-del delete ${String(sessionId)}`, [])
|
|
136
|
+
const outcome = readResult(result, translate)
|
|
137
|
+
if (outcome.ok) {
|
|
138
|
+
setPhase('done')
|
|
139
|
+
setReason('')
|
|
140
|
+
timerRef.current = setTimeout(() => {
|
|
141
|
+
timerRef.current = null
|
|
142
|
+
setMenuOpen(false)
|
|
143
|
+
}, 1200)
|
|
238
144
|
} else {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
kind: execution.kind === 'success' ? 'success' : 'error',
|
|
242
|
-
text: String(execution.text ?? ''),
|
|
243
|
-
})
|
|
145
|
+
setPhase('failed')
|
|
146
|
+
setReason(outcome.text || 'error')
|
|
244
147
|
}
|
|
245
148
|
} catch (error) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
setBusy(false)
|
|
149
|
+
setPhase('failed')
|
|
150
|
+
setReason(String(error?.message ?? error))
|
|
249
151
|
}
|
|
250
152
|
}
|
|
251
153
|
|
|
252
|
-
const
|
|
253
|
-
|
|
154
|
+
const label =
|
|
155
|
+
phase === 'confirm'
|
|
156
|
+
? translate('menu.confirm')
|
|
157
|
+
: phase === 'busy'
|
|
158
|
+
? translate('menu.busy')
|
|
159
|
+
: phase === 'done'
|
|
160
|
+
? translate('menu.done')
|
|
161
|
+
: phase === 'failed'
|
|
162
|
+
? translate('menu.failed', { reason })
|
|
163
|
+
: translate('menu.delete')
|
|
164
|
+
|
|
165
|
+
const danger = phase === 'confirm' || phase === 'failed'
|
|
166
|
+
const busy = phase === 'busy'
|
|
167
|
+
|
|
168
|
+
const style = {
|
|
169
|
+
display: 'flex',
|
|
170
|
+
alignItems: 'center',
|
|
171
|
+
gap: 8,
|
|
172
|
+
boxSizing: 'border-box',
|
|
173
|
+
width: '100%',
|
|
174
|
+
minWidth: 0,
|
|
175
|
+
height: 28,
|
|
176
|
+
padding: '0 8px',
|
|
177
|
+
margin: 0,
|
|
178
|
+
border: 0,
|
|
179
|
+
borderRadius: 6,
|
|
180
|
+
background: hover && !busy ? 'color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent)' : 'transparent',
|
|
181
|
+
color: danger ? 'var(--dsw-alias-state-error-primary)' : 'var(--dsw-alias-label-primary)',
|
|
182
|
+
fontFamily: 'inherit',
|
|
183
|
+
fontSize: 13,
|
|
184
|
+
fontWeight: 400,
|
|
185
|
+
lineHeight: '18px',
|
|
186
|
+
textAlign: 'left',
|
|
187
|
+
cursor: busy ? 'default' : 'pointer',
|
|
188
|
+
opacity: busy ? 0.6 : 1,
|
|
189
|
+
outline: focused ? 'var(--dsw-focus-ring-width, 2px) solid var(--dsw-alias-brand-primary)' : 'none',
|
|
190
|
+
outlineOffset: focused ? -2 : 0,
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const labelStyle = {
|
|
194
|
+
minWidth: 0,
|
|
195
|
+
overflow: 'hidden',
|
|
196
|
+
whiteSpace: 'nowrap',
|
|
197
|
+
textOverflow: 'ellipsis',
|
|
198
|
+
}
|
|
254
199
|
|
|
255
200
|
return h(
|
|
256
|
-
'
|
|
201
|
+
'button',
|
|
257
202
|
{
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
203
|
+
type: 'button',
|
|
204
|
+
role: 'menuitem',
|
|
205
|
+
style,
|
|
206
|
+
title: [displayTitle, phase === 'failed' ? reason : undefined].filter(Boolean).join(' — ') || undefined,
|
|
207
|
+
disabled: busy,
|
|
208
|
+
'aria-label': translate('menu.delete'),
|
|
209
|
+
onMouseEnter: () => setHover(true),
|
|
210
|
+
onMouseLeave: () => setHover(false),
|
|
211
|
+
onFocus: () => setFocused(true),
|
|
212
|
+
onBlur: () => setFocused(false),
|
|
213
|
+
onClick: () => {
|
|
214
|
+
if (phase === 'idle') {
|
|
215
|
+
setPhase('confirm')
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
if (phase === 'confirm' || phase === 'failed') {
|
|
219
|
+
void run()
|
|
220
|
+
}
|
|
267
221
|
},
|
|
268
222
|
},
|
|
269
|
-
h(
|
|
270
|
-
|
|
271
|
-
{ className: 'sd-dialog-body' },
|
|
272
|
-
h('div', { className: 'sd-dialog-title', key: 'title' }, t('dialog.title')),
|
|
273
|
-
h('p', { className: 'sd-dialog-desc', key: 'desc' }, t('dialog.desc', { title })),
|
|
274
|
-
h('p', { className: 'sd-dialog-note', key: 'note' }, t('dialog.note')),
|
|
275
|
-
busy ? h('div', { className: 'sd-dialog-status', key: 'status', role: 'status' }, t('dialog.working')) : null,
|
|
276
|
-
outcome
|
|
277
|
-
? h(
|
|
278
|
-
'div',
|
|
279
|
-
{
|
|
280
|
-
className: `sd-dialog-result ${succeeded ? 'sd-ok' : 'sd-err'}`,
|
|
281
|
-
key: 'result',
|
|
282
|
-
role: 'alert',
|
|
283
|
-
},
|
|
284
|
-
outcome.text
|
|
285
|
-
)
|
|
286
|
-
: null
|
|
287
|
-
),
|
|
288
|
-
h(
|
|
289
|
-
'div',
|
|
290
|
-
{ className: 'sd-dialog-footer' },
|
|
291
|
-
succeeded
|
|
292
|
-
? h('button', { type: 'button', className: 'sd-btn', onClick: () => window.location.reload() }, t('reload'))
|
|
293
|
-
: h('button', { type: 'button', className: 'sd-btn', disabled: busy, onClick: close }, t('cancel')),
|
|
294
|
-
succeeded
|
|
295
|
-
? h('button', { type: 'button', className: 'sd-btn', onClick: close }, t('done'))
|
|
296
|
-
: h(
|
|
297
|
-
'button',
|
|
298
|
-
{ type: 'button', className: 'sd-btn sd-danger', disabled: busy, onClick: confirm },
|
|
299
|
-
t('confirm')
|
|
300
|
-
)
|
|
301
|
-
)
|
|
223
|
+
h('span', { key: 'icon', style: { display: 'inline-flex', flex: 'none', width: 14, height: 14 } }, TrashIcon()),
|
|
224
|
+
h('span', { key: 'label', style: labelStyle }, label)
|
|
302
225
|
)
|
|
303
226
|
}
|
|
304
227
|
|
|
305
|
-
/**
|
|
306
|
-
const pendingDelete = createStore(null)
|
|
307
|
-
/** 当前 client 上下文(供确认框按需取用 ctx.remote)。 */
|
|
228
|
+
/** 当前 client 上下文(供点击时按需取用 ctx.remote)。 */
|
|
308
229
|
let ctxRef = null
|
|
309
230
|
|
|
310
231
|
return {
|
|
@@ -313,11 +234,6 @@ window.__ModuleLoader__.load({
|
|
|
313
234
|
ctxRef = ctx
|
|
314
235
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'session_del: dictionaries')
|
|
315
236
|
|
|
316
|
-
/** 打开一次确认。 */
|
|
317
|
-
const requestDelete = (request) => {
|
|
318
|
-
pendingDelete.set({ ...request, at: Date.now() })
|
|
319
|
-
}
|
|
320
|
-
|
|
321
237
|
ctx.slots.inject('sidebar.workspaces.session.menu.item', () =>
|
|
322
238
|
ctx.slots.register(
|
|
323
239
|
{
|
|
@@ -325,27 +241,10 @@ window.__ModuleLoader__.load({
|
|
|
325
241
|
id: 'session_del',
|
|
326
242
|
order: 600,
|
|
327
243
|
locale: NS,
|
|
328
|
-
inject: () => ({ requestDelete }),
|
|
329
244
|
},
|
|
330
245
|
DeleteMenuItem
|
|
331
246
|
)
|
|
332
247
|
)
|
|
333
|
-
|
|
334
|
-
ctx.slots.inject('shell.overlay', () =>
|
|
335
|
-
ctx.slots.register(
|
|
336
|
-
{
|
|
337
|
-
name: 'shell.overlay',
|
|
338
|
-
id: 'session_del.confirm',
|
|
339
|
-
order: 600,
|
|
340
|
-
locale: NS,
|
|
341
|
-
inject: () => ({
|
|
342
|
-
hooks: { pendingDelete },
|
|
343
|
-
settleDelete: () => pendingDelete.set(null),
|
|
344
|
-
}),
|
|
345
|
-
},
|
|
346
|
-
DeleteOverlay
|
|
347
|
-
)
|
|
348
|
-
)
|
|
349
248
|
},
|
|
350
249
|
}
|
|
351
250
|
},
|
package/package.json
CHANGED