fix: terminal run styles

This commit is contained in:
engigu
2025-12-27 14:09:32 +08:00
parent ec882de420
commit 13b3343301
2 changed files with 9 additions and 9 deletions
+5 -5
View File
@@ -134,18 +134,18 @@ function connectWebSocket() {
ws.onopen = () => { ws.onopen = () => {
terminal?.writeln('\x1b[32m已连接到终端\x1b[0m') terminal?.writeln('\x1b[32m已连接到终端\x1b[0m')
terminal?.writeln('')
terminal?.focus()
emit('connected') emit('connected')
// 如果有初始命令,延迟发送 // 如果有初始命令,延迟发送PTY 会自动回显命令)
if (props.initialCommand) { if (props.initialCommand) {
setTimeout(() => { setTimeout(() => {
if (ws && ws.readyState === WebSocket.OPEN) { if (ws && ws.readyState === WebSocket.OPEN) {
ws.send(props.initialCommand + '\r\n') // 直接发送命令,PTY 会回显
ws.send(props.initialCommand + '\r')
} }
}, 300) }, 100)
} }
terminal?.focus()
} }
ws.onmessage = (event) => { ws.onmessage = (event) => {
+4 -4
View File
@@ -471,14 +471,14 @@ onUnmounted(() => {
<!-- 终端弹窗 --> <!-- 终端弹窗 -->
<Dialog v-model:open="showTerminalDialog"> <Dialog v-model:open="showTerminalDialog">
<DialogContent class="w-[calc(100%-2rem)] sm:max-w-3xl h-[60vh] sm:h-[70vh] flex flex-col p-0 overflow-hidden" :show-close-button="false"> <DialogContent class="w-[calc(100%-2rem)] sm:max-w-3xl h-[60vh] sm:h-[70vh] flex flex-col p-0 overflow-hidden !bg-[#1e1e1e] border-[#3c3c3c]" :show-close-button="false">
<div class="flex items-center justify-between px-3 sm:px-4 py-2 border-b bg-[#252526] rounded-t-lg"> <div class="flex items-center justify-between px-3 sm:px-4 py-2 border-b border-[#3c3c3c]">
<span class="text-xs sm:text-sm font-medium text-gray-300">运行脚本</span> <span class="text-xs sm:text-sm font-medium text-gray-300">运行脚本</span>
<Button variant="ghost" size="icon" class="h-6 w-6 text-gray-400 hover:text-white" @click="closeTerminal"> <Button variant="ghost" size="icon" class="h-6 w-6 text-gray-400 hover:text-white hover:bg-white/10" @click="closeTerminal">
<X class="h-4 w-4" /> <X class="h-4 w-4" />
</Button> </Button>
</div> </div>
<div class="flex-1 overflow-hidden p-1 rounded-b-lg"> <div class="flex-1 overflow-hidden">
<XTerminal <XTerminal
v-if="showTerminalDialog" v-if="showTerminalDialog"
ref="terminalRef" ref="terminalRef"