26 lines
673 B
JavaScript
26 lines
673 B
JavaScript
import { computed } from 'vue'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import { useSimulationStore } from '@/stores/simulation'
|
|
|
|
/**
|
|
* Feature-detects in-app simulation via GET /api/v1/simulation/config.
|
|
* Fail-closed: any error leaves simulationStore.enabled = false.
|
|
*/
|
|
export function useSimulationAvailable() {
|
|
const auth = useAuthStore()
|
|
const simulation = useSimulationStore()
|
|
|
|
const available = computed(() => simulation.enabled)
|
|
|
|
async function detect() {
|
|
if (!auth.isAuthenticated) {
|
|
simulation.enabled = false
|
|
return false
|
|
}
|
|
await simulation.loadConfig()
|
|
return simulation.enabled
|
|
}
|
|
|
|
return { available, detect }
|
|
}
|