Spaces:
Runtime error
Runtime error
Download desktop/src/config.ts from Nryn215/FreeLLMAPI: direct link, hf CLI and curl.
- Browser
- Download file 711 Bytes
-
https://huggingface.co/spaces/Nryn215/FreeLLMAPI/resolve/main/desktop/src/config.ts
- Command line
-
hf download hf://spaces/Nryn215/FreeLLMAPI/desktop/src/config.ts
-
curl -L -o config.ts https://huggingface.co/spaces/Nryn215/FreeLLMAPI/resolve/main/desktop/src/config.ts
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); | |
| } | |
| } | |