changing page layout assignment to work with Vite now
This commit is contained in:
parent
606899494c
commit
5f87596b2f
@ -3,8 +3,13 @@ require("./bootstrap");
|
||||
import { createApp, h } from 'vue';
|
||||
import { createInertiaApp } from '@inertiajs/inertia-vue3';
|
||||
import { InertiaProgress } from '@inertiajs/progress';
|
||||
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
|
||||
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
|
||||
import Notifications from 'notiwind';
|
||||
import AppLayout from './Layouts/AppLayout.vue';
|
||||
import AuthLayout from './Layouts/AuthLayout.vue';
|
||||
import BaseLayout from './Layouts/BaseLayout.vue';
|
||||
import GuestLayout from './Layouts/GuestLayout.vue';
|
||||
|
||||
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
|
||||
|
||||
@ -14,7 +19,25 @@ window.genUid = function () {
|
||||
|
||||
createInertiaApp({
|
||||
title: (title) => `${title} - ${appName}`,
|
||||
resolve: (name) => require(`./Pages/${name}.vue`),
|
||||
resolve: (name) => {
|
||||
const page = resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue'));
|
||||
|
||||
page.then((module) => {
|
||||
if (module.default.layout === undefined) {
|
||||
if (name.startsWith('Auth/')) {
|
||||
module.default.layout = AuthLayout;
|
||||
} else if (name.startsWith('Dashboard/') || name.startsWith('Profile/')) {
|
||||
module.default.layout = AppLayout;
|
||||
} else if (name.startsWith('Guest/')) {
|
||||
module.default.layout = GuestLayout;
|
||||
} else if (!name.startsWith('Components/') && !name.startsWith('Jetstream/') && !name.startsWith('Icons/') && !name.startsWith('Layouts/') && !name.includes('Partials')) {
|
||||
module.default.layout = BaseLayout;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return page;
|
||||
},
|
||||
setup({ el, app, props, plugin }) {
|
||||
return createApp({ render: () => h(app, props) })
|
||||
.use(plugin)
|
||||
|
Loading…
x
Reference in New Issue
Block a user