fix: 终端shell改PowerShell(pwd/ls可用) + 浏览器默认页改example.com(可嵌入) + marker回显验证

This commit is contained in:
Aisland
2026-08-17 20:48:13 +08:00
parent f83aa1d589
commit 3fe012132e
5 changed files with 26 additions and 11 deletions
+2 -2
View File
@@ -741,8 +741,8 @@ function makeDividerHandler(kind: 'left' | 'chat' | 'top' | 'pane' | 'topPane',
/** 浏览器内置窗:地址栏 + iframe */
function BrowserPane() {
const [url, setUrl] = useState('https://www.bing.com')
const [src, setSrc] = useState('https://www.bing.com')
const [url, setUrl] = useState('https://example.com')
const [src, setSrc] = useState('https://example.com')
const go = () => {
const u = url.trim()
setSrc(/^(\/|https?:\/\/)/i.test(u) ? u : 'about:blank')
+6 -3
View File
@@ -134,8 +134,10 @@ function setupTerminal(webServer: any, ctx: any) {
if (!WebSocketServer) return
const pty = ptyMod.default ?? ptyMod
const wss = new WebSocketServer({ noServer: true })
const spawnShell = (): string =>
process.platform === 'win32' ? (process.env.ComSpec || 'cmd.exe') : (process.env.SHELL || '/bin/bash')
const spawnShell = (): { cmd: string; args: string[] } =>
process.platform === 'win32'
? { cmd: 'powershell.exe', args: ['-NoLogo'] }
: { cmd: process.env.SHELL || '/bin/bash', args: [] }
const clampDim = (v: number, fallback: number) => Math.min(1024, Math.max(2, Number.isFinite(v) ? v : fallback))
ctx.effect(() => webServer.registerUpgrade({
@@ -148,7 +150,8 @@ function setupTerminal(webServer: any, ctx: any) {
const rows = clampDim(Number(u.searchParams.get('rows')), 24)
let term: any = null
try {
term = pty.spawn(spawnShell(), [], { name: 'xterm-256color', cols, rows, cwd, env: process.env })
const shell = spawnShell()
term = pty.spawn(shell.cmd, shell.args, { name: 'xterm-256color', cols, rows, cwd, env: process.env })
} catch (err) {
try { ws.send('\r\n[worktable] 终端启动失败:' + String(err)) } catch {}
try { ws.close() } catch {}