Files
OpenVPN-Monitoring-Simple/UI/client/src/composables/useAppConfig.js
2026-01-09 10:30:49 +03:00

29 lines
730 B
JavaScript

import { ref } from 'vue';
const config = ref(null);
const isLoaded = ref(false);
export function useAppConfig() {
const loadConfig = async () => {
if (isLoaded.value) return;
try {
const response = await fetch('/config.json');
config.value = await response.json();
isLoaded.value = true;
} catch (error) {
console.error('Failed to load configuration:', error);
// Fallback or critical error handling
config.value = {
api_base_url: 'http://localhost:5001/api/v1',
refresh_interval: 30000
};
}
};
return {
config,
isLoaded,
loadConfig
};
}