fix: store

This commit is contained in:
2026-04-03 11:32:04 +02:00
parent 68f31952da
commit b7c4b6e3fd
27 changed files with 22 additions and 22 deletions

View File

@@ -0,0 +1,21 @@
import { useFetchJson } from '@/composable/useFetchJson'
import type { Resp } from '@/types'
import type { Settings } from '@/types/settings'
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
export const useSettingsStore = defineStore('settings', () => {
const settings = ref<Settings | null>(null)
const loaded = ref(false)
const shopDefaultLanguage = computed(() => settings.value?.app?.shop_default_language ?? 1)
async function getSettings(): Promise<Settings | null> {
if (loaded.value && settings.value) return settings.value
const resp = await useFetchJson<Settings>('/api/v1/settings')
settings.value = resp.items
loaded.value = true
return resp.items
}
return { settings, loaded, shopDefaultLanguage, getSettings }
})