From 5c6401860142d4f249ffb07c003b874e453d3107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E5=85=83=E7=9A=93?= Date: Thu, 15 May 2025 14:19:21 +0800 Subject: [PATCH] Making basic tty execute command. For testing, use `execute hotnews` :) --- components/app/windows/tty.vue | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/components/app/windows/tty.vue b/components/app/windows/tty.vue index 9c198cf..e5c7b2d 100644 --- a/components/app/windows/tty.vue +++ b/components/app/windows/tty.vue @@ -13,8 +13,6 @@ const openNewWindow = (windowId: string) => { emit("windowopener", windowId); }; -const printAbout = () => {}; - const focusInput = () => { inputRef.value?.focus(); }; @@ -23,21 +21,31 @@ onMounted(() => { }); const startScript = () => { - console.log(commandInputBox.value); - const firstWord = commandInputBox.value.replace(/\s+.*$/, "").trim(); - const app = commands.find((item) => item.command === firstWord); - if (app) { - app.run(commandInputBox.value); - } else { - console.error("Cannot find match"); + if (commandInputBox.value) { + console.log(commandInputBox.value); + const firstWord = commandInputBox.value.replace(/\s+.*$/, "").trim(); + const app = commands.find((item) => item.command === firstWord); + if (app) { + app.run(commandInputBox.value); + } else { + console.error("Cannot find match"); + } + commandInputBox.value = ""; } - commandInputBox.value = ""; }; const findExecutable = (inputContent: string) => { - console.log(inputContent); + const executeMatch = inputContent.match(/^execute\s+(.*)$/); + if (executeMatch) { + const targetPath = executeMatch[1].trim(); + console.log("Executing:", targetPath); + openNewWindow(targetPath); + } else { + console.error("Invalid execute command format"); + } }; +const printAbout = () => {}; // scripts const commands = [ {