@ggboy123/dsh-paper-reader 1.3.0 → 1.3.2
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 +2 -2
- package/dist/host.js +13 -4
- package/lib/client.js +11 -0
- package/package.json +1 -1
- package/reader/index.html +7 -0
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
**DeepSeek 官方桌面端**([deepseek.com/download](https://www.deepseek.com/download/) 下载,即 DeepSeek Harness 桌面版):
|
|
43
43
|
|
|
44
44
|
1. 安装并启动,登录 DeepSeek 账号
|
|
45
|
-
2. 侧栏 → **插件** → **添加插件**,输入 `@ggboy123/dsh-paper-reader@1.3.
|
|
45
|
+
2. 侧栏 → **插件** → **添加插件**,输入 `@ggboy123/dsh-paper-reader@1.3.2` 安装
|
|
46
46
|
3. 装完默认**停用**:点进插件详情,打开「启用」开关
|
|
47
47
|
4. **重启桌面端**(热启用状态下打开论文的链路会静默失效,重启进开机组合才正常,实测)
|
|
48
48
|
|
|
@@ -69,7 +69,7 @@ dsh plugin --profile web add @ggboy123/dsh-paper-reader
|
|
|
69
69
|
**已装过的用户升级必须带显式版本号**——不带版本的 `add` 对已存在的依赖是 no-op(pnpm 按首次安装时记录的版本范围解析,不会追新):
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
dsh plugin --profile web add @ggboy123/dsh-paper-reader@1.3.
|
|
72
|
+
dsh plugin --profile web add @ggboy123/dsh-paper-reader@1.3.2
|
|
73
73
|
# 重启 dsh web 生效;浏览器 Cmd+Shift+R 强刷,避免旧阅读器页面缓存
|
|
74
74
|
```
|
|
75
75
|
|
package/dist/host.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// host.ts — webServer 路由:阅读器页面 + PDF 文件 + 转录数据接口 + 选中即问。
|
|
2
2
|
// 壳层代码:只做 HTTP ↔ 纯函数核心(library/transcribe)的转接。
|
|
3
|
-
import { createReadStream } from 'node:fs';
|
|
3
|
+
import { createReadStream, readFileSync } from 'node:fs';
|
|
4
4
|
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
6
|
import { basename, join } from 'node:path';
|
|
@@ -44,6 +44,8 @@ export function registerRoutes(ctx, config) {
|
|
|
44
44
|
// dist/host.js → 包根/reader/index.html
|
|
45
45
|
const readerHtml = new URL('../reader/index.html', import.meta.url);
|
|
46
46
|
const readerVendorDir = new URL('../reader/vendor/', import.meta.url);
|
|
47
|
+
// 插件版本(读包根 package.json,注入阅读器顶栏——用户截图反馈时一眼可见)
|
|
48
|
+
const pluginVersion = 'v' + JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
47
49
|
// 自带「论文伴读」agent preset → $DSH_HOME/.agent-presets/(实时扫描,免重启);
|
|
48
50
|
// 失败(旧版 dsh/无权限)则回退默认 preset,功能不受影响。
|
|
49
51
|
const presetDir = installPaperPreset(new URL('../', import.meta.url));
|
|
@@ -145,8 +147,15 @@ export function registerRoutes(ctx, config) {
|
|
|
145
147
|
const dispatch = async (req, res, url) => {
|
|
146
148
|
const sub = url.pathname.slice('/paper-reader'.length); // '' | '/' | '/api/...'
|
|
147
149
|
if ((sub === '' || sub === '/') && req.method === 'GET') {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
// no-cache:桌面端 webview 无法强刷(README 里浏览器 Cmd+Shift+R 的建议对桌面端
|
|
151
|
+
// 无效),不带缓存头时升级插件后用户会一直看到缓存的旧阅读器页面(实测空白 bug
|
|
152
|
+
// 「修了还在」正是这个)。版本号注入供用户截图反馈时一眼对版本。
|
|
153
|
+
const html = (await readFile(readerHtml)).toString('utf8').replaceAll('__DPR_VERSION__', pluginVersion);
|
|
154
|
+
res.writeHead(200, {
|
|
155
|
+
'content-type': 'text/html; charset=utf-8',
|
|
156
|
+
'content-length': Buffer.byteLength(html),
|
|
157
|
+
'cache-control': 'no-cache',
|
|
158
|
+
});
|
|
150
159
|
res.end(html);
|
|
151
160
|
return;
|
|
152
161
|
}
|
|
@@ -160,7 +169,7 @@ export function registerRoutes(ctx, config) {
|
|
|
160
169
|
const mime = { '.mjs': 'text/javascript', '.js': 'text/javascript', '.css': 'text/css', '.map': 'application/json' };
|
|
161
170
|
try {
|
|
162
171
|
const body = await readFile(new URL(name, readerVendorDir));
|
|
163
|
-
res.writeHead(200, { 'content-type': (mime[name.slice(name.lastIndexOf('.'))] ?? 'application/octet-stream') + '; charset=utf-8', 'content-length': body.length, 'cache-control': '
|
|
172
|
+
res.writeHead(200, { 'content-type': (mime[name.slice(name.lastIndexOf('.'))] ?? 'application/octet-stream') + '; charset=utf-8', 'content-length': body.length, 'cache-control': 'no-cache' });
|
|
164
173
|
res.end(body);
|
|
165
174
|
}
|
|
166
175
|
catch {
|
package/lib/client.js
CHANGED
|
@@ -268,6 +268,17 @@ window.__ModuleLoader__.load({
|
|
|
268
268
|
// 阅读器整个右移并变窄(实测 x=800 w=300,而列是 280..1100)。
|
|
269
269
|
// 只补 minWidth,不碰 width:dsh 每次会话提交都重写内联 width,抢同一属性会持续闪烁。
|
|
270
270
|
setStyle(panel, 'minWidth', eff ? '100%' : '')
|
|
271
|
+
// 全屏态层级修复(用户实测「点全屏放大后一片白」):dsh 的页签宿主 ._tabCell
|
|
272
|
+
// z-index 是 var(--dsh-dockkit-dock-layer, 10),全屏时该变量被抬到 40——但只定义在
|
|
273
|
+
// 右栏**面板**(P3OORG_panel)子树上,把本阅读器 z-10 的悬浮 iframe 压在下面:
|
|
274
|
+
// iframe 里页面活着、工具栏都在,却被白色 tab 宿主盖住。⚠️ 变量不从列/帧继承,
|
|
275
|
+
// body 级 iframe 拿到的是回落值 10——必须从 panel 上现读实际值再 +2:
|
|
276
|
+
// 盖回 tabCell、仍低于对话头部浮动按钮 45(全屏下拖拽手柄本就隐藏);
|
|
277
|
+
// 非全屏回 10(低于手柄 11 与 overlayLayer 20)。
|
|
278
|
+
if (readerIframeEl) {
|
|
279
|
+
const dockLayer = parseFloat(getComputedStyle(panel).getPropertyValue('--dsh-dockkit-dock-layer')) || 10
|
|
280
|
+
setStyle(readerIframeEl, 'zIndex', frame.hasAttribute('data-rightbar-fullscreen') ? String(dockLayer + 2) : '10')
|
|
281
|
+
}
|
|
271
282
|
}
|
|
272
283
|
const tick = () => {
|
|
273
284
|
if (!alive) return
|
package/package.json
CHANGED
package/reader/index.html
CHANGED
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
#pager { display: flex; align-items: center; gap: 4px; flex: none; }
|
|
49
49
|
#page-input { width: 3.5em; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); font: inherit; font-size: 12.5px; text-align: right; }
|
|
50
50
|
#page-total { flex: none; color: var(--text-2); font-size: 12px; white-space: nowrap; }
|
|
51
|
+
/* 插件版本号(host 注入;未被替换时隐藏——比如旧 host 配新页面的错位场景) */
|
|
52
|
+
#ver { flex: none; font-size: 10.5px; color: var(--text-2); opacity: .65; user-select: none; }
|
|
51
53
|
.page { position: relative; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
|
|
52
54
|
.page.flash { outline: 3px solid var(--hl); outline-offset: 2px; transition: outline .15s; }
|
|
53
55
|
/* textLayer CSS 必须是 pdf.js 6.x 官方规则的子集:TextLayer 只往 span 写 --font-height/--scale-x/--rotate
|
|
@@ -126,6 +128,7 @@
|
|
|
126
128
|
<span id="zoom-label">100%</span>
|
|
127
129
|
<button id="zoom-in" class="tbtn">+</button>
|
|
128
130
|
<button id="zoom-fit" class="tbtn">适宽</button>
|
|
131
|
+
<span id="ver" title="插件版本">__DPR_VERSION__</span>
|
|
129
132
|
</div>
|
|
130
133
|
|
|
131
134
|
<div id="main">
|
|
@@ -871,7 +874,11 @@ bootstrap().catch((e) => {
|
|
|
871
874
|
$('empty').textContent = '文献库加载失败:' + e.message;
|
|
872
875
|
});
|
|
873
876
|
|
|
877
|
+
// 版本号未被 host 注入(旧宿主配新页面的错位场景)时藏掉占位符
|
|
878
|
+
if (!/^v\d/.test(document.getElementById('ver').textContent)) document.getElementById('ver').style.display = 'none';
|
|
879
|
+
|
|
874
880
|
window.dpr = {
|
|
881
|
+
version: document.getElementById('ver').textContent,
|
|
875
882
|
openPaper: (topic, name, page, q) => openPaper(topic, name, { page, q }),
|
|
876
883
|
jumpToPage,
|
|
877
884
|
// 伴读会话的跳转链接用:当前文档里原地跳转,不重载 —— 用户正在看中文版就落在中文版;
|