2FAuth/resources/js_vue3/app.js

96 lines
3.0 KiB
JavaScript
Raw Normal View History

import '/resources/js_vue3/assets/app.scss';
import Notifications from '@kyvg/vue3-notification'
import App from './App.vue'
import router from './router'
2023-09-22 13:10:42 +02:00
import FontAwesomeIcon from './icons'
2023-10-30 13:09:02 +01:00
// import helpers from './helpers'
const app = createApp(App)
2023-09-22 11:32:24 +02:00
// Immutable app properties provided by the laravel blade view
const $2fauth = {
prefix: '2fauth_',
config: window.appConfig,
2023-09-22 11:32:24 +02:00
version: window.appVersion,
isDemoApp: window.isDemoApp,
isTestingApp: window.isTestingApp,
langs: window.appLocales,
2023-09-22 11:32:24 +02:00
}
app.provide('2fauth', readonly($2fauth))
// Stores
const pinia = createPinia()
pinia.use(({ store }) => {
store.$2fauth = $2fauth;
});
app.use(pinia)
2023-09-22 11:32:24 +02:00
// Router
app.use(router)
// Localization
2023-09-22 12:00:16 +02:00
app.use(i18nVue, {
2023-09-22 17:14:00 +02:00
lang: document.documentElement.lang.substring(0, 2),
2023-09-22 12:00:16 +02:00
resolve: async lang => {
const langs = import.meta.glob('../lang/*.json');
2023-09-22 17:14:00 +02:00
if (lang.includes('php_')) {
return await langs[`../lang/${lang}.json`]();
}
2023-09-22 12:00:16 +02:00
}
})
// Notifications
2023-09-21 17:10:12 +02:00
app.use(Notifications)
// Global components registration
import ResponsiveWidthWrapper from '@/layouts/ResponsiveWidthWrapper.vue'
import FormWrapper from '@/layouts/FormWrapper.vue'
import Footer from '@/layouts/Footer.vue'
import Modal from '@/layouts/Modal.vue'
import VueButton from '@/components/formElements/Button.vue'
import ButtonBackCloseCancel from '@/components/formElements/ButtonBackCloseCancel.vue'
import FieldError from '@/components/formElements/FieldError.vue'
import FormField from '@/components/formElements/FormField.vue'
import FormPasswordField from '@/components/formElements/FormPasswordField.vue'
import FormSelect from '@/components/formElements/FormSelect.vue'
import FormToggle from '@/components/formElements/FormToggle.vue'
import FormCheckbox from '@/components/formElements/FormCheckbox.vue'
import FormButtons from '@/components/formElements/FormButtons.vue'
import Kicker from '@/components/Kicker.vue'
2023-09-22 15:35:58 +02:00
app
.component('FontAwesomeIcon', FontAwesomeIcon)
.component('ResponsiveWidthWrapper', ResponsiveWidthWrapper)
.component('FormWrapper', FormWrapper)
.component('VueFooter', Footer)
.component('Modal', Modal)
.component('VueButton', VueButton)
.component('ButtonBackCloseCancel', ButtonBackCloseCancel)
.component('FieldError', FieldError)
.component('FormField', FormField)
.component('FormPasswordField', FormPasswordField)
.component('FormSelect', FormSelect)
.component('FormToggle', FormToggle)
.component('FormCheckbox', FormCheckbox)
.component('FormButtons', FormButtons)
.component('Kicker', Kicker)
2023-09-22 13:10:42 +02:00
// Global error handling
import { useNotifyStore } from '@/stores/notify'
2023-09-29 15:06:35 +02:00
if (process.env.NODE_ENV != 'development') {
app.config.errorHandler = (err) => {
useNotifyStore().error(err)
}
}
2023-10-30 13:09:02 +01:00
// Helpers
// app.config.globalProperties.$helpers = helpers
// App mounting
2023-09-29 13:16:41 +02:00
app.mount('#app')
// Theme
import { useUserStore } from '@/stores/user'
useUserStore().applyUserPrefs()