2023-03-03 15:54:28 +00:00
|
|
|
import '../css/app.css';
|
2024-04-29 09:25:50 +00:00
|
|
|
import { createApp, h } from 'vue';
|
2023-03-03 15:54:28 +00:00
|
|
|
import { Inertia } from '@inertiajs/inertia';
|
|
|
|
|
2024-04-23 17:36:45 +00:00
|
|
|
import { createInertiaApp } from '@inertiajs/vue3';
|
2023-03-17 15:13:37 +00:00
|
|
|
// import DefaultLayout from '@/Layouts/Default.vue';
|
2023-03-03 15:54:28 +00:00
|
|
|
import { createPinia } from 'pinia';
|
2024-04-23 17:36:45 +00:00
|
|
|
import { StyleService } from '@/Stores/style.service';
|
2023-03-17 15:13:37 +00:00
|
|
|
import { LayoutService } from '@/Stores/layout';
|
2024-09-16 15:59:46 +00:00
|
|
|
import { LocaleStore } from '@/Stores/locale';
|
2023-03-03 15:54:28 +00:00
|
|
|
import { darkModeKey, styleKey } from '@/config';
|
2024-04-23 17:36:45 +00:00
|
|
|
// import type { DefineComponent } from 'vue';
|
|
|
|
// import { resolvePageComponent } from '@adonisjs/inertia/helpers';
|
2023-03-03 15:54:28 +00:00
|
|
|
const pinia = createPinia();
|
2024-07-26 12:51:57 +00:00
|
|
|
// import i18n from './i18n';
|
2023-04-06 16:56:41 +00:00
|
|
|
import { EmitterPlugin } from '@/EmitterDirective';
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
import { initRoutes } from '@eidellev/adonis-stardust/client/index.js';
|
2023-03-03 15:54:28 +00:00
|
|
|
initRoutes();
|
|
|
|
|
2024-09-16 15:59:46 +00:00
|
|
|
// import { loadTranslations } from './utils/tethyscloud-l10n';
|
|
|
|
import asyncPlugin from '@/apps/settings/asyncPlugin';
|
|
|
|
// const translation = await asyncPlugin.install('settings');
|
|
|
|
|
2024-04-29 09:25:50 +00:00
|
|
|
// interface SetupOptions {
|
|
|
|
// el: Element;
|
|
|
|
// App: App;
|
|
|
|
// props: Record<string, any>;
|
|
|
|
// plugin: Plugin;
|
|
|
|
// }
|
2024-04-23 17:36:45 +00:00
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
// import '@fontsource/archivo-black/index.css';
|
|
|
|
// import '@fontsource/inter/index.css';
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
createInertiaApp({
|
2023-03-17 15:13:37 +00:00
|
|
|
progress: {
|
|
|
|
// color: '#4B5563',
|
|
|
|
color: '#22C55E',
|
2024-04-23 17:36:45 +00:00
|
|
|
},
|
2023-03-17 15:13:37 +00:00
|
|
|
// Webpack
|
|
|
|
// resolve: (name) => require(`./Pages/${name}`),
|
|
|
|
// resolve: (name) => require(`./Pages/${name}.vue`),
|
|
|
|
// add default layout
|
2024-03-14 19:25:27 +00:00
|
|
|
// resolve: (name) => {
|
|
|
|
// const page = require(`./Pages/${name}.vue`).default;
|
|
|
|
// // if (!page.layout) {
|
|
|
|
// // page.layout = DefaultLayout;
|
|
|
|
// // }
|
|
|
|
// return page;
|
|
|
|
// },
|
2024-04-23 17:36:45 +00:00
|
|
|
resolve: async (name: string) => {
|
2024-03-14 19:25:27 +00:00
|
|
|
// Dynamically import the Vue component using import
|
|
|
|
const { default: page } = await import(`./Pages/${name}.vue`);
|
|
|
|
// const page = require(`./Pages/${name}.vue`).default;
|
2023-03-17 15:13:37 +00:00
|
|
|
// if (!page.layout) {
|
|
|
|
// page.layout = DefaultLayout;
|
|
|
|
// }
|
|
|
|
return page;
|
|
|
|
},
|
2024-04-23 17:36:45 +00:00
|
|
|
// resolve: (name) => {
|
|
|
|
// return resolvePageComponent(
|
|
|
|
// `./Pages/${name}.vue`,
|
|
|
|
// import.meta.glob<DefineComponent>('./pages/**/*.vue'),
|
|
|
|
// )
|
|
|
|
// },
|
|
|
|
|
2024-09-16 15:59:46 +00:00
|
|
|
setup({ el, App, props, plugin }) {
|
|
|
|
const app = createApp({ render: () => h(App, props) })
|
2023-03-17 15:13:37 +00:00
|
|
|
.use(plugin)
|
|
|
|
.use(pinia)
|
2024-07-26 12:51:57 +00:00
|
|
|
// .use(i18n)
|
2024-09-16 15:59:46 +00:00
|
|
|
.use(EmitterPlugin);
|
|
|
|
// .component('inertia-link', Link)
|
|
|
|
|
|
|
|
asyncPlugin.install('settings').then(() => {
|
|
|
|
app.mount(el);
|
|
|
|
});
|
2023-03-17 15:13:37 +00:00
|
|
|
},
|
2024-09-16 15:59:46 +00:00
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const styleService = StyleService(pinia);
|
|
|
|
const layoutService = LayoutService(pinia);
|
2024-09-16 15:59:46 +00:00
|
|
|
const localeService = LocaleStore(pinia);
|
|
|
|
|
|
|
|
localeService.initializeLocale();
|
2023-03-03 15:54:28 +00:00
|
|
|
// const mainService = MainService(pinia);
|
|
|
|
// mainService.setUser(user);
|
|
|
|
|
|
|
|
/* App style */
|
|
|
|
styleService.setStyle(localStorage[styleKey] ?? 'basic');
|
|
|
|
|
|
|
|
/* Dark mode */
|
2023-06-27 16:23:18 +00:00
|
|
|
if ((!localStorage[darkModeKey] && window.matchMedia('(prefers-color-scheme: dark)').matches) || localStorage[darkModeKey] === '1') {
|
2023-03-17 15:13:37 +00:00
|
|
|
styleService.setDarkMode(true);
|
2023-03-03 15:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Collapse mobile aside menu on route change */
|
2024-04-23 17:36:45 +00:00
|
|
|
Inertia.on('navigate', () => {
|
2023-03-17 15:13:37 +00:00
|
|
|
layoutService.isAsideMobileExpanded = false;
|
|
|
|
layoutService.isAsideLgActive = false;
|
2023-03-03 15:54:28 +00:00
|
|
|
});
|