dsh-desktop-windows 0.2.3 → 0.2.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/package.json +1 -1
- package/src/main.js +31 -3
- package/src/screenshot.html +6 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-desktop-windows",
|
|
3
3
|
"productName": "DeepSeek Harness Desktop",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"description": "DeepSeek Harness 桌面版(Windows)· Electron desktop shell for DeepSeek Harness (dsh web) — 双击即用,无需终端 / double-click to run the harness in a standalone window",
|
|
6
6
|
"main": "src/main.js",
|
|
7
7
|
"license": "MIT",
|
package/src/main.js
CHANGED
|
@@ -18,6 +18,7 @@ const { spawn, execFile } = require('node:child_process')
|
|
|
18
18
|
const http = require('node:http')
|
|
19
19
|
const fs = require('node:fs')
|
|
20
20
|
const path = require('node:path')
|
|
21
|
+
const os = require('node:os')
|
|
21
22
|
|
|
22
23
|
const DEFAULT_PORT = 3080
|
|
23
24
|
const START_TIMEOUT_MS = 90_000
|
|
@@ -52,6 +53,15 @@ function log(...args) {
|
|
|
52
53
|
console.log(LOG_PREFIX, ...args)
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
/** 截图流程日志(追加写入 ~/.dsh/logs/screenshot.log,便于诊断)。 */
|
|
57
|
+
function shotLog(...args) {
|
|
58
|
+
try {
|
|
59
|
+
const line = `[${new Date().toISOString()}] ${args.join(' ')}`
|
|
60
|
+
console.log('[shot]', ...args)
|
|
61
|
+
fs.appendFileSync(path.join(os.homedir(), '.dsh', 'logs', 'screenshot.log'), line + '\n')
|
|
62
|
+
} catch { /* 忽略日志错误 */ }
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
/* ------------------------------------------------------------------ *
|
|
56
66
|
* 工具:探测 / 等待 HTTP 服务
|
|
57
67
|
* ------------------------------------------------------------------ */
|
|
@@ -437,6 +447,7 @@ function openShotWindow() {
|
|
|
437
447
|
shotWindow.webContents.once('did-finish-load', () => {
|
|
438
448
|
if (pendingShot && !shotWindow.isDestroyed()) {
|
|
439
449
|
shotWindow.webContents.send('screenshot:data', pendingShot.toDataURL())
|
|
450
|
+
shotLog('shot: data sent to selector window')
|
|
440
451
|
}
|
|
441
452
|
})
|
|
442
453
|
shotWindow.on('closed', () => {
|
|
@@ -454,11 +465,15 @@ function onShotLoaded() {
|
|
|
454
465
|
|
|
455
466
|
/** 选区确认:裁剪 → 剪贴板 → 恢复主窗口并粘贴。 */
|
|
456
467
|
function onShotDone(rect) {
|
|
468
|
+
shotLog('shot: done called', rect ? JSON.stringify(rect) : 'null')
|
|
457
469
|
const image = pendingShot
|
|
458
470
|
pendingShot = null
|
|
459
471
|
if (shotWindow && !shotWindow.isDestroyed()) shotWindow.destroy()
|
|
460
472
|
showMainWindow() // 恢复显示聊天窗口
|
|
461
|
-
if (!image || !rect)
|
|
473
|
+
if (!image || !rect) {
|
|
474
|
+
shotLog('shot: done skipped (no image or rect)')
|
|
475
|
+
return
|
|
476
|
+
}
|
|
462
477
|
const sf = screen.getPrimaryDisplay().scaleFactor || 1
|
|
463
478
|
const r = {
|
|
464
479
|
x: Math.round(rect.x * sf),
|
|
@@ -466,13 +481,21 @@ function onShotDone(rect) {
|
|
|
466
481
|
width: Math.round(rect.w * sf),
|
|
467
482
|
height: Math.round(rect.h * sf),
|
|
468
483
|
}
|
|
469
|
-
if (r.width <= 0 || r.height <= 0)
|
|
484
|
+
if (r.width <= 0 || r.height <= 0) {
|
|
485
|
+
shotLog('shot: invalid crop rect after scale')
|
|
486
|
+
return
|
|
487
|
+
}
|
|
470
488
|
const cropped = image.crop(r)
|
|
489
|
+
shotLog('shot: cropped', cropped.getSize().width + 'x' + cropped.getSize().height)
|
|
471
490
|
// 保存一份临时文件(验证/诊断用)
|
|
472
491
|
try {
|
|
473
492
|
fs.writeFileSync(path.join(os.tmpdir(), 'dsh-screenshot.png'), cropped.toPNG())
|
|
474
|
-
|
|
493
|
+
shotLog('shot: saved temp png')
|
|
494
|
+
} catch (e) {
|
|
495
|
+
shotLog('shot: temp save failed', String(e && e.message || e))
|
|
496
|
+
}
|
|
475
497
|
clipboard.writeImage(cropped)
|
|
498
|
+
shotLog('shot: written to clipboard')
|
|
476
499
|
// 等主窗口就绪后尝试自动粘贴;若聚焦失败则提示手动 Ctrl+V
|
|
477
500
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|
478
501
|
setTimeout(async () => {
|
|
@@ -658,6 +681,7 @@ if (!gotLock) {
|
|
|
658
681
|
})
|
|
659
682
|
// 选区截图:隐藏主窗口 → 截全屏 → 选区窗口 → 裁剪 → 剪贴板 → 粘贴
|
|
660
683
|
ipcMain.handle('dsh-desktop:capture', async () => {
|
|
684
|
+
shotLog('capture: requested')
|
|
661
685
|
try {
|
|
662
686
|
// 先隐藏主窗口,避免截到聊天框本身
|
|
663
687
|
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.hide()
|
|
@@ -673,17 +697,21 @@ if (!gotLock) {
|
|
|
673
697
|
})
|
|
674
698
|
if (!sources.length) {
|
|
675
699
|
showMainWindow()
|
|
700
|
+
shotLog('capture: no screen source')
|
|
676
701
|
return { ok: false, error: '未找到屏幕源' }
|
|
677
702
|
}
|
|
678
703
|
pendingShot = sources[0].thumbnail
|
|
679
704
|
if (pendingShot.isEmpty()) {
|
|
680
705
|
showMainWindow()
|
|
706
|
+
shotLog('capture: empty thumbnail')
|
|
681
707
|
return { ok: false, error: '截图为空' }
|
|
682
708
|
}
|
|
709
|
+
shotLog('capture: captured', pendingShot.getSize().width + 'x' + pendingShot.getSize().height)
|
|
683
710
|
openShotWindow()
|
|
684
711
|
return { ok: true }
|
|
685
712
|
} catch (e) {
|
|
686
713
|
showMainWindow()
|
|
714
|
+
shotLog('capture: error', String((e && e.message) || e))
|
|
687
715
|
return { ok: false, error: String((e && e.message) || e) }
|
|
688
716
|
}
|
|
689
717
|
})
|
package/src/screenshot.html
CHANGED
|
@@ -200,11 +200,17 @@
|
|
|
200
200
|
t.style.display = 'flex'
|
|
201
201
|
t.style.left = Math.min(rect.x + rect.w + 10, W - 230) + 'px'
|
|
202
202
|
t.style.top = (rect.y + rect.h + 14 > H - 60 ? rect.y - 58 : rect.y + rect.h + 14) + 'px'
|
|
203
|
+
tip.textContent = '可拖拽边框微调 · 点确定或双击完成'
|
|
203
204
|
hint.style.opacity = '0'
|
|
204
205
|
layout() // 显示手柄
|
|
205
206
|
}
|
|
206
207
|
})
|
|
207
208
|
|
|
209
|
+
// 双击选区 → 直接提交
|
|
210
|
+
document.addEventListener('dblclick', function (e) {
|
|
211
|
+
if (rect && inside(e, rect)) window.__screenshot.done(rect)
|
|
212
|
+
})
|
|
213
|
+
|
|
208
214
|
document.getElementById('okBtn').onclick = function () {
|
|
209
215
|
if (rect) window.__screenshot.done(rect)
|
|
210
216
|
}
|