app.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import '/resources/js_vue3/assets/app.scss';
  2. import { createApp } from 'vue'
  3. import { i18nVue } from 'laravel-vue-i18n'
  4. import { createPinia } from 'pinia'
  5. import App from './App.vue'
  6. import router from './router'
  7. import Notifications from '@kyvg/vue3-notification'
  8. import FontAwesomeIcon from './icons'
  9. const app = createApp(App)
  10. // Immutable app properties provided by the laravel blade view
  11. const $2fauth = {
  12. prefix: '2fauth_',
  13. config: window.appConfig, //{"proxyAuth":false,"proxyLogoutUrl":false,"subdirectory":""}
  14. version: window.appVersion,
  15. isDemoApp: window.isDemoApp,
  16. isTestingApp: window.isTestingApp,
  17. langs: window.appLocales,
  18. }
  19. app.provide('2fauth', readonly($2fauth))
  20. const pinia = createPinia()
  21. pinia.use(({ store }) => {
  22. store.$2fauth = $2fauth;
  23. });
  24. app.use(pinia)
  25. app.use(router)
  26. app.use(i18nVue, {
  27. lang: document.documentElement.lang.substring(0, 2),
  28. resolve: async lang => {
  29. const langs = import.meta.glob('../lang/*.json');
  30. if (lang.includes('php_')) {
  31. return await langs[`../lang/${lang}.json`]();
  32. }
  33. }
  34. })
  35. app.use(Notifications)
  36. import ResponsiveWidthWrapper from '@/layouts/ResponsiveWidthWrapper.vue'
  37. import FormWrapper from '@/layouts/FormWrapper.vue'
  38. import Footer from '@/layouts/Footer.vue'
  39. import VueButton from '@/components/formElements/Button.vue'
  40. import FieldError from '@/components/formElements/FieldError.vue'
  41. import FormField from '@/components/formElements/FormField.vue'
  42. import FormPasswordField from '@/components/formElements/FormPasswordField.vue'
  43. import FormButtons from '@/components/formElements/FormButtons.vue'
  44. // Components registration
  45. app
  46. .component('FontAwesomeIcon', FontAwesomeIcon)
  47. .component('ResponsiveWidthWrapper', ResponsiveWidthWrapper)
  48. .component('FormWrapper', FormWrapper)
  49. .component('VueFooter', Footer)
  50. .component('VueButton', VueButton)
  51. .component('FieldError', FieldError)
  52. .component('FormField', FormField)
  53. .component('FormPasswordField', FormPasswordField)
  54. .component('FormButtons', FormButtons)
  55. // App mounting
  56. app.mount('#app')