This commit is contained in:
pavel 2026-02-25 14:57:46 +01:00
commit 63d8aa9fe3
6 changed files with 4536 additions and 517 deletions

View file

@ -33,8 +33,26 @@ const state = {
};
// --- Desktop Backend Configuration ---
const urlParams = new URLSearchParams(window.location.search);
const API_BASE_URL = urlParams.get('backend') || ''; // Absolute URL to the remote server
let API_BASE_URL = ''; // Will be initialized via IPC
async function initializeConfig() {
try {
const config = await window.electronAPI.getConfig();
API_BASE_URL = config.backendUrl;
console.log(`Backend initialized: ${API_BASE_URL}`);
// Start the app now that config is ready
init();
} catch (err) {
console.error("Failed to fetch config via IPC", err);
// Fallback to URL search params if IPC fails (unlikely in desktop app)
const urlParams = new URLSearchParams(window.location.search);
API_BASE_URL = urlParams.get('backend') || '';
}
}
// Start config fetch immediately
initializeConfig();
function getWsUrl(path) {
let urlStr;
@ -1625,4 +1643,5 @@ async function init() {
}
}
init();
// Config fetcher will trigger init()
initializeConfig();

View file

@ -1,5 +1,6 @@
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
copyToClipboard: (text) => ipcRenderer.invoke('clipboard-write', text)
copyToClipboard: (text) => ipcRenderer.invoke('clipboard-write', text),
getConfig: () => ipcRenderer.invoke('get-config')
});