Custom Commands: Typen (Hintergrund/Vordergrund/Nachricht) mit Output-Modal
This commit is contained in:
1 parent
d83a6f60ef
commit
ab234fde69
8 files changed
+241
-36
No files matched your search
@@ -65,22 +65,37 @@ registerPage('chat', {
|
||||
try { cmds = JSON.parse(session.customCommands || '[]') || []; } catch(e) {}
|
||||
cmds.forEach(cmd => {
|
||||
if (!cmd.name || !cmd.command) return;
|
||||
const type = cmd.type || 'background';
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'custom-cmd-btn';
|
||||
if (type === 'message') btn.classList.add('cmd-type-message');
|
||||
btn.textContent = cmd.name;
|
||||
btn.title = cmd.command;
|
||||
btn.title = type === 'message' ? cmd.command : `[${type}] ${cmd.command}`;
|
||||
btn.addEventListener('click', async () => {
|
||||
if (type === 'message') {
|
||||
// Nachricht in den Chat senden
|
||||
const inputEl = document.getElementById('input');
|
||||
if (inputEl) {
|
||||
inputEl.value = cmd.command;
|
||||
inputEl.dispatchEvent(new Event('input'));
|
||||
}
|
||||
sendMessage();
|
||||
return;
|
||||
}
|
||||
btn.disabled = true;
|
||||
btn.classList.add('running');
|
||||
try {
|
||||
await apiExecCommand(sessionId, cmd.command);
|
||||
if (type === 'foreground') {
|
||||
const result = await apiExecCommand(sessionId, cmd.command, 'foreground');
|
||||
showCommandOutputModal(cmd.name, cmd.command, result);
|
||||
} else {
|
||||
await apiExecCommand(sessionId, cmd.command, 'background');
|
||||
}
|
||||
} catch(e) {
|
||||
console.error('Exec failed:', e);
|
||||
}
|
||||
setTimeout(() => {
|
||||
btn.disabled = false;
|
||||
btn.classList.remove('running');
|
||||
}, 1000);
|
||||
btn.disabled = false;
|
||||
btn.classList.remove('running');
|
||||
});
|
||||
cmdBar.appendChild(btn);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user