dsh-lean-router 1.0.8 → 1.0.9
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/docs/changelog.en.md +6 -1
- package/docs/changelog.md +6 -1
- package/docs/quickstart.en.md +1 -1
- package/docs/quickstart.md +1 -1
- package/lib/client.js +64 -36
- package/package.json +1 -1
- package/test/client-plugin.test.mjs +54 -17
package/docs/changelog.en.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 1.0.
|
|
3
|
+
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 1.0.9).
|
|
4
|
+
|
|
5
|
+
## 1.0.9 (2026-11-24)
|
|
6
|
+
|
|
7
|
+
- Fixed (real install, rendering): the header button appeared, but clicking it drew only a thin black bar across that row. The panel used to render as a React component inside the header slot, so `position: fixed` was confined to that row by an ancestor's `transform` / `overflow`. It is now a plain DOM overlay appended to `document.body` (`#lean-router-panel`), with only the button left in the slot; the overlay sits at `z-index: 2147483000`, closes on backdrop or ✕ click, and the button toggles it.
|
|
8
|
+
- Tests: new assertion that clicking the button mounts the panel on `body` and clicking again removes it; 222 tests green.
|
|
4
9
|
|
|
5
10
|
## 1.0.8 (2026-11-24)
|
|
6
11
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# 变更记录(changelog)
|
|
2
2
|
|
|
3
|
-
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 1.0.
|
|
3
|
+
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 1.0.9)。
|
|
4
|
+
|
|
5
|
+
## 1.0.9 (2026-11-24)
|
|
6
|
+
|
|
7
|
+
- 修复(真机,渲染):顶栏按钮能出现,但点击后面板只在那一行显示成「一条黑条」。原因是面板原先作为 React 组件渲染在顶栏 slot 内部,`position: fixed` 被祖先元素的 `transform` / `overflow` 限制在那一行里。改为挂到 `document.body` 的纯 DOM 浮层(`#lean-router-panel`),slot 里只留按钮;浮层层级提到 `2147483000`,点遮罩或 ✕ 关闭,再点按钮收起。
|
|
8
|
+
- 测试:新增「点按钮把面板挂到 body、再点一次移除」断言;222 测试全绿。
|
|
4
9
|
|
|
5
10
|
## 1.0.8 (2026-11-24)
|
|
6
11
|
|
package/docs/quickstart.en.md
CHANGED
|
@@ -20,7 +20,7 @@ After restarting DSH, pick the **Lean router** preset (lean tier) or **Lean rout
|
|
|
20
20
|
### Path B: npm install (recommended)
|
|
21
21
|
|
|
22
22
|
~~~powershell
|
|
23
|
-
dsh plugin --profile desktop add npm:dsh-lean-router@1.0.
|
|
23
|
+
dsh plugin --profile desktop add npm:dsh-lean-router@1.0.9
|
|
24
24
|
~~~
|
|
25
25
|
|
|
26
26
|
(Both paths match the output of scripts/install.mjs; the real installer, claim boundaries and `--uninstall` rollback belong to ticket 09.)
|
package/docs/quickstart.md
CHANGED
|
@@ -20,7 +20,7 @@ dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
|
|
|
20
20
|
### 路径 B:npm 安装(推荐)
|
|
21
21
|
|
|
22
22
|
~~~powershell
|
|
23
|
-
dsh plugin --profile desktop add npm:dsh-lean-router@1.0.
|
|
23
|
+
dsh plugin --profile desktop add npm:dsh-lean-router@1.0.9
|
|
24
24
|
~~~
|
|
25
25
|
|
|
26
26
|
(两条路径与 scripts/install.mjs 输出的说明一致;真安装器、认领边界与 `--uninstall` 回滚归票 09。)
|
package/lib/client.js
CHANGED
|
@@ -36,7 +36,7 @@ window.__ModuleLoader__.load({
|
|
|
36
36
|
const overlayStyle = {
|
|
37
37
|
position: "fixed",
|
|
38
38
|
inset: 0,
|
|
39
|
-
zIndex:
|
|
39
|
+
zIndex: 2147483000,
|
|
40
40
|
display: "flex",
|
|
41
41
|
alignItems: "center",
|
|
42
42
|
justifyContent: "center",
|
|
@@ -70,45 +70,73 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
opacity: 0.7,
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
function
|
|
75
|
-
return
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
/** 把 React 风格对象转成 cssText,DOM 浮层复用同一套样式。 */
|
|
74
|
+
function cssOf(style) {
|
|
75
|
+
return Object.entries(style)
|
|
76
|
+
.map(([key, value]) => key.replace(/[A-Z]/g, (ch) => "-" + ch.toLowerCase()) + ":" + value)
|
|
77
|
+
.join(";");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 1.0.9 修(真机):面板原来用 React 渲染在顶栏 slot 内,position:fixed 会被祖先的
|
|
81
|
+
// transform / overflow 限制在那一行里,只剩一条黑条。改为挂到 document.body 的纯 DOM
|
|
82
|
+
// 浮层,slot 里只留按钮。
|
|
83
|
+
let panelEl = null;
|
|
84
|
+
|
|
85
|
+
function closePanel() {
|
|
86
|
+
if (panelEl) {
|
|
87
|
+
panelEl.remove();
|
|
88
|
+
panelEl = null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function buildPanel() {
|
|
93
|
+
const overlay = document.createElement("div");
|
|
94
|
+
overlay.id = "lean-router-panel";
|
|
95
|
+
overlay.style.cssText = cssOf(overlayStyle);
|
|
96
|
+
const card = document.createElement("div");
|
|
97
|
+
card.style.cssText = cssOf(cardStyle);
|
|
98
|
+
const close = document.createElement("button");
|
|
99
|
+
close.type = "button";
|
|
100
|
+
close.textContent = "✕";
|
|
101
|
+
close.title = "关闭";
|
|
102
|
+
close.style.cssText = cssOf(closeStyle);
|
|
103
|
+
const title = document.createElement("div");
|
|
104
|
+
title.textContent = "技能面板 · 骨架";
|
|
105
|
+
title.style.cssText = "font-size:15px;font-weight:600;margin-bottom:8px";
|
|
106
|
+
const body = document.createElement("div");
|
|
107
|
+
body.style.cssText = "opacity:.75";
|
|
108
|
+
body.innerHTML =
|
|
109
|
+
"链路已通:这个面板由 dsh-lean-router 的客户端插件渲染。<br>" +
|
|
110
|
+
"阶段 2 接入 31 个技能与审计统计,阶段 3 加分组表格、开关与一键工作流。";
|
|
111
|
+
close.addEventListener("click", (event) => {
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
closePanel();
|
|
114
|
+
});
|
|
115
|
+
card.addEventListener("click", (event) => event.stopPropagation());
|
|
116
|
+
overlay.addEventListener("click", closePanel);
|
|
117
|
+
card.appendChild(close);
|
|
118
|
+
card.appendChild(title);
|
|
119
|
+
card.appendChild(body);
|
|
120
|
+
overlay.appendChild(card);
|
|
121
|
+
return overlay;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function togglePanel() {
|
|
125
|
+
if (panelEl) {
|
|
126
|
+
closePanel();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (typeof document === "undefined" || !document.body) return;
|
|
130
|
+
panelEl = buildPanel();
|
|
131
|
+
document.body.appendChild(panelEl);
|
|
92
132
|
}
|
|
93
133
|
|
|
94
|
-
/**
|
|
134
|
+
/** 顶栏「技能」按钮:点开/关闭 body 级浮层面板。 */
|
|
95
135
|
function SkillsButton() {
|
|
96
|
-
const [open, setOpen] = React.useState(false);
|
|
97
|
-
const close = React.useCallback(() => setOpen(false), []);
|
|
98
136
|
return h(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"button",
|
|
103
|
-
{
|
|
104
|
-
type: "button",
|
|
105
|
-
style: btnStyle,
|
|
106
|
-
title: "lean-router 技能面板",
|
|
107
|
-
onClick: () => setOpen((value) => !value),
|
|
108
|
-
},
|
|
109
|
-
"技能"
|
|
110
|
-
),
|
|
111
|
-
open ? h(SkillsPanel, { onClose: close }) : null
|
|
137
|
+
"button",
|
|
138
|
+
{ type: "button", style: btnStyle, title: "lean-router 技能面板", onClick: togglePanel },
|
|
139
|
+
"技能"
|
|
112
140
|
);
|
|
113
141
|
}
|
|
114
142
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// dsh-lean-router
|
|
2
|
-
//
|
|
1
|
+
// dsh-lean-router —— 客户端插件(lib/client.js)的服务获取、时机与渲染回归。
|
|
2
|
+
// 真机事故链:
|
|
3
3
|
// 1.0.6: 直接读 ctx.register 抛 cannot get property "register" without inject,apply 整体失败。
|
|
4
|
-
// 1.0.7: 改成 ctx.get("slots"),但 apply
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// 1.0.7: 改成 ctx.get("slots"),但 apply 早于 slots 服务注册,拿到 undefined 后兜底又因
|
|
5
|
+
// document.body 未建立而静默返回 → 无按钮、无报错。
|
|
6
|
+
// 1.0.8: 用 ctx.inject(["slots"], cb) 等服务就绪,按钮出现。
|
|
7
|
+
// 1.0.9: 面板原先渲染在顶栏 slot 内,position:fixed 被祖先 transform/overflow 裁成一条黑条,
|
|
8
|
+
// 改为挂到 document.body 的纯 DOM 浮层。
|
|
7
9
|
import test from "node:test";
|
|
8
10
|
import assert from "node:assert/strict";
|
|
9
11
|
|
|
@@ -14,8 +16,6 @@ await import("../lib/client.js");
|
|
|
14
16
|
const React = {
|
|
15
17
|
createElement: (type, props, ...children) => ({ type, props, children }),
|
|
16
18
|
Fragment: "Fragment",
|
|
17
|
-
useState: (value) => [value, () => {}],
|
|
18
|
-
useCallback: (fn) => fn,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
function makePlugin() {
|
|
@@ -40,13 +40,31 @@ function throwingGetters(extra) {
|
|
|
40
40
|
}, extra);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/** 够用的假 DOM:支持 createElement / appendChild / remove / addEventListener。 */
|
|
44
|
+
function makeFakeDocument() {
|
|
45
|
+
const body = { tag: "body", children: [], appendChild(node) { this.children.push(node); node.parent = this; } };
|
|
46
|
+
const doc = {
|
|
47
|
+
body,
|
|
48
|
+
getElementById() { return undefined; },
|
|
49
|
+
createElement(tag) {
|
|
50
|
+
return {
|
|
51
|
+
tag, style: {}, children: [], parent: null,
|
|
52
|
+
addEventListener(type, fn) { this[type] = fn; },
|
|
53
|
+
appendChild(node) { this.children.push(node); node.parent = this; },
|
|
54
|
+
remove() { if (this.parent) { this.parent.children = this.parent.children.filter((x) => x !== this); this.parent = null; } },
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
return doc;
|
|
59
|
+
}
|
|
60
|
+
|
|
43
61
|
test("用 ctx.inject(['slots'], cb) 等服务就绪后注册到头栏 slot", () => {
|
|
44
62
|
const registered = [];
|
|
45
63
|
const slots = makeSlots(registered);
|
|
46
64
|
let asked = null;
|
|
47
65
|
const ctx = throwingGetters({
|
|
48
66
|
inject(deps, cb) { asked = deps; cb(throwingGetters({ get: (name) => (name === "slots" ? slots : undefined) })); return () => {}; },
|
|
49
|
-
get(
|
|
67
|
+
get() { return undefined; },
|
|
50
68
|
});
|
|
51
69
|
const dispose = makePlugin().apply(ctx);
|
|
52
70
|
assert.equal(typeof dispose, "function");
|
|
@@ -54,6 +72,7 @@ test("用 ctx.inject(['slots'], cb) 等服务就绪后注册到头栏 slot", ()
|
|
|
54
72
|
assert.equal(registered.length, 1);
|
|
55
73
|
assert.equal(registered[0].spec.name, "conversation.session.header.actions");
|
|
56
74
|
assert.equal(registered[0].spec.id, "lean-router.skills");
|
|
75
|
+
assert.equal(typeof registered[0].spec.inject, "function", "spec 需要 inject props 工厂");
|
|
57
76
|
});
|
|
58
77
|
|
|
59
78
|
test("没有 ctx.inject 时退化为直接取 slots 注册", () => {
|
|
@@ -65,21 +84,39 @@ test("没有 ctx.inject 时退化为直接取 slots 注册", () => {
|
|
|
65
84
|
assert.equal(registered.length, 1);
|
|
66
85
|
});
|
|
67
86
|
|
|
87
|
+
test("点按钮把面板挂到 body(不在 slot 内渲染),再点一次移除", () => {
|
|
88
|
+
const registered = [];
|
|
89
|
+
const slots = makeSlots(registered);
|
|
90
|
+
const ctx = throwingGetters({
|
|
91
|
+
inject(deps, cb) { cb(throwingGetters({ get: (name) => (name === "slots" ? slots : undefined) })); return () => {}; },
|
|
92
|
+
get() { return undefined; },
|
|
93
|
+
});
|
|
94
|
+
makePlugin().apply(ctx);
|
|
95
|
+
globalThis.document = makeFakeDocument();
|
|
96
|
+
try {
|
|
97
|
+
const Button = registered[0].component;
|
|
98
|
+
const element = Button({});
|
|
99
|
+
assert.equal(element.type, "button");
|
|
100
|
+
element.props.onClick();
|
|
101
|
+
assert.equal(document.body.children.length, 1, "面板必须挂到 body");
|
|
102
|
+
assert.equal(document.body.children[0].id, "lean-router-panel");
|
|
103
|
+
element.props.onClick();
|
|
104
|
+
assert.equal(document.body.children.length, 0, "再点一次必须移除");
|
|
105
|
+
} finally {
|
|
106
|
+
delete globalThis.document;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
68
110
|
test("slots 一直不出现时,2 秒后插入纯 DOM 兜底按钮(不再静默)", async () => {
|
|
69
|
-
|
|
70
|
-
globalThis.document = {
|
|
71
|
-
body: { appendChild(node) { appended.push(node); } },
|
|
72
|
-
getElementById() { return undefined; },
|
|
73
|
-
createElement(tag) { return { tag, style: {}, addEventListener() {}, remove() {} }; },
|
|
74
|
-
};
|
|
111
|
+
globalThis.document = makeFakeDocument();
|
|
75
112
|
try {
|
|
76
113
|
const ctx = throwingGetters({ inject() { return () => {}; }, get() { return undefined; } });
|
|
77
114
|
const dispose = makePlugin().apply(ctx);
|
|
78
115
|
assert.equal(typeof dispose, "function");
|
|
79
|
-
assert.equal(
|
|
116
|
+
assert.equal(document.body.children.length, 0, "兜底要等 2 秒,不能立刻插");
|
|
80
117
|
await new Promise((resolve) => setTimeout(resolve, 2200));
|
|
81
|
-
assert.equal(
|
|
82
|
-
assert.equal(
|
|
118
|
+
assert.equal(document.body.children.length, 1, "2 秒后必须插兜底按钮");
|
|
119
|
+
assert.equal(document.body.children[0].id, "lean-router-dom-fallback");
|
|
83
120
|
} finally {
|
|
84
121
|
delete globalThis.document;
|
|
85
122
|
}
|