dsh-reload-buttons 0.1.2 → 0.1.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/README.en.md CHANGED
@@ -39,7 +39,7 @@ Restart DSH afterwards. Replace `desktop` with your own profile name if you use
39
39
 
40
40
  Requirements: the DSH desktop app (the restart button needs the shell to close and relaunch). On `dsh web` the reload button works and restart just ends the kernel process. Node follows DSH; no extra runtime is needed.
41
41
 
42
- Compatible with the DSH 0.2.1 line (alpha / rc / stable); 0.3 and later are not guaranteed.
42
+ Requires DSH >= 0.2.1-alpha.3; verified on 0.2.1-alpha.3 and 0.2.2-rc.1, later versions untested.
43
43
 
44
44
  ## Where the buttons live
45
45
 
@@ -78,6 +78,13 @@ npm run smoke # structure / registration / authorization / artifact
78
78
 
79
79
  Build rules: keep `react` and `react/jsx-runtime` external (the DSH client module table provides them); the `id` inside the `window.__ModuleLoader__.load({ id, factory })` envelope must equal the package name.
80
80
 
81
+ ## Feedback
82
+
83
+ - Open an issue: https://github.com/taoziliyouchong/dsh-reload-buttons/issues — searchable, and others can help.
84
+ - Or reach me on QQ: **2171960697** (mention which plugin you installed when adding the contact).
85
+
86
+ Please include: DSH version, plugin version, the exact error text, and a screenshot.
87
+
81
88
  ## License
82
89
 
83
90
  MIT
package/README.md CHANGED
@@ -39,7 +39,7 @@ dsh plugin --profile desktop add dsh-reload-buttons
39
39
 
40
40
  要求:DSH 桌面端(重启按钮要关壳重开)。`dsh web` 下刷新可用,重启等于结束内核进程。Node 版本跟随 DSH,不需要额外运行时。
41
41
 
42
- 兼容:DSH 0.2.1 系列(alpha / rc / 正式版均可);0.3 起不保证。
42
+ 要求 DSH >= 0.2.1-alpha.3;实测 0.2.1-alpha.3、0.2.2-rc.1,更高版本未验证。
43
43
 
44
44
  ## 界面位置
45
45
 
@@ -50,6 +50,7 @@ dsh plugin --profile desktop add dsh-reload-buttons
50
50
  - 宿主半边注册一条 `POST /dsh-reload-buttons/api/restart`:只接受回环地址(`127.*`、`::1`、`::ffff:127.*`),只接受 POST。远程访问的 DSH 上点重启会被 403 拒绝。
51
51
  - 桌面端把重启交棒给 `assets/restart-app.mjs`(detached spawn):等 1.2 秒让 HTTP 响应交回浏览器 → 关掉 Electron 主进程 → 等端口释放(12 秒不放就结束内核)→ 拉起 exe 并按新进程 pid 探活(8 秒不稳就再试一次)。
52
52
  - 桌面端每次启动端口都不同,探活只看进程 pid,不看端口。
53
+ - 拉起 exe 之前顺手清一次累积的 `dsh-auth-*` 会话 Cookie(超过 30 条才清,先备份):桌面端每次启动换端口,Cookie 名里编着「域名:端口」,而 Cookie 按域名存、不区分端口——每启动一次多一条,堆到约 70 条、请求头过 16 KB 后,下次启动会报 `desktop welcome: Web authentication failed`。清不了只记日志,不影响重启。
53
54
  - 重启日志写在 `$DSH_HOME/logs/dsh-reload-buttons-restart.log`。
54
55
  - 刷新按钮是纯浏览器侧行为,不需要宿主。
55
56
  - 不联网、不上传任何内容。
@@ -78,6 +79,15 @@ npm run smoke # 结构 / 注册 / 鉴权 / 产物 四关
78
79
 
79
80
  打包要求:`react` 与 `react/jsx-runtime` 保持 external(由 DSH 客户端模块表提供);产物外壳 `window.__ModuleLoader__.load({ id, factory })` 里的 `id` 必须等于包名。
80
81
 
82
+ ## 反馈
83
+
84
+ 插件有问题,按这个顺序:
85
+
86
+ 1. 开 Issue:https://github.com/taoziliyouchong/dsh-reload-buttons/issues —— 能留痕、能搜历史,别人也可能已经遇过;
87
+ 2. 急着问或不想开 Issue,QQ 号:**2171960697**(加好友请注明装的是哪个插件)。
88
+
89
+ 反馈时带上:DSH 版本、插件版本、报错原文、截图。少一样多半要再问一轮。
90
+
81
91
  ## 许可
82
92
 
83
93
  MIT
@@ -79,7 +79,45 @@ if (!released) {
79
79
  }
80
80
  log(`port ${released ? 'released' : 'STILL BUSY'}`)
81
81
 
82
- // 4) 重新拉起应用
82
+ // 4) 清一次累积的浏览器会话 Cookie。此刻应用已完全退出,数据库没人占着。
83
+ // DSH 每次启动换端口,Cookie 名里编着「域名:端口」,而 Cookie 按域名存、不区分端口,
84
+ // 所以每启动一次多一条;堆到约 70 条、请求头过 16 KB,下次启动会报认证失败。
85
+ async function pruneAuthCookies() {
86
+ try {
87
+ const { DatabaseSync } = await import('node:sqlite')
88
+ const { join } = await import('node:path')
89
+ const { homedir } = await import('node:os')
90
+ const { existsSync, copyFileSync } = await import('node:fs')
91
+ const dbPath = join(homedir(), 'AppData', 'Roaming', '@deepseek-ai', 'dsh-desktop', 'Network', 'Cookies')
92
+ if (!existsSync(dbPath)) {
93
+ log('cookie db missing, skip')
94
+ return
95
+ }
96
+ const db = new DatabaseSync(dbPath)
97
+ const count = () => db.prepare(
98
+ "select count(*) as n from cookies where host_key = '127.0.0.1' and name like 'dsh-auth-%'",
99
+ ).get().n
100
+ const before = count()
101
+ if (before <= 30) {
102
+ db.close()
103
+ log(`cookies ${before} <= 30, skip`)
104
+ return
105
+ }
106
+ const stamp = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)
107
+ copyFileSync(dbPath, `${dbPath}.bak-${stamp}`)
108
+ db.exec("delete from cookies where host_key = '127.0.0.1' and name like 'dsh-auth-%'")
109
+ db.exec('vacuum')
110
+ const after = count()
111
+ db.close()
112
+ log(`cookies pruned ${before} -> ${after}`)
113
+ } catch (error) {
114
+ // 清不了不影响重启:重启本身必须先完成。
115
+ log(`cookie prune skipped: ${error.message}`)
116
+ }
117
+ }
118
+ await pruneAuthCookies()
119
+
120
+ // 5) 重新拉起应用
83
121
  if (!exePath) {
84
122
  log('no exe path, stop')
85
123
  process.exit(1)
@@ -121,7 +159,7 @@ async function waitAlive(pid, ms) {
121
159
 
122
160
  const first = launchApp('first launch')
123
161
 
124
- // 5) 起来了吗?起不来就再试一次(第二次失败只能让用户手动开)
162
+ // 6) 起来了吗?起不来就再试一次(第二次失败只能让用户手动开)
125
163
  if (await waitAlive(first.pid, 8000)) {
126
164
  log(`ok: app is back (pid ${first.pid} alive)`)
127
165
  process.exit(0)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-reload-buttons",
3
- "version": "0.1.2",
4
- "description": "在界面左上角放两个按钮:刷新界面与重启应用——刷新按需整页重载或就地重同步插件,不给白屏;重启在桌面端关掉界面壳后自动重开,在 dsh web 下结束内核交给你的守护进程。",
3
+ "version": "0.1.4",
4
+ "description": "在 DSH 界面左上角放两个按钮:刷新界面、重启应用。",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "exports": {
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "engines": {
26
26
  "node": "^22.19.0 || >=24.0.0",
27
- "dsh": ">=0.2.1-0 <0.3.0-0"
27
+ "dsh": ">=0.2.1-0"
28
28
  },
29
29
  "dsh": {
30
30
  "client": {
@@ -53,6 +53,7 @@
53
53
  "devDependencies": {
54
54
  "esbuild": "^0.28.1"
55
55
  },
56
+ "author": "taoziliyouchong",
56
57
  "license": "MIT",
57
58
  "repository": {
58
59
  "type": "git",