fix: file路由readFile改promise版 + 终端客户端自动聚焦(实机pwd已验证服务端通)

This commit is contained in:
Aisland
2026-08-17 20:45:29 +08:00
parent 825730c54c
commit f83aa1d589
5 changed files with 43 additions and 2 deletions
+4
View File
@@ -982,6 +982,9 @@ function TerminalPane() {
return
}
term.open(el)
const focusTerm = () => { try { term.focus() } catch {} }
focusTerm()
el.addEventListener('pointerdown', focusTerm)
const scope = splitEnv?.getScope?.()
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:'
const url = proto + '//' + location.host + '/api/worktable/term?sessionId=' + encodeURIComponent(scope?.sessionId ?? '') + '&cwd=' + encodeURIComponent(scope?.cwd ?? '') + '&cols=80&rows=24'
@@ -992,6 +995,7 @@ function TerminalPane() {
setFailed(T('pane.termFail'))
return
}
ws.onopen = () => { focusTerm() }
ws.onmessage = (ev) => { try { term.write(String(ev.data)) } catch {} }
ws.onclose = () => { if (!disposed) { try { term.write('\r\n[连接已关闭]') } catch {} } }
ws.onerror = () => { if (!disposed) setFailed(T('pane.termFail')) }
+2 -2
View File
@@ -1,7 +1,7 @@
import { Context } from '@deepseek-ai/cordis'
import { execFile } from 'node:child_process'
import { readdirSync, readFile, realpathSync } from 'node:fs'
import { readdir } from 'node:fs/promises'
import { readdirSync, realpathSync } from 'node:fs'
import { readdir, readFile } from 'node:fs/promises'
import { dirname, resolve as pathResolve, sep } from 'node:path'
import { createRequire } from 'node:module'
import { homedir } from 'node:os'