44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { createInertiaApp } from '@inertiajs/vue3';
|
|
import I18NextVue from 'i18next-vue';
|
|
import type { DefineComponent } from 'vue';
|
|
import i18next from './lang/init';
|
|
import Layout from './layouts/Layout.vue';
|
|
|
|
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
|
|
|
createInertiaApp({
|
|
title: (title) => (title ? `${title} - ${appName}` : appName),
|
|
progress: {
|
|
color: '#4B5563',
|
|
},
|
|
layout() {
|
|
return Layout;
|
|
},
|
|
resolve(name) {
|
|
const pages = import.meta.glob<DefineComponent>(
|
|
['./features/*/pages/*.vue', './pages/*.vue'],
|
|
{
|
|
eager: true,
|
|
},
|
|
);
|
|
|
|
if (name.includes('::')) {
|
|
const n = name.split('::');
|
|
const domain = n[0];
|
|
const page = n[1][0].toUpperCase() + n[1].slice(1).toLowerCase();
|
|
|
|
return pages[`./features/${domain}/pages/${page}.vue`];
|
|
}
|
|
|
|
return pages[`./pages/${name}.vue`];
|
|
},
|
|
withApp(app, options) {
|
|
app.use(I18NextVue, {
|
|
i18next,
|
|
...options,
|
|
});
|
|
|
|
return app;
|
|
},
|
|
});
|