dsh-share-html 0.5.1 → 0.7.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 +140 -33
- package/lib/client.js +134 -0
- package/lib/index.js +14 -0
- package/lib/kernel.js +1617 -183
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,38 +4,112 @@
|
|
|
4
4
|
|
|
5
5
|
存档复盘、交付会话、贴进 wiki,都不用再截图拼接。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 它解决什么问题
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- **观感对齐 DSH** —— 不是自己画一套样式,而是把 DSH 主题包的设计令牌抽成字面值内联进去,浅色/深色跟随系统。
|
|
13
|
-
- **按需裁剪** —— 三档粒度:只要问答、带上思考与工具调用、或连工具结果全文一起导出。
|
|
14
|
-
- **默认脱敏** —— API Key、令牌、私钥、邮箱、内网 IP 自动打码,支持不可逆哈希。
|
|
15
|
-
- **零依赖安装** —— 发布物是预构建 JS,装的时候不需要构建,也不需要批准安装脚本。
|
|
11
|
+
日常用 DSH 排查问题、做分析、写方案,结果往往散在会话里。要把一次会话留存或交付出去时,常见做法都不太合适:
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
| 常见做法 | 问题 |
|
|
14
|
+
|---|---|
|
|
15
|
+
| **截图** | 长会话要拼十几张图,还截不到折叠内容 |
|
|
16
|
+
| **复制粘贴** | Markdown 粘出去格式全丢,表格和代码块散架 |
|
|
17
|
+
| **共享会话链接** | 查看方也得登录 DSH,还得有对应权限 |
|
|
18
|
+
|
|
19
|
+
装了本插件,点一下「分享」,拿到**一个 `.html` 文件**:
|
|
20
|
+
|
|
21
|
+
- 可以归档,也可以直接发出去,**双击就能打开**
|
|
22
|
+
- 对方**不用装任何东西,不用联网**
|
|
23
|
+
- 排版、深浅色、代码高亮,跟原会话一模一样
|
|
24
|
+
- API Key、邮箱、内网 IP **默认自动打码**
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 安装完是什么样
|
|
29
|
+
|
|
30
|
+
装好并**重启 `dsh web`** 后,打开任意会话,顶部工具栏会多出一个 **「分享」** 按钮:
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
点它就会弹出导出面板,选好参数后直接下载。
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 导出来长什么样
|
|
39
|
+
|
|
40
|
+
导出的文件用浏览器打开就是这个样子。下面是真实导出(1 轮 / 9 条消息 / 13 次工具调用,选「完整」档):
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
从这张图能看出几个关键设计:
|
|
45
|
+
|
|
46
|
+
| 位置 | 说明 |
|
|
47
|
+
|---|---|
|
|
48
|
+
| **顶部摘要** | 轮次、消息数、工具调用数、导出时间、粒度、脱敏处数 —— 一眼知道文件里有什么 |
|
|
49
|
+
| **右侧气泡** | 你的提问,原样保留,不解析 Markdown |
|
|
50
|
+
| **左侧正文** | 模型回答,排版与 DSH 一致 |
|
|
51
|
+
| **模型名** | 每条回答上方显示所用模型 |
|
|
52
|
+
| **`bash` / `read` / `grep` 行** | 工具调用折成一行,**默认收起**,点开才看参数与结果 |
|
|
53
|
+
| **表格与代码块** | Markdown 完整渲染,不丢格式 |
|
|
54
|
+
|
|
55
|
+
工具调用默认收起这点很关键:上图那次会话有 13 次工具调用,收起后正文始终连贯可读;想查某个命令具体跑了什么,再点开那一行。
|
|
56
|
+
|
|
57
|
+
### 一轮折叠:先看结论,需要时再展开
|
|
58
|
+
|
|
59
|
+
每轮对话的顶部有一条折叠头,显示状态和耗时。默认收起 —— 长会话里你看到的始终是干净的正文:
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
点一下,过程(思考、工具调用)就地展开,正文不动:
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
### 文件改动:点开右侧看 diff
|
|
68
|
+
|
|
69
|
+
轮次末尾会有一张「已编辑 N 个文件 +x −y」的卡片:
|
|
70
|
+
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+
点文件名,右侧滑出改动抽屉,逐行显示增删:
|
|
18
74
|
|
|
19
|
-
|
|
75
|
+

|
|
20
76
|
|
|
77
|
+
抽屉是纯 CSS `:target` 实现的 —— **没有一行 JavaScript**,所以离线打开、进企业邮件网关都不受影响。
|
|
78
|
+
|
|
79
|
+
想看完整一屏的效果:
|
|
80
|
+
|
|
81
|
+
<details>
|
|
82
|
+
<summary>展开查看整页(1280 × 3800)</summary>
|
|
83
|
+
|
|
84
|
+
<br>
|
|
85
|
+
|
|
86
|
+
<img src="assets/screenshot-export-full.png" alt="整页效果" width="760">
|
|
87
|
+
|
|
88
|
+
</details>
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 安装
|
|
21
93
|
|
|
22
94
|
```bash
|
|
23
|
-
dsh plugin --profile web add dsh-share-html
|
|
95
|
+
dsh plugin --profile web add dsh-share-html --config.minimumReleaseAge=0
|
|
24
96
|
```
|
|
25
97
|
|
|
26
|
-
装完**重启 `dsh web`**,打开任意会话,header
|
|
98
|
+
装完**重启 `dsh web`**,打开任意会话,header 上就会出现「分享」按钮。
|
|
99
|
+
|
|
100
|
+
> **`--config.minimumReleaseAge=0` 建议带上。** pnpm 默认会跳过「刚发布不久」的版本,
|
|
101
|
+
> 不带这个参数可能装到上一个版本。详见 [INSTALL.md 的「装到旧版怎么办」](INSTALL.md)。
|
|
27
102
|
|
|
28
103
|
<details>
|
|
29
104
|
<summary>其他安装方式</summary>
|
|
30
105
|
|
|
31
|
-
|
|
106
|
+
**从 GitHub Release 装**(预构建 tarball,不依赖 npm):
|
|
32
107
|
|
|
33
108
|
```bash
|
|
34
|
-
|
|
35
|
-
dsh plugin --profile web add https://github.com/unknown3310v0/dsh-share-html/releases/download/<版本>/dsh-share-html-<版本去掉v>.tgz
|
|
109
|
+
dsh plugin --profile web add https://github.com/unknown3310v0/dsh-share-html/releases/latest/download/dsh-share-html.tgz
|
|
36
110
|
```
|
|
37
111
|
|
|
38
|
-
|
|
112
|
+
**从源码装**:
|
|
39
113
|
|
|
40
114
|
```bash
|
|
41
115
|
dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
@@ -43,6 +117,24 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
43
117
|
|
|
44
118
|
</details>
|
|
45
119
|
|
|
120
|
+
完整安装指引(含内网源、离线包、排错)见 **[INSTALL.md](INSTALL.md)**。
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 为什么用它
|
|
125
|
+
|
|
126
|
+
- **单文件、真离线** —— 产物里零 `<script>`、零外链、零网络请求。发邮件、传网盘、放进任何地方都能打开。
|
|
127
|
+
- **观感对齐 DSH** —— 不是自己画一套样式,而是把 DSH 主题包的设计令牌抽成字面值内联进去,浅色/深色跟随系统。
|
|
128
|
+
- **按需裁剪** —— 三档粒度:只要问答、带上思考与工具调用、或连工具结果全文一起导出。
|
|
129
|
+
- **默认脱敏** —— API Key、令牌、私钥、邮箱、内网 IP 自动打码,支持不可逆哈希。
|
|
130
|
+
- **零依赖安装** —— 发布物是预构建 JS,装的时候不需要构建,也不需要批准安装脚本。
|
|
131
|
+
|
|
132
|
+
### 和同类 HTML 分享插件比
|
|
133
|
+
|
|
134
|
+
同类插件大多带 `<script>` 或引 CDN 资源,本插件两者都没有 —— 这不只是"更快",而是决定了文件能不能进得去:邮件网关、内网文档系统、终端安全软件都会拦带脚本的 HTML 附件。详细对比见 [INSTALL.md](INSTALL.md)。
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
46
138
|
## 使用
|
|
47
139
|
|
|
48
140
|
点会话 header 的「分享」按钮,弹窗里选粒度、勾选要包含的内容,右侧实时预览,确认后下载。
|
|
@@ -66,7 +158,7 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
66
158
|
| **思考过程** | 完全看不到模型推理 | 折叠的「思考过程」块,点开可见推理原文 |
|
|
67
159
|
| **工具调用** | 整段工具交互消失 | 折叠的「工具名 + 参数摘要」 |
|
|
68
160
|
| **工具结果** | 只留一行摘要(`共 3 行 / 52 字符`) | 结果正文全文 |
|
|
69
|
-
| **附件** | 不显示文件条目 | 文件名 + 类型 +
|
|
161
|
+
| **附件** | 不显示文件条目 | 文件名 + 类型 + 大小(不含内容) |
|
|
70
162
|
| **模型信息** | 消息头部不显示模型名 | 消息头部左侧显示模型名 |
|
|
71
163
|
|
|
72
164
|
> **关于「检索结果」和「深度研究」**:这两个开关曾经存在,v0.3.1 起已从界面上移除。
|
|
@@ -75,19 +167,6 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
75
167
|
> 摆一个拨动后毫无变化的开关,比不摆更让人困惑,所以先收起;
|
|
76
168
|
> 契约层仍然接受这两个字段(老客户端传过来不会报错),等 DSH 补上事件形态后加回界面即可。
|
|
77
169
|
|
|
78
|
-
### 想看三档的实际差别
|
|
79
|
-
|
|
80
|
-
打开 [示例对比页](docs/example-compare.html):同一段会话(排查订单服务超时)用三档各导一次,并排展示。
|
|
81
|
-
|
|
82
|
-
也可以单独打开:
|
|
83
|
-
|
|
84
|
-
- [对话档](docs/example-conversation.html) —— 只有两轮问答
|
|
85
|
-
- [过程档](docs/example-process.html) —— 多出思考、工具调用、附件;工具结果只剩一行摘要
|
|
86
|
-
- [完整档](docs/example-full.html) —— 工具结果全文,消息头带模型名
|
|
87
|
-
|
|
88
|
-
> 想直观看出区别,请用**用过工具**的会话(让模型读过文件、跑过命令)。只有纯问答的会话,
|
|
89
|
-
> 大部分开关没有可显示的内容,三档看起来会几乎一样 —— 这是正确的,不是开关失灵。
|
|
90
|
-
|
|
91
170
|
### 选择轮次
|
|
92
171
|
|
|
93
172
|
会话很长时,可以只导出其中几轮。展开「导出轮次」后按轮勾选:
|
|
@@ -113,25 +192,46 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
113
192
|
|
|
114
193
|
关闭脱敏时,产物 meta 与页脚都会标记 `unredacted`,并且在弹窗里需要二次确认。
|
|
115
194
|
|
|
195
|
+
### 想看三档的实际差别
|
|
196
|
+
|
|
197
|
+
打开 **[示例对比页](docs/example-compare.html)**:同一段会话(排查订单服务超时)用三档各导一次,并排展示。
|
|
198
|
+
|
|
199
|
+
也可以单独打开:
|
|
200
|
+
|
|
201
|
+
- [对话档](docs/example-conversation.html) —— 只有两轮问答
|
|
202
|
+
- [过程档](docs/example-process.html) —— 多出思考、工具调用、附件;工具结果只剩一行摘要
|
|
203
|
+
- [完整档](docs/example-full.html) —— 工具结果全文,消息头带模型名
|
|
204
|
+
|
|
205
|
+
> 想直观看出区别,请用**用过工具**的会话(让模型读过文件、跑过命令)。只有纯问答的会话,
|
|
206
|
+
> 大部分开关没有可显示的内容,三档看起来会几乎一样 —— 这是正确的,不是开关失灵。
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
116
210
|
## 产物长什么样
|
|
117
211
|
|
|
118
212
|
- 单个 `.html` 文件,文件名 `share-{标题slug}-{id8}-{yyyymmdd-HHmm}.html`
|
|
119
213
|
- 无 `<script>`、无 `<link>`、无 `<img>` 外链
|
|
120
214
|
- 深浅主题跟随系统偏好
|
|
121
|
-
-
|
|
215
|
+
- 文件附件只显示名称 / 类型 / 大小,不含字节内容
|
|
216
|
+
- 每轮末尾的「已编辑 N 个文件 +x −y」摘要可展开查看逐文件行数(受上面的限制影响)
|
|
217
|
+
|
|
218
|
+
---
|
|
122
219
|
|
|
123
220
|
## 已知限制
|
|
124
221
|
|
|
125
222
|
- **仅 Web**:`dsh.client.platform` 为 `web`,暂不支持其他端。
|
|
126
223
|
- **locale 未接线**:`locale/*.json` 已备好,但界面文案目前是中文硬编码,非中文用户看到的是中文。
|
|
127
224
|
- **体积**:「完整」档产物中约 90% 是工具结果原文(这本就是该档的定义)。几十轮带大量工具调用的会话可到数百 KB;只要结论请选「对话」档。
|
|
225
|
+
- **文件改动摘要受限于 Host 内存**:DSH 的 `workspace/changes` 事件只记录轮次号,改动明细缓存在 Host 进程内存里。重启 DSH 后再导出旧会话,这一块拿不到(此时不显示,而不是显示成「没有改动」)。
|
|
226
|
+
|
|
227
|
+
---
|
|
128
228
|
|
|
129
229
|
## 开发
|
|
130
230
|
|
|
131
231
|
```bash
|
|
132
232
|
npm install # 只有一个 devDependency:esbuild
|
|
133
233
|
npm run build # 把 src/host 打包成 lib/kernel.js
|
|
134
|
-
npm test #
|
|
234
|
+
npm test # 230 条测试
|
|
135
235
|
```
|
|
136
236
|
|
|
137
237
|
测试只需 Node 内置 `node:test`,但 `build` 需要 esbuild。
|
|
@@ -154,21 +254,28 @@ lib/
|
|
|
154
254
|
index.js Host 半:注册 /api/share-html/* 路由
|
|
155
255
|
kernel.js 构建产物(勿手改)
|
|
156
256
|
client.js 浏览器半:header 按钮 + 弹窗 + 下载
|
|
157
|
-
test/
|
|
257
|
+
test/ 230 条测试
|
|
158
258
|
scripts/
|
|
159
259
|
build.mjs 内核打包
|
|
160
260
|
snapshot-tokens.mjs 从 DSH 主题包抽取设计令牌
|
|
161
261
|
replay.ts 拿真实会话日志回放
|
|
262
|
+
publish-npm.sh 发 npm 并校验 registry 上的包
|
|
263
|
+
release.sh 建 GitHub Release,资产取 npm 上那一份
|
|
162
264
|
```
|
|
163
265
|
|
|
164
266
|
⚠️ `lib/kernel.js` 是构建产物,改逻辑要改 `src/host/` 再重新 build。
|
|
165
267
|
|
|
166
268
|
</details>
|
|
167
269
|
|
|
270
|
+
---
|
|
271
|
+
|
|
168
272
|
## 相关文档
|
|
169
273
|
|
|
274
|
+
- [INSTALL.md](./INSTALL.md) —— 安装指引:三种装法、排错、版本说明
|
|
170
275
|
- [DESIGN.md](./DESIGN.md) —— 设计文档:需求、数据模型、阶段划分
|
|
171
|
-
- [
|
|
276
|
+
- [DEV.md](./DEV.md) —— 本地开发、热更新、发版流程
|
|
277
|
+
- [CONVENTIONS.md](./CONVENTIONS.md) —— 提交与发版约定、踩坑记录
|
|
278
|
+
- [KNOWN-ISSUES.md](./KNOWN-ISSUES.md) —— 已知问题清单
|
|
172
279
|
|
|
173
280
|
## 许可
|
|
174
281
|
|
package/lib/client.js
CHANGED
|
@@ -26,6 +26,14 @@ window.__ModuleLoader__.load({
|
|
|
26
26
|
var useRef = React.useRef
|
|
27
27
|
|
|
28
28
|
var SLOT_ACTIONS = 'conversation.session.header.actions'
|
|
29
|
+
/**
|
|
30
|
+
* 每轮工具栏(复制 / 赞踩 / 分支那一行)的插槽。
|
|
31
|
+
*
|
|
32
|
+
* owner props 只有 `{ messageId }`,但插槽 scope 是 'session',
|
|
33
|
+
* 宿主会把 sessionId 一并注进来 —— 弹窗需要它。
|
|
34
|
+
* 位置在「复制」与「分支」之间(见 DSH 的 MessageIconActions.extraActions)。
|
|
35
|
+
*/
|
|
36
|
+
var SLOT_TURN_ACTIONS = 'conversation.chat.assistant-actions'
|
|
29
37
|
|
|
30
38
|
// ---- 令牌:与导出产物同源(DSH 宿主内它们本来就有效,可直接引用变量) ------
|
|
31
39
|
var RADIUS_SM = 'var(--dsw-radius-sm, 8px)'
|
|
@@ -809,6 +817,69 @@ window.__ModuleLoader__.load({
|
|
|
809
817
|
])
|
|
810
818
|
}
|
|
811
819
|
|
|
820
|
+
/**
|
|
821
|
+
* 每轮工具栏里的「分享」按钮。
|
|
822
|
+
*
|
|
823
|
+
* 与左上角那个共用同一个弹窗,只是入口更贴近内容 —— 读者看完某一轮想导出时,
|
|
824
|
+
* 视线就在这条工具栏上。
|
|
825
|
+
*
|
|
826
|
+
* 图标用内联 SVG(导出箭头),不依赖宿主图标库,避免不同 DSH 版本缺图标时白屏。
|
|
827
|
+
*/
|
|
828
|
+
function ShareTurnAction(props) {
|
|
829
|
+
var sessionId = props.sessionId
|
|
830
|
+
|| (props.session && (props.session.id || props.session.sessionId))
|
|
831
|
+
|| props.session_id
|
|
832
|
+
var ctx = props.ctx
|
|
833
|
+
var openState = useState(false)
|
|
834
|
+
var open = openState[0]
|
|
835
|
+
var setOpen = openState[1]
|
|
836
|
+
|
|
837
|
+
var Portal = function (child) {
|
|
838
|
+
if (typeof document === 'undefined') return null
|
|
839
|
+
var host = document.getElementById('dsh-share-html-root')
|
|
840
|
+
if (!host) {
|
|
841
|
+
host = document.createElement('div')
|
|
842
|
+
host.id = 'dsh-share-html-root'
|
|
843
|
+
document.body.appendChild(host)
|
|
844
|
+
}
|
|
845
|
+
return require('react-dom').createPortal(child, host)
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// 图标用 DSH 自己的 share-outline(SVG 路径逐字取自
|
|
849
|
+
// @deepseek-ai/dsh-client-ui-primitives 的 IconShareOutlineRegular),
|
|
850
|
+
// 这样与宿主里其它分享入口的图形一致 —— 先前手画的向下箭头看起来像「下载」。
|
|
851
|
+
var icon = h('svg', {
|
|
852
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
853
|
+
viewBox: '0 0 16 16',
|
|
854
|
+
fill: 'none',
|
|
855
|
+
stroke: 'currentColor',
|
|
856
|
+
strokeWidth: 1,
|
|
857
|
+
'aria-hidden': 'true',
|
|
858
|
+
}, h('path', {
|
|
859
|
+
d: 'M14.1256 7.58723C14.3483 7.81942 14.3482 8.18589 14.1254 8.41799L8.6646 14.1077C8.53985 14.2377 8.32031 14.1494 8.32031 13.9692L8.32035 10.2039C8.32035 10.1943 8.31534 10.1864 8.30592 10.1849C8.08306 10.148 5.30067 9.7729 1.50993 13.2904C1.49711 13.3023 1.47561 13.2943 1.4757 13.2768C1.49273 9.87168 3.42001 5.07166 8.29999 5.05835C8.31103 5.05832 8.32035 5.04937 8.32035 5.03832L8.32031 2.03109C8.32031 1.85088 8.53993 1.76259 8.66466 1.89266L14.1256 7.58723Z',
|
|
860
|
+
}))
|
|
861
|
+
|
|
862
|
+
return h(React.Fragment, null, [
|
|
863
|
+
h('button', {
|
|
864
|
+
key: 'btn',
|
|
865
|
+
type: 'button',
|
|
866
|
+
// 与 DSH 的 MessageIconActions 图标按钮同一套外观:无边框、悬停浮底色
|
|
867
|
+
className: 'dsh-share-html-turn-action',
|
|
868
|
+
title: sessionId ? '导出当前会话为离线 HTML' : '当前没有可导出的会话',
|
|
869
|
+
'aria-label': '分享',
|
|
870
|
+
disabled: !sessionId,
|
|
871
|
+
onClick: function () { if (sessionId) setOpen(true) },
|
|
872
|
+
}, icon),
|
|
873
|
+
open && sessionId
|
|
874
|
+
? Portal(h(Dialog, {
|
|
875
|
+
ctx: ctx,
|
|
876
|
+
sessionId: sessionId,
|
|
877
|
+
onClose: function () { setOpen(false) },
|
|
878
|
+
}))
|
|
879
|
+
: null,
|
|
880
|
+
])
|
|
881
|
+
}
|
|
882
|
+
|
|
812
883
|
// ---- 注册 ---------------------------------------------------------------
|
|
813
884
|
//
|
|
814
885
|
// 插槽 API(对照 dsh-client-ui-jobs 的真实用法):
|
|
@@ -819,7 +890,45 @@ window.__ModuleLoader__.load({
|
|
|
819
890
|
exports.name = 'dsh-share-html/client'
|
|
820
891
|
exports.inject = ['slots', 'connection']
|
|
821
892
|
|
|
893
|
+
/**
|
|
894
|
+
* 每轮工具栏按钮的样式:与 DSH 的 MessageIconActions 图标按钮同一套外观
|
|
895
|
+
* (28px 见方、无边框、tertiary 色、悬停浮底色)。
|
|
896
|
+
* 只注入一次 —— 插槽可能重挂载,重复插入会让 <style> 越积越多。
|
|
897
|
+
*/
|
|
898
|
+
var TURN_ACTION_CSS = [
|
|
899
|
+
'.dsh-share-html-turn-action{',
|
|
900
|
+
'display:inline-flex;align-items:center;justify-content:center;',
|
|
901
|
+
'width:28px;height:28px;padding:6px;',
|
|
902
|
+
'border:none;border-radius:var(--dsw-radius-sm,8px);',
|
|
903
|
+
'background:transparent;color:var(--dsw-alias-label-tertiary,#81858c);',
|
|
904
|
+
'cursor:pointer;transition:background 100ms ease,color 100ms ease;',
|
|
905
|
+
'}',
|
|
906
|
+
'.dsh-share-html-turn-action:hover:not(:disabled){',
|
|
907
|
+
'background:var(--dsw-alias-interactive-bg-hover,rgba(0,0,0,.05));',
|
|
908
|
+
'color:var(--dsw-alias-label-secondary,#61666b);',
|
|
909
|
+
'}',
|
|
910
|
+
// 与邻居图标同尺寸(DSH 的 .action svg 是 15px + 字号增量)
|
|
911
|
+
'.dsh-share-html-turn-action svg{',
|
|
912
|
+
'width:calc(15px + var(--dsh-content-font-delta, 0px));',
|
|
913
|
+
'height:calc(15px + var(--dsh-content-font-delta, 0px));',
|
|
914
|
+
'}',
|
|
915
|
+
'.dsh-share-html-turn-action:disabled{opacity:.4;cursor:default;}',
|
|
916
|
+
'.dsh-share-html-turn-action:focus-visible{',
|
|
917
|
+
'outline:none;box-shadow:inset 0 0 0 2px var(--dsw-focus-ring-color,#4d6bfe);',
|
|
918
|
+
'}',
|
|
919
|
+
].join('')
|
|
920
|
+
|
|
921
|
+
function injectTurnActionStyle() {
|
|
922
|
+
if (typeof document === 'undefined') return
|
|
923
|
+
if (document.getElementById('dsh-share-html-turn-style')) return
|
|
924
|
+
var el = document.createElement('style')
|
|
925
|
+
el.id = 'dsh-share-html-turn-style'
|
|
926
|
+
el.textContent = TURN_ACTION_CSS
|
|
927
|
+
document.head.appendChild(el)
|
|
928
|
+
}
|
|
929
|
+
|
|
822
930
|
exports.apply = function apply(ctx) {
|
|
931
|
+
injectTurnActionStyle()
|
|
823
932
|
ctx.slots.inject(SLOT_ACTIONS, function () {
|
|
824
933
|
return ctx.slots.register({
|
|
825
934
|
name: SLOT_ACTIONS,
|
|
@@ -837,6 +946,31 @@ window.__ModuleLoader__.load({
|
|
|
837
946
|
}, ShareHeaderAction)
|
|
838
947
|
})
|
|
839
948
|
console.log('[dsh-share-html] registered share button on ' + SLOT_ACTIONS)
|
|
949
|
+
|
|
950
|
+
// 每轮工具栏里的入口。插槽是 'list' 类型,同一 session 下每个 messageId
|
|
951
|
+
// 都会渲染一次;id 用固定值,避免重复注册。
|
|
952
|
+
try {
|
|
953
|
+
ctx.slots.inject(SLOT_TURN_ACTIONS, function () {
|
|
954
|
+
return ctx.slots.register({
|
|
955
|
+
name: SLOT_TURN_ACTIONS,
|
|
956
|
+
id: 'share-html-turn',
|
|
957
|
+
order: 20,
|
|
958
|
+
locale: null,
|
|
959
|
+
inject: function () {
|
|
960
|
+
return {
|
|
961
|
+
ctx: ctx,
|
|
962
|
+
shareInvoke: function (method, args) {
|
|
963
|
+
return invoke(ctx, method, args)
|
|
964
|
+
},
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
}, ShareTurnAction)
|
|
968
|
+
})
|
|
969
|
+
console.log('[dsh-share-html] registered share button on ' + SLOT_TURN_ACTIONS)
|
|
970
|
+
} catch (error) {
|
|
971
|
+
// 老版本 DSH 可能没有这个插槽:左上角的按钮仍可用,不影响导出
|
|
972
|
+
console.warn('[dsh-share-html] turn action slot unavailable:', error && error.message)
|
|
973
|
+
}
|
|
840
974
|
}
|
|
841
975
|
|
|
842
976
|
return module.exports
|
package/lib/index.js
CHANGED
|
@@ -44,9 +44,23 @@ export function apply(ctx) {
|
|
|
44
44
|
workspaceChanges = undefined
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// attachments 同样是可选服务。导出时用它把图片重编码成缩略图 ——
|
|
48
|
+
// DSH 内部用 sharp 做解码/缩放/压缩,插件因此不需要任何图像库依赖。
|
|
49
|
+
// 漏接这个服务会让所有图片退化成 IMG 文字卡片(曾经就是这样)。
|
|
50
|
+
let attachments
|
|
51
|
+
try {
|
|
52
|
+
attachments = typeof ctx.get === "function" ? ctx.get("attachments") : undefined
|
|
53
|
+
} catch {
|
|
54
|
+
attachments = undefined
|
|
55
|
+
}
|
|
56
|
+
if (!attachments) {
|
|
57
|
+
log("[dsh-share-html] attachments service unavailable — images will render as placeholders")
|
|
58
|
+
}
|
|
59
|
+
|
|
47
60
|
const handlers = createHandlers({
|
|
48
61
|
sessionQuery: ctx.sessionQuery,
|
|
49
62
|
...(workspaceChanges ? { workspaceChanges } : {}),
|
|
63
|
+
...(attachments ? { attachments } : {}),
|
|
50
64
|
...(logger ? { logger } : {}),
|
|
51
65
|
})
|
|
52
66
|
|