first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 22:07:47 +03:00
commit 5285a0dd86
522 changed files with 41738 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
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)
}
})

View File

@@ -0,0 +1,20 @@
import type { Hero } from "~~/types/hero";
export default defineNuxtPlugin(async () => {
const { useHeroStore } = await import('@/stores/hero')
const heroStore = useHeroStore()
const config = useRuntimeConfig();
const apiUrl = config.public.BASE_API_URL;
try {
const data = await $fetch<Hero>(`${apiUrl}/api/v1/hero`)
if (data) {
heroStore.setHero(data)
}
} catch (error) {
console.error('Failed to fetch settings:', error)
}
})

11
app/plugins/auth-error.ts Normal file
View File

@@ -0,0 +1,11 @@
export default defineNuxtPlugin((nuxtApp) => {
const { data, signOut } = useAuth();
// Watch for session changes
watch(data, async (session) => {
if (session?.error === 'RefreshAccessTokenError') {
console.warn('Refresh token expired or invalid. Signing out...');
await signOut({ callbackUrl: '/auth/login' });
}
}, { immediate: true });
});

View File

@@ -0,0 +1,7 @@
// Converted to a no-op: we register Font Awesome using an SSR-aware plugin `app/plugins/fontawesome.ts`.
// Keep this client-only file present (if you relied on it elsewhere) but do not inject the runtime script
// to avoid hydration mismatches.
export default defineNuxtPlugin(() => {
if (process.server) return
// No-op on client — FontAwesome is registered via app/plugins/fontawesome.ts
})

View File

@@ -0,0 +1,39 @@
// SSR-friendly Font Awesome plugin
// Registers the Vue component and a small set of icons so server-render and client-render match.
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
// Import a conservative set of icons used in the admin UI
import {
faHouse,
faUsers,
faCogs,
faNewspaper,
faTags,
faHashtag,
faRightFromBracket,
faPlus,
faWandMagic,
faGaugeHigh,
faShieldAlt
} from '@fortawesome/free-solid-svg-icons'
export default defineNuxtPlugin((nuxtApp) => {
// Add selected icons to the library
library.add(
faHouse,
faUsers,
faCogs,
faNewspaper,
faTags,
faHashtag,
faRightFromBracket,
faPlus,
faWandMagic,
faGaugeHigh,
faShieldAlt
)
// Globally register component
nuxtApp.vueApp.component('FontAwesomeIcon', FontAwesomeIcon)
})

View File

@@ -0,0 +1,5 @@
import Swal from 'sweetalert2'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.provide('swal', Swal)
})