Making basic tty execute command.

For testing, use `execute hotnews` :)
This commit is contained in:
吳元皓 2025-05-15 14:19:21 +08:00
parent a94b6fbb79
commit 5c64018601

View File

@ -13,8 +13,6 @@ const openNewWindow = (windowId: string) => {
emit("windowopener", windowId); emit("windowopener", windowId);
}; };
const printAbout = () => {};
const focusInput = () => { const focusInput = () => {
inputRef.value?.focus(); inputRef.value?.focus();
}; };
@ -23,21 +21,31 @@ onMounted(() => {
}); });
const startScript = () => { const startScript = () => {
console.log(commandInputBox.value); if (commandInputBox.value) {
const firstWord = commandInputBox.value.replace(/\s+.*$/, "").trim(); console.log(commandInputBox.value);
const app = commands.find((item) => item.command === firstWord); const firstWord = commandInputBox.value.replace(/\s+.*$/, "").trim();
if (app) { const app = commands.find((item) => item.command === firstWord);
app.run(commandInputBox.value); if (app) {
} else { app.run(commandInputBox.value);
console.error("Cannot find match"); } else {
console.error("Cannot find match");
}
commandInputBox.value = "";
} }
commandInputBox.value = "";
}; };
const findExecutable = (inputContent: string) => { 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 // scripts
const commands = [ const commands = [
{ {