Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
2.7 kB · 76 lines
HTML
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; frame-src https://aesthetic.computer http://localhost:*;"> <title>Aesthetic Computer</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } html, body { width: 100%; height: 100%; overflow: hidden; background: #000; } webview { width: 100%; height: 100%; border: none; } </style></head><body> <webview id="ac-webview" src="https://aesthetic.computer/prompt" allowpopups></webview> <script> const webview = document.getElementById('ac-webview'); // Update window title based on current piece function updateTitle(url) { try { const u = new URL(url); const piece = u.pathname.replace(/^\//, '').replace(/\/$/, '') || 'prompt'; document.title = `${piece} — Aesthetic Computer`; } catch (e) { document.title = 'Aesthetic Computer'; } } webview.addEventListener('did-navigate', (e) => updateTitle(e.url)); webview.addEventListener('did-navigate-in-page', (e) => updateTitle(e.url));
// Intercept window.open from inside the webview. // Used by AC prompt commands: '+' opens new window, '-' requests close via ac://close. webview.addEventListener('new-window', (e) => { if (e?.preventDefault) e.preventDefault(); const url = e?.url || ''; if (url.startsWith('ac://close')) { window.ac?.closeWindow?.(); return; } window.ac?.openWindow?.(url); }); // Handle navigation from main process (menu) window.ac?.onNavigate?.((url) => { webview.src = url; updateTitle(url); });
// Handle menu commands window.ac?.onGoBack?.(() => webview.goBack()); window.ac?.onGoForward?.(() => webview.goForward()); window.ac?.onToggleDevtools?.(() => { if (webview.isDevToolsOpened()) { webview.closeDevTools(); } else { webview.openDevTools(); } }); // ========== Alt + Scroll to Drag Window ========== document.addEventListener('wheel', (e) => { // Alt + scroll (two-finger drag with alt) moves the window if (e.altKey && window.ac?.moveWindow) { e.preventDefault(); const currentX = window.screenX; const currentY = window.screenY; const newX = currentX - e.deltaX; const newY = currentY - e.deltaY; window.ac.moveWindow(Math.round(newX), Math.round(newY)); } }, { passive: false }); </script></body></html>