main funcions fixes

This commit is contained in:
2025-09-29 22:06:11 +09:00
parent 40e016e128
commit c8c3274527
7995 changed files with 1517998 additions and 1057 deletions

View File

@@ -0,0 +1,110 @@
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron');
const path = require('path');
const ConfigManager = require('./config');
let mainWindow;
let config;
function createWindow() {
// Инициализируем конфигурацию
config = new ConfigManager();
// Получаем сохраненные размеры окна
const bounds = config.getWindowBounds();
mainWindow = new BrowserWindow({
width: bounds.width,
height: bounds.height,
x: bounds.x,
y: bounds.y,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
webSecurity: false // Needed for WebRTC
},
icon: path.join(__dirname, '../assets/icon.png'),
title: 'GodEye Operator Console',
show: false,
minWidth: 1200,
minHeight: 800
});
mainWindow.loadFile('src/renderer/index.html');
// Show window when ready to prevent visual flash
mainWindow.once('ready-to-show', () => {
mainWindow.show();
// Передаем конфигурацию в renderer процесс
mainWindow.webContents.send('config-loaded', {
serverUrl: config.getServerUrl(),
autoConnect: config.getAutoConnect(),
videoFilters: config.getVideoFilters()
});
});
// Сохраняем размеры окна при изменении
mainWindow.on('resize', saveWindowBounds);
mainWindow.on('move', saveWindowBounds);
// Open DevTools in development
if (process.argv.includes('--dev')) {
mainWindow.webContents.openDevTools();
}
mainWindow.on('closed', () => {
mainWindow = null;
});
// Обработка внешних ссылок
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
shell.openExternal(url);
return { action: 'deny' };
});
}
function saveWindowBounds() {
if (mainWindow && !mainWindow.isDestroyed()) {
const bounds = mainWindow.getBounds();
config.setWindowBounds(bounds);
}
}
// IPC обработчики
ipcMain.handle('get-config', (event, key) => {
return config.get(key);
});
ipcMain.handle('set-config', (event, key, value) => {
config.set(key, value);
return true;
});
ipcMain.handle('show-save-dialog', async (event, options) => {
const result = await dialog.showSaveDialog(mainWindow, options);
return result;
});
ipcMain.handle('show-message-box', async (event, options) => {
const result = await dialog.showMessageBox(mainWindow, options);
return result;
});
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
// IPC handlers for main process communication
ipcMain.handle('app-version', () => {
return app.getVersion();
});