21 lines
537 B
TypeScript
21 lines
537 B
TypeScript
import type { Setting } from "~~/types/setting";
|
|
|
|
export default defineNuxtPlugin(async () => {
|
|
|
|
|
|
const { useSettingStore } = await import('@/stores/setting')
|
|
const settingStore = useSettingStore()
|
|
|
|
const config = useRuntimeConfig();
|
|
const apiUrl = config.public.BASE_API_URL;
|
|
|
|
try {
|
|
const data = await $fetch<Setting>(`${apiUrl}/api/v1/setting`)
|
|
if (data) {
|
|
settingStore.setSettings(data)
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to fetch settings:', error)
|
|
}
|
|
})
|