FreeLLMAPI / desktop /src /config.ts
Nryn215's picture
Upload folder using huggingface_hub
077865a verified
Raw
History Blame Contribute Delete
711 Bytes
import fs from 'node:fs';
import path from 'node:path';
import { app } from 'electron';
export interface DesktopConfig {
port?: number;
theme?: 'dark' | 'light';
}
function configPath(): string {
return path.join(app.getPath('userData'), 'config.json');
}
export function loadConfig(): DesktopConfig {
try {
return JSON.parse(fs.readFileSync(configPath(), 'utf8')) as DesktopConfig;
} catch {
return {};
}
}
export function saveConfig(cfg: DesktopConfig): void {
try {
fs.mkdirSync(app.getPath('userData'), { recursive: true });
fs.writeFileSync(configPath(), JSON.stringify(cfg, null, 2));
} catch (err) {
console.warn('[desktop] could not persist config:', err);
}
}