- Add Vue 3 + TypeScript + Pinia setup - Add 6 complete views: Dashboard, Queue, Scanner, Rules, Workers, Settings - Add Pinia stores for state management - Add API service with Axios client - Add dark theme with Tdarr-inspired styling - Add setup wizard component - Add path browser for filesystem navigation
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref, computed } from 'vue'
|
|
import axios from 'axios'
|
|
|
|
export const useConfigStore = defineStore('config', () => {
|
|
const operationMode = ref<'standalone' | 'bazarr_slave'>('standalone')
|
|
const hasGPU = ref(false)
|
|
const loading = ref(false)
|
|
|
|
const isStandalone = computed(() => operationMode.value === 'standalone')
|
|
const isBazarrSlave = computed(() => operationMode.value === 'bazarr_slave')
|
|
|
|
async function fetchConfig() {
|
|
loading.value = true
|
|
try {
|
|
// Get operation mode from settings
|
|
const response = await axios.get('/api/settings/operation_mode')
|
|
operationMode.value = response.data.value === 'bazarr_slave' ? 'bazarr_slave' : 'standalone'
|
|
} catch (error) {
|
|
console.error('Failed to fetch operation mode:', error)
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
async function detectGPU() {
|
|
try {
|
|
// Try to get system resources to detect GPU
|
|
const response = await axios.get('/api/system/resources')
|
|
hasGPU.value = response.data.gpus && response.data.gpus.length > 0
|
|
} catch (error) {
|
|
// If endpoint doesn't exist, assume no GPU detection available
|
|
hasGPU.value = false
|
|
}
|
|
}
|
|
|
|
return {
|
|
operationMode,
|
|
hasGPU,
|
|
loading,
|
|
isStandalone,
|
|
isBazarrSlave,
|
|
fetchConfig,
|
|
detectGPU
|
|
}
|
|
})
|
|
|