dsh-desktop-windows 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-desktop-windows",
3
3
  "productName": "DeepSeek Harness Desktop",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
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
@@ -411,11 +411,13 @@ function openShotWindow() {
411
411
  return
412
412
  }
413
413
  shotWindow = new BrowserWindow({
414
- fullscreen: true,
415
414
  frame: false,
416
415
  resizable: false,
416
+ movable: false,
417
+ fullscreen: true,
417
418
  alwaysOnTop: true,
418
419
  skipTaskbar: true,
420
+ show: false, // 截图加载完成后再显示,避免黑屏闪烁
419
421
  webPreferences: {
420
422
  contextIsolation: true,
421
423
  nodeIntegration: false,
@@ -425,10 +427,6 @@ function openShotWindow() {
425
427
  })
426
428
  shotWindow.setAlwaysOnTop(true, 'screen-saver')
427
429
  shotWindow.loadFile(path.join(__dirname, 'screenshot.html'))
428
- shotWindow.once('ready-to-show', () => {
429
- shotWindow.show()
430
- shotWindow.focus()
431
- })
432
430
  shotWindow.webContents.once('did-finish-load', () => {
433
431
  if (pendingShot && !shotWindow.isDestroyed()) {
434
432
  shotWindow.webContents.send('screenshot:data', pendingShot.toDataURL())
@@ -439,6 +437,14 @@ function openShotWindow() {
439
437
  })
440
438
  }
441
439
 
440
+ // 截图在选区窗口内加载完成 → 再显示窗口(避免黑屏"小窗口")
441
+ function onShotLoaded() {
442
+ if (shotWindow && !shotWindow.isDestroyed()) {
443
+ shotWindow.show()
444
+ shotWindow.focus()
445
+ }
446
+ }
447
+
442
448
  /** 选区确认:裁剪 → 剪贴板 → 恢复主窗口并粘贴。 */
443
449
  function onShotDone(rect) {
444
450
  const image = pendingShot
@@ -456,17 +462,27 @@ function onShotDone(rect) {
456
462
  if (r.width <= 0 || r.height <= 0) return
457
463
  const cropped = image.crop(r)
458
464
  clipboard.writeImage(cropped)
465
+ // 等主窗口就绪后再聚焦输入框并粘贴(失败则提示手动 Ctrl+V)
459
466
  if (mainWindow && !mainWindow.isDestroyed()) {
460
- mainWindow.show()
461
- mainWindow.focus()
462
- mainWindow.webContents
463
- .executeJavaScript(
464
- `(() => { const el = document.querySelector('textarea, [contenteditable="true"]'); if (el) { el.focus(); return true } return false })()`
465
- )
466
- .then((focused) => {
467
- if (focused) mainWindow.webContents.paste()
468
- })
469
- .catch(() => {})
467
+ setTimeout(async () => {
468
+ let focused = false
469
+ try {
470
+ focused = await mainWindow.webContents.executeJavaScript(
471
+ `(() => { const el = document.querySelector('textarea, [contenteditable="true"]'); if (el) { el.focus(); return true } return false })()`
472
+ )
473
+ } catch {
474
+ focused = false
475
+ }
476
+ if (focused) {
477
+ mainWindow.webContents.paste()
478
+ } else {
479
+ dialog.showMessageBox(mainWindow, {
480
+ type: 'info',
481
+ message: '截图已复制到剪贴板,请在聊天输入框按 Ctrl+V 粘贴',
482
+ buttons: ['好'],
483
+ })
484
+ }
485
+ }, 400)
470
486
  }
471
487
  }
472
488
 
@@ -669,6 +685,7 @@ if (!gotLock) {
669
685
  // 选区截图结果
670
686
  ipcMain.on('screenshot:done', (_e, rect) => onShotDone(rect))
671
687
  ipcMain.on('screenshot:cancel', () => onShotCancel())
688
+ ipcMain.on('screenshot:loaded', () => onShotLoaded())
672
689
  if (external) log('reusing external dsh service on port ' + port)
673
690
  })
674
691
 
@@ -12,4 +12,6 @@ contextBridge.exposeInMainWorld('__screenshot', {
12
12
  done: (rect) => ipcRenderer.send('screenshot:done', rect),
13
13
  // 取消
14
14
  cancel: () => ipcRenderer.send('screenshot:cancel'),
15
+ // 截图已加载完成(可显示窗口了)
16
+ loaded: () => ipcRenderer.send('screenshot:loaded'),
15
17
  })
@@ -58,8 +58,11 @@
58
58
 
59
59
  // 接收主进程传来的截图 dataURL
60
60
  window.__screenshot.onData((dataUrl) => {
61
+ bg.onload = () => {
62
+ window.__screenshot.loaded()
63
+ setTimeout(() => (hint.style.opacity = '0.9'), 100)
64
+ }
61
65
  bg.src = dataUrl
62
- setTimeout(() => (hint.style.opacity = '0.9'), 100)
63
66
  })
64
67
 
65
68
  const updateMask = () => {