af9f42ef68
useApi centralizes fetch error handling — every API call throws ApiError on non-2xx with the parsed body attached, so components don't repeat the 'check response.ok' boilerplate. import store wraps import settings, batch status, task list (with cursor pagination), and the trigger/retry/clear admin actions. system store gains a refreshStats() that powers the Settings overview tab. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
31 lines
775 B
JavaScript
31 lines
775 B
JavaScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
import { useApi } from '../composables/useApi.js'
|
|
|
|
export const useSystemStore = defineStore('system', () => {
|
|
const api = useApi()
|
|
const healthy = ref(null) // null=unknown, true=ok, false=down
|
|
const stats = ref(null)
|
|
const statsLoading = ref(false)
|
|
|
|
async function refreshHealth() {
|
|
try {
|
|
const body = await api.get('/api/health')
|
|
healthy.value = body.status === 'ok'
|
|
} catch {
|
|
healthy.value = false
|
|
}
|
|
}
|
|
|
|
async function refreshStats() {
|
|
statsLoading.value = true
|
|
try {
|
|
stats.value = await api.get('/api/system/stats')
|
|
} finally {
|
|
statsLoading.value = false
|
|
}
|
|
}
|
|
|
|
return { healthy, stats, statsLoading, refreshHealth, refreshStats }
|
|
})
|