adrema/resources/js/app.js

59 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-04-10 20:32:12 +02:00
import Vue from 'vue';
2022-11-17 20:56:46 +01:00
import {App as InertiaApp, plugin, Link as ILink} from '@inertiajs/inertia-vue';
2022-12-05 00:04:01 +01:00
import {Inertia} from '@inertiajs/inertia';
2022-12-04 23:40:35 +01:00
import PortalVue from 'portal-vue';
2023-02-26 20:51:59 +01:00
import axios from 'axios';
import VueAxios from 'vue-axios';
2023-03-04 12:02:17 +01:00
import Toasted from 'vue-toasted';
2023-05-19 01:06:46 +02:00
import VTooltip from 'v-tooltip';
2023-04-29 23:15:07 +02:00
import {createPinia, PiniaVuePlugin} from 'pinia';
2023-05-19 01:06:46 +02:00
import requireModules from './lib/requireModules.js';
2020-04-10 20:32:12 +02:00
2023-05-19 01:06:46 +02:00
import AppLayout from './layouts/AppLayout.vue';
import hasModule from './mixins/hasModule.js';
import hasFlash from './mixins/hasFlash.js';
// ---------------------------------- Plugins ----------------------------------
2022-02-12 01:31:01 +01:00
Vue.use(plugin);
2022-12-04 23:40:35 +01:00
Vue.use(PortalVue);
2021-08-22 16:49:38 +02:00
Vue.use(VTooltip);
2023-03-04 12:02:17 +01:00
Vue.use(Toasted);
2023-02-26 20:51:59 +01:00
Vue.use(VueAxios, axios);
2023-04-29 23:15:07 +02:00
Vue.use(PiniaVuePlugin);
2020-04-10 20:32:12 +02:00
2023-05-19 01:06:46 +02:00
Vue.component('SvgSprite', () => import('./components/SvgSprite.js'));
Vue.component('ILink', ILink);
2023-05-18 01:13:28 +02:00
2023-05-19 01:06:46 +02:00
// ---------------------------------- mixins -----------------------------------
Vue.mixin(hasModule);
Vue.mixin(hasFlash);
2023-05-18 23:22:45 +02:00
2023-05-19 01:06:46 +02:00
// -------------------------------- Components ---------------------------------
requireModules(require.context('./components/form', false, /\.vue$/, 'lazy'), Vue, 'f');
requireModules(require.context('./components/ui', false, /\.vue$/, 'lazy'), Vue, 'ui');
requireModules(require.context('./components/page', false, /\.vue$/, 'lazy'), Vue, 'page');
2023-05-18 01:13:28 +02:00
// ----------------------------------- init ------------------------------------
2022-02-12 01:31:01 +01:00
const el = document.getElementById('app');
2023-04-29 23:15:07 +02:00
const pinia = createPinia();
2020-04-12 00:26:44 +02:00
2022-12-05 00:04:01 +01:00
Inertia.on('start', (event) => window.dispatchEvent(new Event('inertiaStart')));
2020-04-10 20:32:12 +02:00
new Vue({
2023-04-29 23:15:07 +02:00
pinia,
2022-11-17 20:56:46 +01:00
render: (h) =>
h(InertiaApp, {
props: {
initialPage: JSON.parse(el.dataset.page),
resolveComponent: async (name) => {
var page = (await import(`./views/${name}`)).default;
2021-04-11 11:19:55 +02:00
2022-11-17 20:56:46 +01:00
if (page.layout === undefined) {
page.layout = AppLayout;
}
return page;
},
},
}),
2021-04-10 19:45:11 +02:00
}).$mount(el);