a
This commit is contained in:
parent
a4abbf7844
commit
63d8aa9fe3
6 changed files with 4536 additions and 517 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue