first commit
This commit is contained in:
42
resources/js/app.ts
Normal file
42
resources/js/app.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { createInertiaApp, router } from '@inertiajs/vue3';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, createSSRApp } from 'vue';
|
||||
import {
|
||||
startGlobalLoading,
|
||||
stopGlobalLoading,
|
||||
} from './composables/useGlobalLoading';
|
||||
import { setupNaiveDiscreteApi } from './plugins/naive';
|
||||
import { renderWithProviders } from './providers';
|
||||
import '../css/app.css';
|
||||
|
||||
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
||||
|
||||
// Глобальный индикатор загрузки на переходах Inertia.
|
||||
router.on('start', () => startGlobalLoading());
|
||||
router.on('finish', () => stopGlobalLoading());
|
||||
|
||||
createInertiaApp({
|
||||
title: (title) => (title ? `${title} — ${appName}` : appName),
|
||||
progress: { color: '#63e2b7' },
|
||||
setup({ el, App, props, plugin }) {
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
|
||||
const render = () =>
|
||||
renderWithProviders(App, props as unknown as Record<string, unknown>);
|
||||
|
||||
// При SSR страница уже отрисована — гидратируем через createSSRApp.
|
||||
const app = el.hasAttribute('data-server-rendered')
|
||||
? createSSRApp({ render })
|
||||
: createApp({ render });
|
||||
|
||||
app.use(plugin);
|
||||
app.use(createPinia());
|
||||
|
||||
// Discrete API NaiveUI (window.$message и т.п.) — только в браузере.
|
||||
setupNaiveDiscreteApi(app);
|
||||
|
||||
app.mount(el);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user