dsh-web-jump 0.0.0-stage → 0.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/LICENSE +20 -0
- package/README.md +172 -2
- package/client.js +924 -0
- package/cordis.patch.yml +3 -0
- package/docs/cookie-iframe-test.png +0 -0
- package/docs//345/256/236/347/216/260/346/226/271/346/241/210.md +258 -0
- package/icon.svg +6 -0
- package/index.js +1 -0
- package/locale/en.json +8 -0
- package/locale/zh.json +8 -0
- package/package.json +50 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 baianInfo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,173 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-web-jump
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
给 DeepSeek Harness(DSH)用的侧边栏插件:把外部工作台页面嵌进 DSH 侧边栏,**切换页面不重新加载**,并支持「点域名直接开一个新会话」。
|
|
4
|
+
|
|
5
|
+
一个插件注册两个侧边栏入口:
|
|
6
|
+
|
|
7
|
+
| 入口 | 面板 id | 内容 |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| 网站跳转 | `web-jump` | 除「信息服务」以外的站点(默认:监督检查、通报预警、互联网服务主体) |
|
|
10
|
+
| 信息服务 | `web-info` | 只放「信息服务」站点 |
|
|
11
|
+
|
|
12
|
+
> 两个入口共享同一个 iframe 常驻池,来回切换都不重载,滚动位置、分页、筛选条件都保留。
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
### 方式一:拿到 `.tgz` 安装(推荐给别的项目)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# 1) 在插件目录打包
|
|
20
|
+
npm pack # 产出 dsh-web-jump-0.1.0.tgz
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
把 tgz 拷到目标机器,然后二选一:
|
|
24
|
+
|
|
25
|
+
**GUI**:DSH 设置 → 插件 → 安装本地包 → 选中 `.tgz`。
|
|
26
|
+
|
|
27
|
+
**CLI**(`dsh.cmd` 在 DSH 安装目录 `resources\runtime\cli\bin\` 下):
|
|
28
|
+
|
|
29
|
+
```powershell
|
|
30
|
+
"<DSH安装目录>\resources\runtime\cli\bin\dsh.cmd" plugin --profile <profile名> add <tgz的绝对路径>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
装完还要把这个包名登记到 profile 的 `package.json`(CLI 只装依赖,不改 bundles):
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
// ~/.dsh/profiles/<profile>/package.json
|
|
37
|
+
"dsh": { "profile": { "bundles": [ "...", "dsh-web-jump" ] } }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
然后**重启 DSH**(插件是启动时加载的)。
|
|
41
|
+
|
|
42
|
+
### 方式二:`link:` 本地开发
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
// ~/.dsh/profiles/<profile>/package.json
|
|
46
|
+
"dsh-web-jump": "link:/绝对路径/dsh-web-jump"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
源码即产物,改完重启 DSH 就生效,适合还在调插件的阶段。缺点:只在本机有效、路径写死。
|
|
50
|
+
|
|
51
|
+
### 方式三:npm
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm publish # 名字 dsh-web-jump 目前未被占用
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
对方:`dsh.cmd plugin --profile <name> add dsh-web-jump`,同样要登记 `bundles` 再重启。
|
|
58
|
+
|
|
59
|
+
## 每个项目怎么配自己的站点
|
|
60
|
+
|
|
61
|
+
站点地址**不写在代码里**也能改,两种方式:
|
|
62
|
+
|
|
63
|
+
### A. 面板里改(运行时,最省事)
|
|
64
|
+
|
|
65
|
+
打开「网站跳转」→ 右上角 **⚙** → 编辑 JSON → 保存。配置存在本机 `localStorage`(键 `dsh-web-jump:config`),保存后 iframe 重建一次,而且**立刻生效、不用重启 DSH**。
|
|
66
|
+
|
|
67
|
+
### B. 改默认值(随插件分发,适合固化到某个项目)
|
|
68
|
+
|
|
69
|
+
编辑 `client.js` 顶部的 `DEFAULT_CONFIG`:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const DEFAULT_CONFIG = {
|
|
73
|
+
appOrigin: 'https://kqydya.baianinfo.com:8043',
|
|
74
|
+
base: '', // 留空 = appOrigin + '/gptclient/index.html'
|
|
75
|
+
sites: [
|
|
76
|
+
{ id: 'hlwInspection', label: '监督检查', route: '/standalone/hlwInspection' },
|
|
77
|
+
{ id: 'xJearlyManage', label: '通报预警', route: '/standalone/xJearlyManage' },
|
|
78
|
+
{ id: 'information', label: '信息服务', route: '/standalone/information' },
|
|
79
|
+
{ id: 'unitList', label: '互联网服务主体', route: '/standalone/unitList' },
|
|
80
|
+
],
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 配置格式
|
|
85
|
+
|
|
86
|
+
```jsonc
|
|
87
|
+
{
|
|
88
|
+
"appOrigin": "https://kqydya.baianinfo.com:8043", // 站点源,用于 token 单点与消息校验
|
|
89
|
+
"base": "", // 留空则 appOrigin + "/gptclient/index.html"
|
|
90
|
+
"sites": [
|
|
91
|
+
// ① 站内 hash 路由:拼成 base#route,登录态走 token 单点
|
|
92
|
+
{ "id": "unitList", "label": "互联网服务主体", "route": "/standalone/unitList" },
|
|
93
|
+
|
|
94
|
+
// ② 任意外部网站:原样加载,不套 token
|
|
95
|
+
{ "id": "sentry", "label": "Sentry", "url": "https://sentry.example.com/" },
|
|
96
|
+
|
|
97
|
+
// ③ infoOnly: true → 只在「信息服务」面板出现
|
|
98
|
+
{ "id": "information", "label": "信息服务", "route": "/standalone/information", "infoOnly": true }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`id` 必须唯一且稳定(它决定页签记忆),`label` 是页签文字,`route` 与 `url` 二选一。
|
|
104
|
+
|
|
105
|
+
## 嵌入的页面要做两件事
|
|
106
|
+
|
|
107
|
+
### 1. 把登录 token 送出来(免二次登录)
|
|
108
|
+
|
|
109
|
+
页面登录成功后:
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
if (window.top !== window.self) {
|
|
113
|
+
window.parent.postMessage(
|
|
114
|
+
{ source: 'dsh-web-jump', type: 'token', token: '<用户 token>' },
|
|
115
|
+
'*'
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
插件收到后存进 cookie `dsh_web_jump_token` + localStorage,并用它拼单点地址:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
{base}#/login?token=<token>&redirect=<route>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
也可以不接这套,直接在面板的 token 输入框里手动填一次。
|
|
127
|
+
|
|
128
|
+
### 2. 域名点击开新会话(可选)
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
window.parent.postMessage({
|
|
132
|
+
source: 'dsh-web-jump',
|
|
133
|
+
type: 'open-chat',
|
|
134
|
+
domain: 'example.com',
|
|
135
|
+
unitName: '某某单位', // 可选
|
|
136
|
+
unitId: '123', // 可选
|
|
137
|
+
}, '*')
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
插件会调 DSH 的 `uiWorkspace.startSession(undefined, { prompt, whenDraftExists: 'replace' })`,**开一个新会话并自动切到聊天面板**,提示词是「请针对这个域名进行智能体分析:example.com(主体名称:某某单位)」。
|
|
141
|
+
|
|
142
|
+
## 免重载是怎么做到的(三条铁律)
|
|
143
|
+
|
|
144
|
+
1. **iframe 只建一次,永不销毁**,存在 body 级容器 `#dsh-web-jump-keepalive` 里;
|
|
145
|
+
2. **永不搬动 iframe 的父节点**——搬动 DOM 就会触发重载;
|
|
146
|
+
3. **隐藏用「移出屏幕」**(`left:-100000px` 但保持宽高),绝不用 `display:none`——那会把 iframe 视口压成 0,滚动位置就丢了。
|
|
147
|
+
|
|
148
|
+
切页签只改 iframe 自身的 `display`,容器位置另由 `syncHolderPosition()` 维护,两者互不干扰。
|
|
149
|
+
|
|
150
|
+
## 常见问题
|
|
151
|
+
|
|
152
|
+
| 现象 | 原因 / 处理 |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| 侧边栏没有这两个入口 | 没重启 DSH;或 profile 里没装(`dsh plugin list` 看一下) |
|
|
155
|
+
| 页面白屏 / 拒绝显示 | 目标站点下发了 `X-Frame-Options: DENY/SAMEORIGIN`;改成 CSP `frame-ancestors` 放行 |
|
|
156
|
+
| 登录后仍跳登录页 | 跨站 iframe 的 cookie 被拦:后端 cookie 需要 `SameSite=None; Secure`,或走上面的 `?token=` 单点 |
|
|
157
|
+
| 某站点总在重载 | 站点自己做了 `frame-ancestors` 校验或每次访问都换 URL;也可能被配成了 `url` 形式且地址带随机参数 |
|
|
158
|
+
| 改了配置没反应 | 面板 ⚙ 保存会自动重建;改 `DEFAULT_CONFIG` 需要重启 DSH |
|
|
159
|
+
| 点域名没反应 | 站点侧没发 `open-chat` 消息,或 `event.origin` 不在 `appOrigin`/站点 `url` 白名单里(插件会丢弃) |
|
|
160
|
+
|
|
161
|
+
## 文件
|
|
162
|
+
|
|
163
|
+
| 文件 | 作用 |
|
|
164
|
+
| --- | --- |
|
|
165
|
+
| `client.js` | 全部 UI 与逻辑(侧边栏入口、面板、iframe 池、配置、token、消息) |
|
|
166
|
+
| `index.js` | Host 侧占位(`apply(){}`,本插件没有服务端逻辑) |
|
|
167
|
+
| `cordis.patch.yml` | 声明把插件插入 DSH 的组合 |
|
|
168
|
+
| `locale/zh.json`、`locale/en.json` | 侧边栏与面板文案 |
|
|
169
|
+
| `docs/实现方案.md` | 设计与实现细节(时序、API 链路、踩坑记录) |
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|