2022-05-20 22:26:09 +02:00
|
|
|
import {createApp} from 'vue'
|
2021-08-19 20:09:45 +02:00
|
|
|
|
2022-09-23 12:55:53 +02:00
|
|
|
import pinia from './pinia'
|
2018-09-06 19:46:09 +02:00
|
|
|
import router from './router'
|
2022-09-23 12:55:53 +02:00
|
|
|
import App from './App.vue'
|
2018-08-28 22:50:22 +02:00
|
|
|
|
2021-08-25 12:28:29 +02:00
|
|
|
import {error, success} from './message'
|
|
|
|
|
2020-05-09 21:39:46 +02:00
|
|
|
import {VERSION} from './version.json'
|
2021-04-22 14:26:48 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// Notifications
|
2021-08-20 15:46:41 +02:00
|
|
|
import Notifications from '@kyvg/vue3-notification'
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// PWA
|
|
|
|
import './registerServiceWorker'
|
|
|
|
|
|
|
|
// Vuex
|
2022-07-21 18:45:58 +02:00
|
|
|
import { store, key } from './store'
|
2021-06-24 01:24:57 +02:00
|
|
|
// i18n
|
2021-08-20 15:38:16 +02:00
|
|
|
import {i18n} from './i18n'
|
2020-09-05 22:35:52 +02:00
|
|
|
|
2022-04-13 19:40:50 +02:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
API_URL: string;
|
|
|
|
SENTRY_ENABLED: boolean;
|
|
|
|
SENTRY_DSN: string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-09 21:39:46 +02:00
|
|
|
console.info(`Vikunja frontend version ${VERSION}`)
|
|
|
|
|
2020-10-11 12:13:35 +02:00
|
|
|
// Check if we have an api url in local storage and use it if that's the case
|
|
|
|
const apiUrlFromStorage = localStorage.getItem('API_URL')
|
|
|
|
if (apiUrlFromStorage !== null) {
|
|
|
|
window.API_URL = apiUrlFromStorage
|
|
|
|
}
|
|
|
|
|
2020-05-10 18:26:33 +02:00
|
|
|
// Make sure the api url does not contain a / at the end
|
2020-09-05 22:35:52 +02:00
|
|
|
if (window.API_URL.substr(window.API_URL.length - 1, window.API_URL.length) === '/') {
|
2020-05-10 18:26:33 +02:00
|
|
|
window.API_URL = window.API_URL.substr(0, window.API_URL.length - 1)
|
|
|
|
}
|
|
|
|
|
2021-08-19 20:09:45 +02:00
|
|
|
const app = createApp(App)
|
2018-08-28 22:50:22 +02:00
|
|
|
|
2021-08-20 15:46:41 +02:00
|
|
|
app.use(Notifications)
|
2018-09-08 21:43:16 +02:00
|
|
|
|
2021-08-19 20:09:45 +02:00
|
|
|
// directives
|
2021-11-22 22:36:17 +01:00
|
|
|
import focus from '@/directives/focus'
|
2022-01-16 22:24:51 +01:00
|
|
|
// @ts-ignore The export does exist, ts just doesn't find it.
|
2021-11-23 08:08:21 +01:00
|
|
|
import { VTooltip } from 'v-tooltip'
|
|
|
|
import 'v-tooltip/dist/v-tooltip.css'
|
2021-11-13 21:28:29 +01:00
|
|
|
import shortcut from '@/directives/shortcut'
|
2021-11-22 22:36:17 +01:00
|
|
|
import cypress from '@/directives/cypress'
|
2021-10-26 20:53:17 +02:00
|
|
|
|
2021-08-19 20:09:45 +02:00
|
|
|
app.directive('focus', focus)
|
2021-11-23 08:08:21 +01:00
|
|
|
app.directive('tooltip', VTooltip)
|
2021-11-13 21:28:29 +01:00
|
|
|
app.directive('shortcut', shortcut)
|
2021-11-22 22:36:17 +01:00
|
|
|
app.directive('cy', cypress)
|
2021-04-22 14:26:48 +02:00
|
|
|
|
2021-08-19 20:09:45 +02:00
|
|
|
// global components
|
2022-09-22 17:31:13 +02:00
|
|
|
import FontAwesomeIcon from '@/components/misc/Icon'
|
2021-11-23 08:08:21 +01:00
|
|
|
import Button from '@/components/input/button.vue'
|
2022-04-18 19:04:10 +02:00
|
|
|
import Modal from '@/components/misc/modal.vue'
|
2021-11-23 08:08:21 +01:00
|
|
|
import Card from '@/components/misc/card.vue'
|
2021-10-26 20:53:17 +02:00
|
|
|
|
2021-08-19 20:09:45 +02:00
|
|
|
app.component('icon', FontAwesomeIcon)
|
|
|
|
app.component('x-button', Button)
|
|
|
|
app.component('modal', Modal)
|
|
|
|
app.component('card', Card)
|
2021-01-17 18:57:57 +01:00
|
|
|
|
2021-08-20 15:46:41 +02:00
|
|
|
app.config.errorHandler = (err, vm, info) => {
|
2022-04-24 17:27:16 +02:00
|
|
|
if (import.meta.env.DEV) {
|
|
|
|
console.error(err, vm, info)
|
|
|
|
}
|
2021-10-26 20:53:17 +02:00
|
|
|
error(err)
|
2021-08-20 15:46:41 +02:00
|
|
|
}
|
|
|
|
|
2021-10-09 16:04:19 +02:00
|
|
|
if (import.meta.env.DEV) {
|
2022-04-13 19:40:50 +02:00
|
|
|
app.config.warnHandler = (msg) => {
|
2021-10-09 16:04:19 +02:00
|
|
|
error(msg)
|
2022-05-22 17:06:50 +02:00
|
|
|
throw(msg)
|
2021-10-09 16:04:19 +02:00
|
|
|
}
|
|
|
|
|
2021-10-17 23:32:21 +02:00
|
|
|
// https://stackoverflow.com/a/52076738/15522256
|
|
|
|
window.addEventListener('error', (err) => {
|
|
|
|
error(err)
|
|
|
|
throw err
|
|
|
|
})
|
2021-10-26 20:53:17 +02:00
|
|
|
|
|
|
|
|
2021-10-17 23:32:21 +02:00
|
|
|
window.addEventListener('unhandledrejection', (err) => {
|
|
|
|
// event.promise contains the promise object
|
|
|
|
// event.reason contains the reason for the rejection
|
|
|
|
error(err)
|
|
|
|
throw err
|
|
|
|
})
|
|
|
|
}
|
2021-10-09 16:04:19 +02:00
|
|
|
|
2021-08-20 15:46:41 +02:00
|
|
|
app.config.globalProperties.$message = {
|
|
|
|
error,
|
|
|
|
success,
|
|
|
|
}
|
|
|
|
|
2021-10-26 20:53:17 +02:00
|
|
|
if (window.SENTRY_ENABLED) {
|
|
|
|
import('./sentry').then(sentry => sentry.default(app, router))
|
|
|
|
}
|
|
|
|
|
2022-09-21 16:23:57 +02:00
|
|
|
app.use(pinia)
|
|
|
|
|
2022-07-21 18:45:58 +02:00
|
|
|
app.use(store, key) // pass the injection key
|
2021-12-21 09:02:03 +01:00
|
|
|
app.use(router)
|
2021-08-19 20:09:45 +02:00
|
|
|
app.use(i18n)
|
|
|
|
|
|
|
|
app.mount('#app')
|