From 72b2d297fdb0b0632520e4536dc7a2c37a8bc573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Thu, 2 Apr 2026 00:15:04 +0300 Subject: [PATCH] feat: implement Nginx and Apache configuration management and service control IPC handlers --- src/main/ipc/index.ts | 7 +++++ src/renderer/src/App.tsx | 61 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/main/ipc/index.ts b/src/main/ipc/index.ts index 1c6ca45..38b286f 100644 --- a/src/main/ipc/index.ts +++ b/src/main/ipc/index.ts @@ -232,9 +232,13 @@ async function rebuildApacheConfig(forceProjects: boolean = false): Promise<{ bi async function restartApache(): Promise<{ success: boolean; message: string }> { try { const { binPath, configPath } = await rebuildApacheConfig(false) + const settings = configService.getSettings() await processManager.forceKillAll('apache') await processManager.stopService('apache') + // Force kill port to be absolutely sure + await processManager.killByPort('apache', settings.apachePort || '8080') + await new Promise(resolve => setTimeout(resolve, 1000)) const success = await processManager.startService('apache', binPath, ['-f', configPath], false) @@ -275,6 +279,9 @@ export function registerIpcHandlers(): void { if (serviceName === 'apache') { const { binPath, configPath } = await rebuildApacheConfig(false) + const settings = configService.getSettings() + // Ensure port is free + await processManager.killByPort('apache', settings.apachePort || '8080') const success = await processManager.startService('apache', binPath, ['-f', configPath], false) if (!success) { const errorLogs = await processManager.getLastErrorLogs('apache') diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 2a5ecaf..0544684 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -517,7 +517,15 @@ function App(): JSX.Element { if (window.api && window.api.invoke) { const result = await window.api.invoke('nginx:config:save', nginxConfig) if (result.success) { - setNotification({ open: true, message: t('server.nginx.config_saved'), severity: 'success' }) + Swal.fire({ + title: t('common.success'), + text: t('server.nginx.config_saved'), + icon: 'success', + background: '#1e1e1e', + color: '#fff', + confirmButtonColor: '#153E5E', + customClass: { popup: 'swal2-dark-popup' } + }) setIsNginxConfigOpen(false) } } @@ -535,7 +543,15 @@ function App(): JSX.Element { if (window.api && window.api.invoke) { const result = await window.api.invoke('apache:config:save', apacheConfig) if (result.success) { - setNotification({ open: true, message: t('server.apache.config_saved'), severity: 'success' }) + Swal.fire({ + title: t('common.success'), + text: t('server.apache.config_saved'), + icon: 'success', + background: '#1e1e1e', + color: '#fff', + confirmButtonColor: '#153E5E', + customClass: { popup: 'swal2-dark-popup' } + }) setIsApacheConfigOpen(false) } } @@ -616,7 +632,15 @@ function App(): JSX.Element { if (window.api && window.api.invoke) { const result = await window.api.invoke('project:nginx:save', selectedProjectHost, projectNginxConfig) if (result.success) { - setNotification({ open: true, message: t('server.nginx.config_saved'), severity: 'success' }) + Swal.fire({ + title: t('common.success'), + text: t('server.nginx.config_saved'), + icon: 'success', + background: '#1e1e1e', + color: '#fff', + confirmButtonColor: '#153E5E', + customClass: { popup: 'swal2-dark-popup' } + }) setIsProjectNginxConfigOpen(false) } } @@ -1099,7 +1123,15 @@ function App(): JSX.Element { { window.api.invoke('services:reload', 'nginx').then((res: any) => { - setNotification({ open: true, message: res.message, severity: res.success ? 'success' : 'error' }) + Swal.fire({ + title: res.success ? t('common.success') : t('common.error'), + text: res.message, + icon: res.success ? 'success' : 'error', + background: '#1e1e1e', + color: '#fff', + confirmButtonColor: '#153E5E', + customClass: { popup: 'swal2-dark-popup' } + }) }) }} title={t('server.nginx.save_reload')} @@ -1150,6 +1182,27 @@ function App(): JSX.Element { > + { + window.api.invoke('services:reload', 'apache').then((res: any) => { + Swal.fire({ + title: res.success ? t('common.success') : t('common.error'), + text: res.message, + icon: res.success ? 'success' : 'error', + background: '#1e1e1e', + color: '#fff', + confirmButtonColor: '#153E5E', + customClass: { popup: 'swal2-dark-popup' } + }) + }) + }} + title={t('server.apache.save_reload')} + size="small" + disabled={status.apache !== 'running'} + sx={{ bgcolor: 'rgba(255,255,255,0.05)', '&:hover': { color: 'primary.main' } }} + > + +