agent-loft 0.2.66 → 0.2.68
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 +5 -3
- package/package.json +1 -1
- package/src/channels/web/api.ts +35 -13
- package/src/channels/web/conv-pages.ts +1 -1
- package/src/channels/web/experts-api.ts +12 -4
- package/src/core/experts.ts +3 -3
- package/src/core/hub.ts +34 -6
- package/src/core/servers.ts +5 -3
- package/src/core/task-runner.ts +4 -4
- package/src/core/ui-prefs.ts +3 -3
- package/src/core/users.ts +32 -8
- package/web/css/settings.css +26 -0
- package/web/css/sidebar.css +43 -1
- package/web/lib/overlay.js +6 -9
- package/web/settings/agents.js +2 -1
- package/web/settings/security.js +11 -2
- package/web/settings/users.js +56 -4
- package/web/views/conv-actions.js +3 -6
- package/web/views/experts.js +5 -1
- package/web/views/layout.js +12 -15
- package/web/views/sidebar-nav.js +0 -4
- package/web/views/sidebar.js +154 -91
- package/web/views/topbar.js +1 -1
package/web/css/sidebar.css
CHANGED
|
@@ -201,7 +201,7 @@ button.conv-group:hover {
|
|
|
201
201
|
color: var(--fg);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
/*
|
|
204
|
+
/* 项目 / 飞书分组拖动排序:被拖的行变淡,落点处画一条横线 */
|
|
205
205
|
.proj-row.dragging {
|
|
206
206
|
opacity: 0.4;
|
|
207
207
|
}
|
|
@@ -255,6 +255,40 @@ button.conv-group:hover {
|
|
|
255
255
|
display: grid;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/* 飞书分组的同一位置:平时显示飞书,悬停或键盘聚焦时显示新建加号。 */
|
|
259
|
+
.bot-row .conv-item.proj {
|
|
260
|
+
padding-right: 36px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.bot-new {
|
|
264
|
+
display: grid;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.bot-new .feishu-mark,
|
|
268
|
+
.bot-new .bot-plus {
|
|
269
|
+
grid-area: 1 / 1;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.bot-new .feishu-mark,
|
|
273
|
+
.bot-new .feishu-mark svg {
|
|
274
|
+
width: 14px;
|
|
275
|
+
height: 14px;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.bot-new .bot-plus {
|
|
279
|
+
visibility: hidden;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.bot-row:hover .bot-new .feishu-mark,
|
|
283
|
+
.bot-row:focus-within .bot-new .feishu-mark {
|
|
284
|
+
visibility: hidden;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.bot-row:hover .bot-new .bot-plus,
|
|
288
|
+
.bot-row:focus-within .bot-new .bot-plus {
|
|
289
|
+
visibility: visible;
|
|
290
|
+
}
|
|
291
|
+
|
|
258
292
|
/* 鼠标挪到右边的加号上时,整行的 hover 底色还留着 */
|
|
259
293
|
.proj-row:hover .conv-item.proj {
|
|
260
294
|
padding-right: 36px;
|
|
@@ -266,6 +300,14 @@ button.conv-group:hover {
|
|
|
266
300
|
.proj-new {
|
|
267
301
|
display: grid;
|
|
268
302
|
}
|
|
303
|
+
|
|
304
|
+
.bot-new .bot-plus {
|
|
305
|
+
visibility: visible;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.bot-new .feishu-mark {
|
|
309
|
+
visibility: hidden;
|
|
310
|
+
}
|
|
269
311
|
}
|
|
270
312
|
|
|
271
313
|
.conv-item {
|
package/web/lib/overlay.js
CHANGED
|
@@ -54,7 +54,7 @@ export function closeMenu() {
|
|
|
54
54
|
removeEventListener("blur", closeMenu);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
/** beforeClose:点 ×
|
|
57
|
+
/** 弹窗只通过按钮关闭,点击遮罩不关闭。beforeClose:点 × 前先问它,false 就不关。返回的 close 直接关 */
|
|
58
58
|
export function modal({ title, body, foot, wide, tall, className = "", beforeClose }) {
|
|
59
59
|
const close = () => overlay.remove();
|
|
60
60
|
const tryClose = async () => {
|
|
@@ -62,11 +62,11 @@ export function modal({ title, body, foot, wide, tall, className = "", beforeClo
|
|
|
62
62
|
};
|
|
63
63
|
const overlay = h(
|
|
64
64
|
"div",
|
|
65
|
-
{ class: "overlay"
|
|
65
|
+
{ class: "overlay" },
|
|
66
66
|
h(
|
|
67
67
|
"div",
|
|
68
68
|
{ class: `modal${wide ? " wide" : ""}${tall ? " tall" : ""}${className ? ` ${className}` : ""}` },
|
|
69
|
-
h("div", { class: "modal-head" }, h("h3", {}, title), h("button", { class: "icon-btn", onclick: () => void tryClose() }, icon("x"))),
|
|
69
|
+
h("div", { class: "modal-head" }, h("h3", {}, title), h("button", { class: "icon-btn", "aria-label": "关闭", onclick: () => void tryClose() }, icon("x"))),
|
|
70
70
|
body,
|
|
71
71
|
foot ?? null,
|
|
72
72
|
),
|
|
@@ -110,7 +110,7 @@ export function placePopover(pop, anchor) {
|
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* 确认弹窗(替代浏览器自带的 confirm),样式和重命名弹窗一致。
|
|
113
|
-
*
|
|
113
|
+
* 回车确认,点击取消按钮取消;resolve 成 true / false
|
|
114
114
|
*/
|
|
115
115
|
/** altText:给了就多一个按钮,点它返回 "alt"(确定返回 true,取消返回 false) */
|
|
116
116
|
export function confirmDialog({ title, message, sub, confirmText = "确定", danger = false, altText }) {
|
|
@@ -125,10 +125,7 @@ export function confirmDialog({ title, message, sub, confirmText = "确定", dan
|
|
|
125
125
|
resolve(v);
|
|
126
126
|
};
|
|
127
127
|
const onKey = (e) => {
|
|
128
|
-
if (e.key === "
|
|
129
|
-
e.preventDefault();
|
|
130
|
-
done(false);
|
|
131
|
-
} else if (e.key === "Enter" && !e.isComposing) {
|
|
128
|
+
if (e.key === "Enter" && !e.isComposing) {
|
|
132
129
|
e.preventDefault();
|
|
133
130
|
done(true);
|
|
134
131
|
}
|
|
@@ -137,7 +134,7 @@ export function confirmDialog({ title, message, sub, confirmText = "确定", dan
|
|
|
137
134
|
cancel.onclick = () => done(false);
|
|
138
135
|
const overlay = h(
|
|
139
136
|
"div",
|
|
140
|
-
{ class: "overlay dialog-overlay"
|
|
137
|
+
{ class: "overlay dialog-overlay" },
|
|
141
138
|
h(
|
|
142
139
|
"div",
|
|
143
140
|
{ class: "dialog confirm-dialog" },
|
package/web/settings/agents.js
CHANGED
|
@@ -183,7 +183,7 @@ function builtinDefaultsSection() {
|
|
|
183
183
|
sync();
|
|
184
184
|
return { el: h("div", { class: "field" }, h("span", {}, label), mode, list), value: () => mode.value === "inherit" ? null : inputs.filter((x) => x.input.checked).map((x) => x.id) };
|
|
185
185
|
};
|
|
186
|
-
const panels = ["claude", "codex"].map((engine) => {
|
|
186
|
+
const panels = ["claude", "codex"].filter((engine) => data.agents[engine]).map((engine) => {
|
|
187
187
|
const label = engine === "claude" ? "Claude Code" : "Codex";
|
|
188
188
|
const prefs = data.agents[engine];
|
|
189
189
|
const skills = picker(`${label} 技能`, data.skills, prefs.skills, "全部已启用的个人技能(含以后新增)");
|
|
@@ -198,6 +198,7 @@ function builtinDefaultsSection() {
|
|
|
198
198
|
fill(section, h("h4", {}, "内置 Agent 默认加载"),
|
|
199
199
|
h("p", { class: "skill-note" }, "仅影响你当前账号使用的内置 Agent;自定义专家继续使用各自的配置。保存后,下次发消息生效,正在执行的任务不受影响。"),
|
|
200
200
|
...panels,
|
|
201
|
+
!panels.length ? h("p", { class: "muted" }, "没有获授权的内置 Agent,请联系管理员配置使用权限。") : null,
|
|
201
202
|
h("small", {}, "技能和 MCP 可分别全部取消。记忆、定时任务、技能管理等系统工具仍按功能设置提供。"),
|
|
202
203
|
h("div", { class: "row" }, saveButton(async () => {
|
|
203
204
|
const agents = Object.fromEntries(Object.entries(choices).map(([engine, c]) => [engine, { skills: c.skills.value(), machineSkills: c.machineSkills.checked, mcp: c.mcp.value() }]));
|
package/web/settings/security.js
CHANGED
|
@@ -23,11 +23,13 @@ export async function accountTab(page) {
|
|
|
23
23
|
};
|
|
24
24
|
const old = h("input", { type: "password", autocomplete: "current-password" });
|
|
25
25
|
const pw = h("input", { type: "password", autocomplete: "new-password" });
|
|
26
|
+
const name = h("input", { value: S.user?.name ?? "", autocomplete: "username", autocapitalize: "off", spellcheck: "false", maxlength: "32" });
|
|
27
|
+
const currentName = h("span", {}, S.user?.name ?? "");
|
|
26
28
|
const devicesBox = h("div", { class: "section" }, h("h4", {}, "已登录的设备"), h("span", { class: "spinner" }));
|
|
27
29
|
page.append(
|
|
28
30
|
h(
|
|
29
31
|
"div",
|
|
30
|
-
{ class: "section" },
|
|
32
|
+
{ class: "section", "data-form": "" },
|
|
31
33
|
h(
|
|
32
34
|
"h4",
|
|
33
35
|
{},
|
|
@@ -35,7 +37,14 @@ export async function accountTab(page) {
|
|
|
35
37
|
h("span", { class: "grow" }),
|
|
36
38
|
logout,
|
|
37
39
|
),
|
|
38
|
-
S.user ? h("div", {},
|
|
40
|
+
S.user ? h("div", {}, currentName, " ", h("span", { class: "status-tag" }, S.user.role === "admin" ? "管理员" : "成员")) : null,
|
|
41
|
+
field("账号名称", name, "也是登录时使用的用户名。1~32 个字符,可用文字、数字和 _ . @ -;修改后请用新名称登录。"),
|
|
42
|
+
h("div", { class: "row" }, saveButton(async () => {
|
|
43
|
+
const data = await api("/api/account", { method: "PATCH", body: { name: name.value.trim() } });
|
|
44
|
+
S.user = data.user;
|
|
45
|
+
name.value = currentName.textContent = data.user.name;
|
|
46
|
+
toast("账号名称已修改");
|
|
47
|
+
}, "保存账号名称")),
|
|
39
48
|
),
|
|
40
49
|
h(
|
|
41
50
|
"div",
|
package/web/settings/users.js
CHANGED
|
@@ -6,6 +6,32 @@ import { field, saveButton } from "./common.js";
|
|
|
6
6
|
import { networkSection } from "./general.js";
|
|
7
7
|
import { deviceList } from "./security.js";
|
|
8
8
|
|
|
9
|
+
/** null 沿用全部;指定列表可以全部取消,新增资源不会自动加入。 */
|
|
10
|
+
function permissionFields(resources, permissions = {}) {
|
|
11
|
+
const pickers = {};
|
|
12
|
+
const el = h("div", { class: "user-permissions" });
|
|
13
|
+
for (const [kind, label] of [["experts", "共享专家"], ["agents", "内置 Agent"], ["servers", "服务器切换"]]) {
|
|
14
|
+
const selected = permissions[kind];
|
|
15
|
+
const items = resources?.[kind] ?? [];
|
|
16
|
+
const known = new Set(items.map((item) => item.id));
|
|
17
|
+
const missing = (selected ?? []).filter((id) => !known.has(id)).map((id) => ({ id, name: `${id}(暂不可用)` }));
|
|
18
|
+
const mode = h("select", { "aria-label": `${label}范围` },
|
|
19
|
+
h("option", { value: "all", selected: selected == null }, "全部允许(含以后新增)"),
|
|
20
|
+
h("option", { value: "pick", selected: selected != null }, "仅允许勾选项(可全部取消)"));
|
|
21
|
+
const inputs = [...items, ...missing].map((item) => ({ id: item.id, input: h("input", { type: "checkbox", checked: selected == null || selected.includes(item.id) }), name: item.name }));
|
|
22
|
+
const list = h("div", { class: "check-list" }, inputs.length
|
|
23
|
+
? inputs.map(({ input, name }) => h("label", { class: "check-item" }, input, h("span", {}, name)))
|
|
24
|
+
: h("small", {}, kind === "servers" ? "尚未添加其他服务器" : "暂无可选项"));
|
|
25
|
+
const sync = () => { list.hidden = mode.value !== "pick"; };
|
|
26
|
+
mode.onchange = sync;
|
|
27
|
+
sync();
|
|
28
|
+
pickers[kind] = () => mode.value === "all" ? null : inputs.filter((x) => x.input.checked).map((x) => x.id);
|
|
29
|
+
el.append(h("div", { class: "field" }, h("span", {}, label), mode, list));
|
|
30
|
+
}
|
|
31
|
+
el.append(h("small", {}, "自己创建的专家仍可使用。内置 Agent 权限只控制直接使用 Claude Code / Codex,不影响已获授权的专家。当前服务器保持可用;其他服务器仍需各自登录,由对应服务器管理账号权限。"));
|
|
32
|
+
return { el, value: () => Object.fromEntries(Object.entries(pickers).map(([kind, value]) => [kind, value()])) };
|
|
33
|
+
}
|
|
34
|
+
|
|
9
35
|
// ---------- 用户(管理员) ----------
|
|
10
36
|
|
|
11
37
|
export async function usersTab(page) {
|
|
@@ -34,6 +60,17 @@ export async function usersTab(page) {
|
|
|
34
60
|
};
|
|
35
61
|
const patch = (u, body) => api(`/api/users/${encodeURIComponent(u.id)}`, { method: "PATCH", body });
|
|
36
62
|
|
|
63
|
+
const permissionsRow = (u, holder) => {
|
|
64
|
+
const picker = permissionFields(data.resources, u.permissions);
|
|
65
|
+
const save = saveButton(async () => {
|
|
66
|
+
await patch(u, { permissions: picker.value() });
|
|
67
|
+
toast(`已更新「${u.name}」的使用权限`);
|
|
68
|
+
reload();
|
|
69
|
+
}, "保存使用权限");
|
|
70
|
+
fill(holder, h("div", { "data-form": "" }, h("h4", {}, "使用权限"), picker.el,
|
|
71
|
+
h("div", { class: "row" }, save, h("button", { class: "btn", onclick: () => fill(holder) }, "取消"))));
|
|
72
|
+
};
|
|
73
|
+
|
|
37
74
|
/** 重置密码:就地展开一个输入框 */
|
|
38
75
|
const resetRow = (u, holder) => {
|
|
39
76
|
const pw = h("input", { type: "password", autocomplete: "new-password", placeholder: "新密码(至少 8 位)" });
|
|
@@ -158,7 +195,8 @@ export async function usersTab(page) {
|
|
|
158
195
|
const extra = h("div");
|
|
159
196
|
return h(
|
|
160
197
|
"div",
|
|
161
|
-
{ class: "list-item" },
|
|
198
|
+
{ class: "list-item user-entry" },
|
|
199
|
+
h("div", { class: "user-entry-head" },
|
|
162
200
|
h(
|
|
163
201
|
"div",
|
|
164
202
|
{ class: "grow" },
|
|
@@ -173,9 +211,11 @@ export async function usersTab(page) {
|
|
|
173
211
|
u.role !== "admin" && u.remote ? h("span", { class: "status-tag" }, "远程控制") : null,
|
|
174
212
|
),
|
|
175
213
|
h("div", { class: "s" }, `创建于 ${relTime(u.createdAt)} · ${u.devices} 台设备已登录${u.feishuLinks ? ` · 绑定了 ${u.feishuLinks} 个飞书账号` : ""}`),
|
|
176
|
-
extra,
|
|
177
214
|
),
|
|
178
|
-
|
|
215
|
+
h("div", { class: "row" },
|
|
216
|
+
u.role !== "admin" ? h("button", { class: "btn small", onclick: () => permissionsRow(u, extra) }, "使用权限") : null,
|
|
217
|
+
actions(u, self, extra))),
|
|
218
|
+
extra,
|
|
179
219
|
);
|
|
180
220
|
}),
|
|
181
221
|
);
|
|
@@ -183,17 +223,29 @@ export async function usersTab(page) {
|
|
|
183
223
|
const name = h("input", { autocomplete: "off", autocapitalize: "off", spellcheck: "false", placeholder: "登录用的名字" });
|
|
184
224
|
const pw = h("input", { type: "password", autocomplete: "new-password", placeholder: "至少 8 位" });
|
|
185
225
|
const role = h("select", {}, h("option", { value: "member" }, "成员"), h("option", { value: "admin" }, "管理员"));
|
|
226
|
+
const permissions = permissionFields(data.resources);
|
|
227
|
+
const remote = h("input", { type: "checkbox" });
|
|
228
|
+
const memberOptions = h("div", { class: "user-permissions" }, permissions.el,
|
|
229
|
+
h("div", { class: "field" }, h("span", {}, "远程权限"), h("label", { class: "check-item" }, remote, h("span", {}, "允许使用终端和桌面"))));
|
|
230
|
+
role.onchange = () => { memberOptions.hidden = role.value === "admin"; };
|
|
186
231
|
fill(
|
|
187
232
|
addBox,
|
|
188
233
|
h("h4", {}, "添加用户"),
|
|
189
234
|
field("用户名", name),
|
|
190
235
|
field("密码", pw, "告诉对方,让他登录后在 设置 →「账号」里自己改掉"),
|
|
191
236
|
field("角色", role, "成员只能用自己的对话;管理员能改所有设置、管理用户"),
|
|
237
|
+
memberOptions,
|
|
192
238
|
h(
|
|
193
239
|
"div",
|
|
194
240
|
{ class: "row" },
|
|
195
241
|
saveButton(async () => {
|
|
196
|
-
|
|
242
|
+
if (role.value === "member" && remote.checked && !(await confirmDialog({
|
|
243
|
+
title: `给「${name.value.trim()}」开通远程控制?`,
|
|
244
|
+
message: "他能以运行 agent-loft 的系统用户直接使用终端和桌面,读写服务器上的文件、安装软件、停止服务,不经过授权卡。只开给完全信任的人。",
|
|
245
|
+
confirmText: "开通并添加", danger: true,
|
|
246
|
+
}))) return false;
|
|
247
|
+
await api("/api/users", { method: "POST", body: { name: name.value.trim(), password: pw.value, role: role.value,
|
|
248
|
+
...(role.value === "member" ? { remote: remote.checked, permissions: permissions.value() } : {}) } });
|
|
197
249
|
toast(`已添加「${name.value.trim()}」`);
|
|
198
250
|
// 先标成已保存再刷新,免得离开提醒
|
|
199
251
|
addBox.removeAttribute("data-dirty");
|
|
@@ -396,7 +396,7 @@ export async function changeCwd(pick) {
|
|
|
396
396
|
await load(startRel);
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
/**
|
|
399
|
+
/** 重命名:小弹窗,回车保存、按钮取消,打开时全选原名 */
|
|
400
400
|
export function renameConv(key = S.current) {
|
|
401
401
|
const c = S.convs.get(key);
|
|
402
402
|
if (!c) return;
|
|
@@ -424,10 +424,7 @@ export function renameConv(key = S.current) {
|
|
|
424
424
|
}
|
|
425
425
|
};
|
|
426
426
|
const onKey = (e) => {
|
|
427
|
-
if (e.key === "
|
|
428
|
-
e.preventDefault();
|
|
429
|
-
close();
|
|
430
|
-
} else if (e.key === "Enter" && !e.isComposing && document.activeElement === input) {
|
|
427
|
+
if (e.key === "Enter" && !e.isComposing && document.activeElement === input) {
|
|
431
428
|
e.preventDefault();
|
|
432
429
|
void submit();
|
|
433
430
|
}
|
|
@@ -436,7 +433,7 @@ export function renameConv(key = S.current) {
|
|
|
436
433
|
cancel.onclick = close;
|
|
437
434
|
const overlay = h(
|
|
438
435
|
"div",
|
|
439
|
-
{ class: "overlay dialog-overlay"
|
|
436
|
+
{ class: "overlay dialog-overlay" },
|
|
440
437
|
h(
|
|
441
438
|
"div",
|
|
442
439
|
{ class: "dialog" },
|
package/web/views/experts.js
CHANGED
|
@@ -2,6 +2,7 @@ import { agentIcon, h } from "../lib/dom.js";
|
|
|
2
2
|
import { api } from "../lib/api.js";
|
|
3
3
|
import { S } from "../state.js";
|
|
4
4
|
import { agentLabel } from "./sidebar.js";
|
|
5
|
+
import { applyShellInfo } from "../lib/shell.js";
|
|
5
6
|
|
|
6
7
|
// ---------- 专家:新对话、定时任务里选 ----------
|
|
7
8
|
// 内置专家就是能用的 agent(Claude Code / Codex),自定义专家在「设置 → 专家」里建。
|
|
@@ -18,7 +19,7 @@ function usableEngines() {
|
|
|
18
19
|
export function expertChoices() {
|
|
19
20
|
const engines = usableEngines();
|
|
20
21
|
return [
|
|
21
|
-
...engines.map((id) => ({ id, name: agentLabel(id), engine: id, builtin: true })),
|
|
22
|
+
...engines.filter((id) => S.agents.find((a) => a.id === id)?.allowed !== false).map((id) => ({ id, name: agentLabel(id), engine: id, builtin: true })),
|
|
22
23
|
...S.experts.filter((e) => engines.includes(e.engine)),
|
|
23
24
|
];
|
|
24
25
|
}
|
|
@@ -66,6 +67,9 @@ export async function reloadExperts() {
|
|
|
66
67
|
try {
|
|
67
68
|
const d = await api("/api/experts/brief");
|
|
68
69
|
S.experts = d.experts ?? [];
|
|
70
|
+
if (Array.isArray(d.builtin)) for (const a of S.agents) a.allowed = d.builtin.includes(a.id);
|
|
71
|
+
if (d.user) S.user = d.user;
|
|
72
|
+
if ("servers" in d) applyShellInfo(d.servers);
|
|
69
73
|
} catch {
|
|
70
74
|
// 拉不到就先用旧的
|
|
71
75
|
}
|
package/web/views/layout.js
CHANGED
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
bootstrapQuery,
|
|
9
9
|
closeSide,
|
|
10
10
|
marquee,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
botGroupId,
|
|
12
|
+
moveSidebarGroup,
|
|
13
|
+
sidebarGroups,
|
|
13
14
|
renderSidebar,
|
|
14
15
|
reportDesktop,
|
|
15
|
-
|
|
16
|
+
resetSidebarGroupOrder,
|
|
16
17
|
setSideWidth,
|
|
17
18
|
startMarquee,
|
|
18
19
|
startSideResize,
|
|
@@ -232,23 +233,19 @@ function renderLayout() {
|
|
|
232
233
|
lastDown = { key, at: now };
|
|
233
234
|
});
|
|
234
235
|
ui.convList.addEventListener("contextmenu", (e) => {
|
|
235
|
-
//
|
|
236
|
+
// 项目和飞书共用移动菜单;触屏也可以通过长按调整混合顺序。
|
|
236
237
|
const bot = e.target.closest?.("[data-bot]")?.dataset.bot;
|
|
237
|
-
if (bot) {
|
|
238
|
-
e.preventDefault();
|
|
239
|
-
showMenu({ x: e.clientX, y: e.clientY }, [{ label: "历史会话…", onclick: () => openBotConversations(bot) }]);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
// 项目目录那一行:调整顺序(触屏上拖不动,靠这个菜单)
|
|
243
238
|
const dir = e.target.closest?.("[data-dir]")?.dataset.dir;
|
|
244
|
-
|
|
245
|
-
|
|
239
|
+
const group = bot ? botGroupId(bot) : dir;
|
|
240
|
+
if (group) {
|
|
241
|
+
const i = sidebarGroups.indexOf(group);
|
|
246
242
|
const moves = [
|
|
247
|
-
...(i > 0 ? [{ label: "置顶", onclick: () =>
|
|
248
|
-
...(i >= 0 && i <
|
|
243
|
+
...(i > 0 ? [{ label: "置顶", onclick: () => moveSidebarGroup(group, null) }, { label: "上移", onclick: () => moveSidebarGroup(group, sidebarGroups[i - 1]) }] : []),
|
|
244
|
+
...(i >= 0 && i < sidebarGroups.length - 1 ? [{ label: "下移", onclick: () => moveSidebarGroup(group, sidebarGroups[i + 1], true) }] : []),
|
|
249
245
|
];
|
|
250
|
-
const reset =
|
|
246
|
+
const reset = sidebarGroups.length > 1 ? [{ label: "按最近活跃重排", onclick: resetSidebarGroupOrder }] : [];
|
|
251
247
|
const items = moves.length && reset.length ? [...moves, "sep", ...reset] : [...moves, ...reset];
|
|
248
|
+
if (bot) items.push(...(items.length ? ["sep"] : []), { label: "历史会话…", onclick: () => openBotConversations(bot) });
|
|
252
249
|
if (!items.length) return;
|
|
253
250
|
e.preventDefault();
|
|
254
251
|
showMenu({ x: e.clientX, y: e.clientY }, items);
|
package/web/views/sidebar-nav.js
CHANGED