Ver Fonte

enh: 'execute' event type

Timothy J. Baek há 7 meses atrás
pai
commit
9bd5567552
1 ficheiros alterados com 7 adições e 0 exclusões
  1. 7 0
      src/lib/components/chat/Chat.svelte

+ 7 - 0
src/lib/components/chat/Chat.svelte

@@ -199,6 +199,13 @@
 
 				eventConfirmationTitle = data.title;
 				eventConfirmationMessage = data.message;
+			} else if (type === 'execute') {
+				try {
+					// Use Function constructor to evaluate code in a safer way
+					new Function(data.code)();
+				} catch (error) {
+					console.error('Error executing code:', error);
+				}
 			} else if (type === 'input') {
 				eventCallback = cb;