29 lines
730 B
JavaScript
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
|
||
|
|
};
|
||
|
|
}
|