dsh-multipane 1.0.3 → 1.0.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/lib/client.js +317 -14
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -971,6 +971,10 @@ window.__ModuleLoader__.load({
|
|
|
971
971
|
.dsv-paneheader[data-drop="1"]{outline:var(--dsv-line-w,2px) dashed var(--dsv-line,#a7aaaf);outline-offset:calc(-1 * var(--dsv-line-w,2px))}
|
|
972
972
|
.dsv-panes{display:flex;flex-direction:row;flex:1 1 auto;min-width:0;min-height:0;overflow:hidden}
|
|
973
973
|
.dsv-pane{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;overflow:hidden;background:var(--dsh-surface-color,transparent);padding-top:calc(var(--dsv-head-h,45px) - var(--dsv-host-offset,0px))}
|
|
974
|
+
/* 拖文件时目标栏的高亮。宿主那个全屏「拖到此处添加」遮罩在多栏下会盖住其它栏、
|
|
975
|
+
让人根本没法选目标栏,所以拖动期间不渲染宿主附件组件,改用这一圈边 + 淡淡底色。 */
|
|
976
|
+
.dsv-pane[data-drop-target="1"]{outline:2px solid var(--dsv-tab-accent,#4a8cf7);outline-offset:-2px}
|
|
977
|
+
.dsv-pane[data-drop-target="1"]::after{content:"";position:absolute;inset:0;z-index:4;pointer-events:none;background:color-mix(in srgb,var(--dsv-tab-accent,#4a8cf7) 8%,transparent)}
|
|
974
978
|
.dsv-pane[data-drop="1"]{outline:var(--dsv-line-w,2px) dashed var(--dsv-line,#a7aaaf);outline-offset:calc(-1 * var(--dsv-line-w,2px))}
|
|
975
979
|
.dsv-pane[data-focus="1"] .dsv-tab[data-active="1"]{background:var(--dsh-surface-raised-color,rgba(128,128,128,.14))}
|
|
976
980
|
.dsv-pane[data-drop-side="left"]{box-shadow:inset var(--dsv-line-w,2px) 0 0 var(--dsv-line,#a7aaaf)}
|
|
@@ -2334,6 +2338,222 @@ window.__ModuleLoader__.load({
|
|
|
2334
2338
|
delete pane.dataset.drop;
|
|
2335
2339
|
}
|
|
2336
2340
|
|
|
2341
|
+
/**
|
|
2342
|
+
* 侧栏折叠时,标签条左侧必须让出的宿主控件宽度。
|
|
2343
|
+
*
|
|
2344
|
+
* 窗口最顶那一行(y=0~40)左侧是宿主自己画的 caption 控件:「收起/展开侧边栏」按钮、
|
|
2345
|
+
* 折叠时才出现的「新建会话」,以及 Desktop preload 注入的应用菜单
|
|
2346
|
+
* (`[data-windows-menu]`,shadow DOM,`left: var(--dsh-windows-menu-start)`,
|
|
2347
|
+
* 展开 48px / 折叠 84px)。标签条是 `position:fixed` + `z-index:60` 贴在最顶端那一行,
|
|
2348
|
+
* 侧栏一折叠,栏就贴到窗口左缘(left=0),整条铺过去会把它们压在底下——看不见也点不到。
|
|
2349
|
+
*
|
|
2350
|
+
* 让出的宽度按宿主元素实时量,不写常数(宿主换布局、改菜单起点时自动跟随)。
|
|
2351
|
+
* 竖排模式(`.dsv-panes[data-narrow="1"]`)下 header 回到 static、不再覆盖那一行,返回 0。
|
|
2352
|
+
*
|
|
2353
|
+
* @param paneEl - 当前栏的根元素
|
|
2354
|
+
* @returns 需要右移并收窄的像素数;侧栏展开或竖排时返回 0
|
|
2355
|
+
*/
|
|
2356
|
+
function paneLeftGuard(paneEl) {
|
|
2357
|
+
const panes = document.querySelector(".dsv-panes");
|
|
2358
|
+
if (panes !== null && panes.getAttribute("data-narrow") === "1") return 0;
|
|
2359
|
+
const rect = paneEl === null || paneEl === void 0 ? null : paneEl.getBoundingClientRect();
|
|
2360
|
+
if (rect === null || !(rect.left <= 8)) return 0;
|
|
2361
|
+
const menu = document.querySelector("[data-windows-menu]");
|
|
2362
|
+
if (menu === null) return 0;
|
|
2363
|
+
return Math.max(0, Math.round(menu.getBoundingClientRect().right) + 8 - rect.left);
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
/* ===== 拖放定向:只让「指针所在那一栏」的 composer 接住掉进来的文件 =====
|
|
2367
|
+
*
|
|
2368
|
+
* 宿主的 ComposerAttachments 每渲染一个实例就往 document 上装一套 dragenter/drop
|
|
2369
|
+
* 监听器,而它的 canAcceptDrop 只看会话自身状态
|
|
2370
|
+
* (!uploadDenied && (subagent===null||continuable) && !locked && !machineBusy && addFiles!==undefined),
|
|
2371
|
+
* 完全不看这一栏是不是用户要放的那一栏。多栏并排时一次 drop 会被 N 个 composer
|
|
2372
|
+
* 全部接住 → 每个栏的草稿里都出现同一个文件。
|
|
2373
|
+
*
|
|
2374
|
+
* 这里注册宿主的 `conversation.input.attachments` 槽位(kind:single,可被插件覆盖),
|
|
2375
|
+
* 拖动期间只让落点所在栏渲染宿主原组件,其余栏返回 null —— 它们连监听器都不会装。
|
|
2376
|
+
* 拿不到宿主原组件时(宿主升级改了槽位形状)不注册,行为退回宿主默认,不会更差。 */
|
|
2377
|
+
|
|
2378
|
+
/** 拖动期间落点所在栏的 id;null = 当前没有拖动。 */
|
|
2379
|
+
let DROP_PANE_ID = null;
|
|
2380
|
+
/** 是否正在拖文件(决定「宿主附件组件要不要卸载」和「栏高亮」)。 */
|
|
2381
|
+
let DRAG_ACTIVE = false;
|
|
2382
|
+
/** 落点变化的订阅者(槽位组件用它触发重渲染)。 */
|
|
2383
|
+
const DROP_SUBSCRIBERS = new Set();
|
|
2384
|
+
/** paneId → 该栏 composer 的 onAddFiles(宿主组件卸载前记下来,drop 时直接调)。 */
|
|
2385
|
+
const PANE_INTAKE = new Map();
|
|
2386
|
+
/** 宿主原来的附件组件(覆盖槽位前从注册表里取出来的引用)。 */
|
|
2387
|
+
let HOST_ATTACHMENTS = null;
|
|
2388
|
+
/** 宿主那份注册的注入值(`readFileDrag` 等)—— 直接调用宿主组件的 inject,免得到处找服务。 */
|
|
2389
|
+
let HOST_ATTACH_INJECT = {};
|
|
2390
|
+
|
|
2391
|
+
/** 当前组件树属于哪一栏(Pane 渲染内容时用 Provider 注入)。 */
|
|
2392
|
+
const PaneIdCtx = react.createContext(null);
|
|
2393
|
+
|
|
2394
|
+
/** 通知所有订阅者(槽位组件重渲染)。 */
|
|
2395
|
+
function notifyDropSubscribers() {
|
|
2396
|
+
for (const fn of [...DROP_SUBSCRIBERS]) {
|
|
2397
|
+
try {
|
|
2398
|
+
fn();
|
|
2399
|
+
} catch {
|
|
2400
|
+
/* 单个订阅者出错不影响别的 */
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* 开关「正在拖文件」。
|
|
2407
|
+
*
|
|
2408
|
+
* 它和「落点在哪一栏」必须分开:拖到侧栏 / 底栏时落点是 none,但仍然要算「正在拖」,
|
|
2409
|
+
* 否则宿主附件组件会被重新渲染回来、重新装上 document 监听器,文件又会被接受。
|
|
2410
|
+
*/
|
|
2411
|
+
function setDragActiveFlag(active) {
|
|
2412
|
+
if (DRAG_ACTIVE === active) return;
|
|
2413
|
+
DRAG_ACTIVE = active;
|
|
2414
|
+
if (active !== true) setDropPaneTarget(null);
|
|
2415
|
+
else notifyDropSubscribers();
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
/** 设置落点栏并打高亮标记(null = 不在任何栏内,清掉全部高亮)。 */
|
|
2419
|
+
function setDropPaneTarget(paneId) {
|
|
2420
|
+
if (DROP_PANE_ID === paneId) return;
|
|
2421
|
+
DROP_PANE_ID = paneId;
|
|
2422
|
+
for (const pane of document.querySelectorAll(".dsv-pane")) {
|
|
2423
|
+
if (paneId !== null && pane.getAttribute("data-pane-id") === paneId) pane.setAttribute("data-drop-target", "1");
|
|
2424
|
+
else pane.removeAttribute("data-drop-target");
|
|
2425
|
+
}
|
|
2426
|
+
notifyDropSubscribers();
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
/** 指针坐标落在哪个 .dsv-pane 上;不在任何栏上返回 null。 */
|
|
2430
|
+
function paneIdAt(x, y) {
|
|
2431
|
+
const el = document.elementFromPoint(x, y);
|
|
2432
|
+
if (el === null || el === void 0 || typeof el.closest !== "function") return null;
|
|
2433
|
+
const pane = el.closest(".dsv-pane");
|
|
2434
|
+
return pane === null ? null : pane.getAttribute("data-pane-id");
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
/** 焦点栏的 id(drop 落在栏外时兜底用它)。 */
|
|
2438
|
+
function focusedPaneId() {
|
|
2439
|
+
const pane = document.querySelector('.dsv-pane[data-focus="1"]');
|
|
2440
|
+
return pane === null ? null : pane.getAttribute("data-pane-id");
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
/** 事件是不是「外部拖进来的文件」。 */
|
|
2444
|
+
function isFileDrag(event) {
|
|
2445
|
+
const dt = event.dataTransfer;
|
|
2446
|
+
if (dt === null || dt === void 0 || dt.types === void 0) return false;
|
|
2447
|
+
return dt.types.includes("Files") || dt.types.includes("application/x-dsh-file");
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
/**
|
|
2451
|
+
* 在 document 捕获阶段接管整条文件拖放链。
|
|
2452
|
+
*
|
|
2453
|
+
* 为什么必须在捕获阶段、且自己派发:宿主的附件组件是「每个 composer 一套 document
|
|
2454
|
+
* 监听器,canAcceptDrop 只看会话自身状态、不看焦点」,多栏下一次 drop 会被 N 栏全接住。
|
|
2455
|
+
* 拖动一开始就把宿主组件全部卸载(见 SplitAttachmentsSlot),这里负责
|
|
2456
|
+
* ① 跟踪落点并高亮目标栏 ② drop 时只把文件交给落点那一栏的 composer。
|
|
2457
|
+
*/
|
|
2458
|
+
function installDropPaneTracking() {
|
|
2459
|
+
const onEnter = (event) => {
|
|
2460
|
+
if (!isFileDrag(event)) return;
|
|
2461
|
+
/* 只要带文件进窗口就算「正在拖」—— 先卸载宿主附件组件(连带它的全屏遮罩),
|
|
2462
|
+
再看落点在哪一栏。 */
|
|
2463
|
+
setDragActiveFlag(true);
|
|
2464
|
+
setDropPaneTarget(paneIdAt(event.clientX, event.clientY));
|
|
2465
|
+
};
|
|
2466
|
+
const onOver = (event) => {
|
|
2467
|
+
if (!isFileDrag(event)) return;
|
|
2468
|
+
const paneId = paneIdAt(event.clientX, event.clientY);
|
|
2469
|
+
if (paneId === null) {
|
|
2470
|
+
/* 侧栏 / 底栏 / 顶部标题栏这些地方**不接受投放**:
|
|
2471
|
+
不 preventDefault → 浏览器判定这里不是合法投放区(光标显示禁止),
|
|
2472
|
+
drop 根本不会发生。但仍然保持 DRAG_ACTIVE,别让宿主组件回魂。 */
|
|
2473
|
+
if (event.dataTransfer !== null && event.dataTransfer !== void 0) event.dataTransfer.dropEffect = "none";
|
|
2474
|
+
setDropPaneTarget(null);
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
event.preventDefault();
|
|
2478
|
+
if (event.dataTransfer !== null && event.dataTransfer !== void 0) event.dataTransfer.dropEffect = "copy";
|
|
2479
|
+
setDragActiveFlag(true);
|
|
2480
|
+
setDropPaneTarget(paneId);
|
|
2481
|
+
};
|
|
2482
|
+
const onLeave = (event) => {
|
|
2483
|
+
const out =
|
|
2484
|
+
event.clientX <= 0 ||
|
|
2485
|
+
event.clientY <= 0 ||
|
|
2486
|
+
event.clientX >= window.innerWidth ||
|
|
2487
|
+
event.clientY >= window.innerHeight;
|
|
2488
|
+
if (out) setDragActiveFlag(false);
|
|
2489
|
+
};
|
|
2490
|
+
const onEnd = () => setDragActiveFlag(false);
|
|
2491
|
+
const onDrop = (event) => {
|
|
2492
|
+
if (!isFileDrag(event)) return;
|
|
2493
|
+
const paneId = paneIdAt(event.clientX, event.clientY);
|
|
2494
|
+
const files = [...(event.dataTransfer?.files ?? [])];
|
|
2495
|
+
setDragActiveFlag(false);
|
|
2496
|
+
/* 只接受落在栏内的投放。落在侧栏 / 底栏(正常不会有 drop 事件)一律丢弃,
|
|
2497
|
+
不做「兜底给焦点栏」—— 用户要的是「只能拖到显示区」。 */
|
|
2498
|
+
if (paneId === null || files.length === 0) return;
|
|
2499
|
+
event.preventDefault();
|
|
2500
|
+
event.stopPropagation();
|
|
2501
|
+
const intake = PANE_INTAKE.get(paneId);
|
|
2502
|
+
if (typeof intake !== "function") return;
|
|
2503
|
+
try {
|
|
2504
|
+
intake(files);
|
|
2505
|
+
} catch (error) {
|
|
2506
|
+
console.warn("[split-view] 投放文件到目标栏失败:", error);
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
2509
|
+
document.addEventListener("dragenter", onEnter, true);
|
|
2510
|
+
document.addEventListener("dragover", onOver, true);
|
|
2511
|
+
document.addEventListener("dragleave", onLeave, true);
|
|
2512
|
+
document.addEventListener("drop", onDrop, true);
|
|
2513
|
+
window.addEventListener("dragend", onEnd, true);
|
|
2514
|
+
return () => {
|
|
2515
|
+
document.removeEventListener("dragenter", onEnter, true);
|
|
2516
|
+
document.removeEventListener("dragover", onOver, true);
|
|
2517
|
+
document.removeEventListener("dragleave", onLeave, true);
|
|
2518
|
+
document.removeEventListener("drop", onDrop, true);
|
|
2519
|
+
window.removeEventListener("dragend", onEnd, true);
|
|
2520
|
+
setDragActiveFlag(false);
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* 宿主 `conversation.input.attachments` 槽位的替代实现。
|
|
2526
|
+
*
|
|
2527
|
+
* · 平时:原样渲染宿主组件(附件栏、缩略图、上传进度都不变)。
|
|
2528
|
+
* · 拖文件期间:整栏返回 null —— 宿主的全屏遮罩就是它自己画的,留着会盖住其它栏、
|
|
2529
|
+
* 让人根本没法选目标栏;这时改用栏级高亮(data-drop-target)。
|
|
2530
|
+
* · 无论渲染与否,都把本栏的 onAddFiles 记进 PANE_INTAKE,drop 落到本栏时才有一份可调用的入口。
|
|
2531
|
+
*/
|
|
2532
|
+
function SplitAttachmentsSlot(props) {
|
|
2533
|
+
const paneId = react.useContext(PaneIdCtx);
|
|
2534
|
+
const [dragState, setLocalDragState] = react.useState({ active: DRAG_ACTIVE, pane: DROP_PANE_ID });
|
|
2535
|
+
react.useEffect(() => {
|
|
2536
|
+
const fn = () => setLocalDragState({ active: DRAG_ACTIVE, pane: DROP_PANE_ID });
|
|
2537
|
+
DROP_SUBSCRIBERS.add(fn);
|
|
2538
|
+
fn();
|
|
2539
|
+
return () => {
|
|
2540
|
+
DROP_SUBSCRIBERS.delete(fn);
|
|
2541
|
+
};
|
|
2542
|
+
}, []);
|
|
2543
|
+
react.useEffect(() => {
|
|
2544
|
+
if (paneId === null || paneId === void 0) return;
|
|
2545
|
+
const intake = props.onAddFiles;
|
|
2546
|
+
PANE_INTAKE.set(paneId, intake);
|
|
2547
|
+
return () => {
|
|
2548
|
+
if (PANE_INTAKE.get(paneId) === intake) PANE_INTAKE.delete(paneId);
|
|
2549
|
+
};
|
|
2550
|
+
}, [paneId, props.onAddFiles]);
|
|
2551
|
+
const Host = HOST_ATTACHMENTS;
|
|
2552
|
+
if (Host === null || Host === void 0) return null;
|
|
2553
|
+
if (dragState.active === true) return null;
|
|
2554
|
+
return h(Host, { ...HOST_ATTACH_INJECT, ...props });
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2337
2557
|
/**
|
|
2338
2558
|
* One tab in the shared strip. Middle-click and double-click both close it,
|
|
2339
2559
|
* which is what the Hermes-style workflow expects.
|
|
@@ -2475,8 +2695,10 @@ window.__ModuleLoader__.load({
|
|
|
2475
2695
|
const cs = getComputedStyle(node);
|
|
2476
2696
|
const inner = node.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
|
|
2477
2697
|
/* pane 本身没有 padding(padding 在 header 上),所以这里不额外扣。
|
|
2478
|
-
header 的左右 padding 与 + 按钮宽度统一在下面 stripW 里扣。
|
|
2479
|
-
|
|
2698
|
+
header 的左右 padding 与 + 按钮宽度统一在下面 stripW 里扣。
|
|
2699
|
+
侧栏折叠时标签条要整体右移让出宿主左上控件,可用宽度同步扣掉那一份;
|
|
2700
|
+
用 paneEl 而不是 node 量,避免拿已经右移过的 header 反复叠算。 */
|
|
2701
|
+
setHeadW(Math.max(0, Math.round(inner) - (paneEl === null ? 0 : paneLeftGuard(paneEl))));
|
|
2480
2702
|
};
|
|
2481
2703
|
read();
|
|
2482
2704
|
const observer = typeof ResizeObserver === "function" ? new ResizeObserver(read) : null;
|
|
@@ -2516,8 +2738,13 @@ window.__ModuleLoader__.load({
|
|
|
2516
2738
|
if (paneEl === null) return;
|
|
2517
2739
|
const sync = () => {
|
|
2518
2740
|
const rect = paneEl.getBoundingClientRect();
|
|
2519
|
-
|
|
2520
|
-
|
|
2741
|
+
/* 侧栏折叠时栏贴到窗口左缘(left=0),但窗口最顶那一行左边还有宿主的控件:
|
|
2742
|
+
收起/展开侧边栏、折叠时的「新建会话」、应用/编辑菜单([data-windows-menu])。
|
|
2743
|
+
标签条是 fixed + z-index:60,从 0 铺过去会把它们整个盖住(看不见也点不到)。
|
|
2744
|
+
这里整体右移并等比收窄,把那一小块还给宿主;侧栏展开/竖排时 guard=0,行为不变。 */
|
|
2745
|
+
const guard = paneLeftGuard(paneEl);
|
|
2746
|
+
const left = `${Math.round(rect.left + guard)}px`;
|
|
2747
|
+
const width = `${Math.max(0, Math.round(rect.width) - guard)}px`;
|
|
2521
2748
|
if (head.style.left !== left) head.style.left = left;
|
|
2522
2749
|
if (head.style.width !== width) head.style.width = width;
|
|
2523
2750
|
};
|
|
@@ -2932,16 +3159,21 @@ window.__ModuleLoader__.load({
|
|
|
2932
3159
|
h(
|
|
2933
3160
|
"div",
|
|
2934
3161
|
{ className: "dsv-body" },
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
3162
|
+
/* 把「这一栏的 id」注入组件树:宿主的附件槽位组件靠它判断自己属于哪一栏。 */
|
|
3163
|
+
h(
|
|
3164
|
+
PaneIdCtx.Provider,
|
|
3165
|
+
{ value: pane.id },
|
|
3166
|
+
h(TabContentMemo, {
|
|
3167
|
+
key: `${active?.id ?? "none"}::${sessionId ?? "blank"}`,
|
|
3168
|
+
sessionId,
|
|
3169
|
+
hero,
|
|
3170
|
+
sessions,
|
|
3171
|
+
renderFactorySlot,
|
|
3172
|
+
SessionProvider,
|
|
3173
|
+
renderSlot,
|
|
3174
|
+
viewBarOn: viewBar.enabled === true
|
|
3175
|
+
})
|
|
3176
|
+
)
|
|
2945
3177
|
),
|
|
2946
3178
|
/* bottom 模式不再画在栏内底部 —— 它由 StatusBar 挂到底栏左边
|
|
2947
3179
|
(用户要求:切换条在底部时搬到最底那行的左侧,统计信息挪右边)。 */
|
|
@@ -6141,6 +6373,77 @@ window.__ModuleLoader__.load({
|
|
|
6141
6373
|
syncSettingsFlag();
|
|
6142
6374
|
SERVICES.ctx = ctx;
|
|
6143
6375
|
|
|
6376
|
+
/* 拖放定向:接管宿主的 `conversation.input.attachments` 槽位。
|
|
6377
|
+
拿得到宿主原组件才接管;拿不到(宿主升级改了槽位形状)就不注册,
|
|
6378
|
+
行为退回宿主默认(多栏拖文件仍会加到每一栏),不会更差。 */
|
|
6379
|
+
ctx.effect(() => {
|
|
6380
|
+
let stopTracking = null;
|
|
6381
|
+
let disposeSlot = null;
|
|
6382
|
+
/* 真正接管。宿主那个槽位可能比本插件晚注册,所以「读 entry + 注册」必须
|
|
6383
|
+
放在 inject 回调里等它就绪,不能在 effect 顶层直接读。 */
|
|
6384
|
+
const attach = () => {
|
|
6385
|
+
if (disposeSlot !== null) return;
|
|
6386
|
+
const slots = service("slots");
|
|
6387
|
+
const entry = (slots?.entries?.("conversation.input.attachments") ?? [])[0];
|
|
6388
|
+
if (entry === void 0 || typeof entry.component !== "function") return;
|
|
6389
|
+
HOST_ATTACHMENTS = entry.component;
|
|
6390
|
+
/* 宿主那份注册带 inject(readFileDrag 等),直接调它拿到注入值,
|
|
6391
|
+
包一层再传给原组件,免得自己去找这些服务。 */
|
|
6392
|
+
try {
|
|
6393
|
+
HOST_ATTACH_INJECT = typeof entry.inject === "function" ? entry.inject() ?? {} : {};
|
|
6394
|
+
} catch {
|
|
6395
|
+
HOST_ATTACH_INJECT = {};
|
|
6396
|
+
}
|
|
6397
|
+
if (stopTracking === null) stopTracking = installDropPaneTracking();
|
|
6398
|
+
/* single 槽必须指定不同的 priority 才能顶掉已有的注册(数值最低者渲染);
|
|
6399
|
+
宿主那份是 priority 0,所以这里用 -1。 */
|
|
6400
|
+
disposeSlot = slots.register(
|
|
6401
|
+
{ name: "conversation.input.attachments", priority: -1, locale: "conversation" },
|
|
6402
|
+
SplitAttachmentsSlot
|
|
6403
|
+
);
|
|
6404
|
+
};
|
|
6405
|
+
let sub = null;
|
|
6406
|
+
try {
|
|
6407
|
+
sub = ctx.slots.inject("conversation.input.attachments", attach);
|
|
6408
|
+
} catch (error) {
|
|
6409
|
+
console.warn("[split-view] 附件槽位 inject 失败:", error);
|
|
6410
|
+
}
|
|
6411
|
+
/* 槽位若已就绪,inject 可能已同步回调;再补一次幂等尝试。 */
|
|
6412
|
+
try {
|
|
6413
|
+
attach();
|
|
6414
|
+
} catch (error) {
|
|
6415
|
+
console.warn("[split-view] 接管附件槽位失败,拖放定向未启用:", error);
|
|
6416
|
+
}
|
|
6417
|
+
if (disposeSlot === null) {
|
|
6418
|
+
console.warn("[split-view] 未找到宿主附件槽位组件,拖放定向未启用(多栏拖文件仍会加到每一栏)");
|
|
6419
|
+
}
|
|
6420
|
+
return () => {
|
|
6421
|
+
if (stopTracking !== null) {
|
|
6422
|
+
try {
|
|
6423
|
+
stopTracking();
|
|
6424
|
+
} catch {
|
|
6425
|
+
/* 忽略 */
|
|
6426
|
+
}
|
|
6427
|
+
}
|
|
6428
|
+
if (typeof sub === "function") {
|
|
6429
|
+
try {
|
|
6430
|
+
sub();
|
|
6431
|
+
} catch {
|
|
6432
|
+
/* 忽略 */
|
|
6433
|
+
}
|
|
6434
|
+
}
|
|
6435
|
+
if (disposeSlot !== null) {
|
|
6436
|
+
try {
|
|
6437
|
+
disposeSlot();
|
|
6438
|
+
} catch {
|
|
6439
|
+
/* 忽略 */
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
HOST_ATTACHMENTS = null;
|
|
6443
|
+
HOST_ATTACH_INJECT = {};
|
|
6444
|
+
};
|
|
6445
|
+
}, "dsh-split-view: attachments drop routing");
|
|
6446
|
+
|
|
6144
6447
|
/* 把「锁定标签」作为一项贡献进宿主的**会话右键菜单**。
|
|
6145
6448
|
标签上右键 → 打开的就是宿主这份菜单(open 见 TabItem),所以标签右键与侧栏会话行右键
|
|
6146
6449
|
看到的是同一套项:置顶 / 重命名 / 分叉 / 归档 / 复制会话 ID…(全部由宿主注册表提供,
|
package/package.json
CHANGED