feat: implement core UI dashboard and backend service management for multi-PHP environment
This commit is contained in:
@@ -2,6 +2,8 @@ import { ipcMain, app } from 'electron'
|
||||
import { processManager } from '../services/ProcessManager'
|
||||
import { configService } from '../services/ConfigService'
|
||||
import { downloadService } from '../services/DownloadService'
|
||||
import { projectService } from '../services/ProjectService'
|
||||
import { phpManagerService } from '../services/PhpManagerService'
|
||||
import path from 'path'
|
||||
|
||||
export function registerIpcHandlers(): void {
|
||||
@@ -54,6 +56,33 @@ export function registerIpcHandlers(): void {
|
||||
})
|
||||
|
||||
// Binary management
|
||||
ipcMain.handle('binaries:list-php', async () => {
|
||||
return phpManagerService.getVersions()
|
||||
})
|
||||
|
||||
ipcMain.handle('binaries:download-php', async (event, id: string) => {
|
||||
const versions = await phpManagerService.getVersions()
|
||||
const version = versions.find(v => v.id === id)
|
||||
if (!version) return { success: false, message: 'Geçersiz sürüm.' }
|
||||
|
||||
try {
|
||||
// Signal immediate start
|
||||
phpManagerService.updateProgress(id, 0, 'downloading')
|
||||
event.sender.send('binaries:progress', { id, progress: 0 })
|
||||
|
||||
await downloadService.downloadAndExtract(version.url, id, (p) => {
|
||||
phpManagerService.updateProgress(id, p)
|
||||
event.sender.send('binaries:progress', { id, progress: p })
|
||||
})
|
||||
|
||||
phpManagerService.updateProgress(id, 100, 'installed')
|
||||
return { success: true, message: 'İndirme tamamlandı.' }
|
||||
} catch (error: any) {
|
||||
phpManagerService.updateProgress(id, 0, 'available')
|
||||
return { success: false, message: `Hata: ${error.message}` }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('binaries:download', async (_event, { name, url }) => {
|
||||
return downloadService.downloadAndExtract(url, name, (p) => {
|
||||
// TODO: Emit progress to renderer via webContents.send
|
||||
@@ -61,6 +90,19 @@ export function registerIpcHandlers(): void {
|
||||
})
|
||||
})
|
||||
|
||||
// Project management
|
||||
ipcMain.handle('projects:list', async () => {
|
||||
return projectService.getProjects()
|
||||
})
|
||||
|
||||
ipcMain.handle('projects:add', async (_event, project) => {
|
||||
return projectService.addProject(project)
|
||||
})
|
||||
|
||||
ipcMain.handle('projects:remove', async (_event, id) => {
|
||||
return projectService.removeProject(id)
|
||||
})
|
||||
|
||||
// Config management
|
||||
ipcMain.handle('config:get', async (_event, key: string) => {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user