diff --git a/web/src/components/XTerminal.vue b/web/src/components/XTerminal.vue index 07a1418..e870500 100644 --- a/web/src/components/XTerminal.vue +++ b/web/src/components/XTerminal.vue @@ -36,6 +36,13 @@ let historyIndex = -1 const statusMessage = ref<{ text: string; type: 'success' | 'error' | 'info' } | null>(null) +watch(() => props.fontSize, (newVal) => { + if (terminal && newVal) { + terminal.options.fontSize = newVal + handleResize() + } +}) + watch(statusMessage, (newVal) => { emit('status-change', newVal) }) @@ -65,7 +72,8 @@ function initTerminal(forceConnect = false) { terminal = new Terminal({ cursorBlink: true, fontSize: props.fontSize, - fontFamily: 'Consolas, Monaco, monospace', + lineHeight: 1.15, + fontFamily: 'Consolas, Monaco, "Courier New", monospace', theme: { background: '#1e1e1e', foreground: '#d4d4d4', diff --git a/web/src/components/ui/tabs/TabsTrigger.vue b/web/src/components/ui/tabs/TabsTrigger.vue index 45e424f..0c2c88c 100644 --- a/web/src/components/ui/tabs/TabsTrigger.vue +++ b/web/src/components/ui/tabs/TabsTrigger.vue @@ -16,7 +16,7 @@ const forwardedProps = useForwardProps(delegatedProps) -import { ref, onMounted } from 'vue' +import { ref, onMounted, computed, onUnmounted } from 'vue' import { Button } from '@/components/ui/button' import { RefreshCw, Info } from 'lucide-vue-next' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' @@ -8,8 +8,11 @@ import { api } from '@/api' const terminalRef = ref | null>(null) const cmds = ref<{ name: string, description: string }[]>([]) +const windowWidth = ref(window.innerWidth) +const updateWidth = () => { windowWidth.value = window.innerWidth } onMounted(async () => { + window.addEventListener('resize', updateWidth) try { const res = await api.terminal.cmds() cmds.value = res @@ -18,6 +21,16 @@ onMounted(async () => { } }) +onUnmounted(() => { + window.removeEventListener('resize', updateWidth) +}) + +const terminalFontSize = computed(() => { + if (windowWidth.value < 640) return 11 + if (windowWidth.value < 1024) return 12 + return 13 +}) + const isReconnecting = ref(false) function reconnect() { @@ -89,7 +102,7 @@ function handleStatusChange(status: any) {
- +