Basic stuff for new laravel container
This commit is contained in:
47
resources/js/app.js
Normal file
47
resources/js/app.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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)
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user