| import path from 'node:path';
|
| import { fileURLToPath } from 'node:url';
|
| import { BrowserWindow } from 'electron';
|
|
|
| const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
| let dashboardWindow: BrowserWindow | null = null;
|
|
|
| export function getDashboardWindow(): BrowserWindow | null {
|
| return dashboardWindow;
|
| }
|
|
|
|
|
|
|
|
|
|
|
| export function openDashboard(port: number, token: string): void {
|
| if (dashboardWindow && !dashboardWindow.isDestroyed()) {
|
| dashboardWindow.show();
|
| dashboardWindow.focus();
|
| return;
|
| }
|
|
|
| dashboardWindow = new BrowserWindow({
|
| width: 1200,
|
| height: 800,
|
| minWidth: 720,
|
| minHeight: 480,
|
| title: 'FreeLLMAPI',
|
|
|
|
|
|
|
|
|
|
|
|
|
| ...(process.platform === 'darwin'
|
| ? {
|
| titleBarStyle: 'hiddenInset' as const,
|
| vibrancy: 'sidebar' as const,
|
| visualEffectState: 'followWindow' as const,
|
| backgroundColor: '#00000000',
|
| }
|
| : { backgroundColor: '#09090b' }),
|
| webPreferences: {
|
| preload: path.join(__dirname, 'preload.cjs'),
|
| contextIsolation: true,
|
| sandbox: false,
|
| nodeIntegration: false,
|
| additionalArguments: [`--freeapi-token=${token}`],
|
| },
|
| });
|
|
|
| dashboardWindow.loadURL(`http://127.0.0.1:${port}`);
|
| dashboardWindow.on('closed', () => {
|
| dashboardWindow = null;
|
| });
|
| }
|
|
|