48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
// resources/js/app.js
|
|
import { createApp, h } from 'vue'
|
|
import { createInertiaApp } from '@inertiajs/vue3'
|
|
import { InertiaProgress } from '@inertiajs/progress'
|
|
import Vue3Toastify, { toast } from 'vue3-toastify'
|
|
import 'vue3-toastify/dist/index.css'
|
|
|
|
// Optional: Lade-Balken für Inertia
|
|
InertiaProgress.init()
|
|
|
|
// Inertia App starten
|
|
createInertiaApp({
|
|
// Alle Pages in app/Views/Pages/**/*.vue werden automatisch importiert
|
|
resolve: name => {
|
|
// Vite scannt die Pages dynamisch
|
|
const pages = import.meta.glob('@views/**/*.vue')
|
|
|
|
// Suche nach der richtigen Page-Datei
|
|
const key = Object.keys(pages).find(k =>
|
|
k.endsWith(`/${name}.vue`) || k.endsWith(`/${name}/index.vue`)
|
|
)
|
|
|
|
if (!key) throw new Error(`Page not found: ${name}`)
|
|
|
|
// Unterstützt sowohl <script setup> als auch klassische Exports
|
|
return pages[key]()
|
|
},
|
|
|
|
// Setup der App
|
|
setup({ el, App, props, plugin }) {
|
|
const vueApp = createApp({ render: () => h(App, props) })
|
|
|
|
// Inertia Plugin
|
|
vueApp.use(plugin)
|
|
|
|
// Toastify global verfügbar machen
|
|
vueApp.use(Vue3Toastify, {
|
|
autoClose: 3000,
|
|
position: 'top-right',
|
|
pauseOnHover: true,
|
|
})
|
|
vueApp.config.globalProperties.$toast = toast
|
|
|
|
// Mounten auf das DOM
|
|
vueApp.mount(el)
|
|
},
|
|
})
|