2021-10-26 20:53:17 +02:00
|
|
|
import {createApp, configureCompat} from 'vue'
|
2021-08-20 15:46:41 +02:00
|
|
|
|
|
|
|
configureCompat({
|
|
|
|
COMPONENT_V_MODEL: false,
|
|
|
|
COMPONENT_ASYNC: false,
|
|
|
|
RENDER_FUNCTION: false,
|
|
|
|
WATCH_ARRAY: false, // TODO: check this again; this might lead to some problemes
|
2021-10-17 22:17:49 +02:00
|
|
|
TRANSITION_GROUP_ROOT: false,
|
2021-08-20 15:46:41 +02:00
|
|
|
})
|
2021-08-19 20:09:45 +02:00
|
|
|
|
2018-08-28 22:50:22 +02:00
|
|
|
import App from './App.vue'
|
2018-09-06 19:46:09 +02:00
|
|
|
import router from './router'
|
2018-08-28 22:50:22 +02:00
|
|
|
|
2021-08-25 12:28:29 +02:00
|
|
|
import {error, success} from './message'
|
|
|
|
|
2021-07-19 20:20:49 +02:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
API_URL: string;
|
2021-10-26 20:53:17 +02:00
|
|
|
SENTRY_ENABLED: boolean;
|
2021-11-22 22:36:17 +01:00
|
|
|
SENTRY_DSN: string;
|
2021-07-19 20:20:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-07 12:20:52 +02:00
|
|
|
import {formatDate, formatDateShort, formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
2021-07-19 20:20:49 +02:00
|
|
|
// @ts-ignore
|
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
|
|
|
|
import {store} 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
|
|
|
|
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'
|
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
|
|
|
|
import FontAwesomeIcon from './icons'
|
2021-11-23 08:08:21 +01:00
|
|
|
import Button from '@/components/input/button.vue'
|
|
|
|
import Modal from '@/components/modal/modal.vue'
|
|
|
|
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-19 20:09:45 +02:00
|
|
|
// Mixins
|
|
|
|
import {getNamespaceTitle} from './helpers/getNamespaceTitle'
|
|
|
|
import {getListTitle} from './helpers/getListTitle'
|
|
|
|
import {colorIsDark} from './helpers/color/colorIsDark'
|
|
|
|
import {setTitle} from './helpers/setTitle'
|
2021-10-26 20:53:17 +02:00
|
|
|
|
2021-08-19 20:09:45 +02:00
|
|
|
app.mixin({
|
2020-01-30 21:49:00 +01:00
|
|
|
methods: {
|
2021-08-20 15:38:16 +02:00
|
|
|
formatDateSince,
|
2021-10-07 12:20:52 +02:00
|
|
|
format: formatDate,
|
2021-08-20 15:38:16 +02:00
|
|
|
formatDate: formatDateLong,
|
|
|
|
formatDateShort: formatDateShort,
|
|
|
|
getNamespaceTitle,
|
|
|
|
getListTitle,
|
|
|
|
colorIsDark,
|
|
|
|
setTitle,
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
2020-01-30 21:49:00 +01:00
|
|
|
})
|
|
|
|
|
2021-08-20 15:46:41 +02:00
|
|
|
app.config.errorHandler = (err, vm, info) => {
|
2021-09-11 17:53:03 +02:00
|
|
|
// if (import.meta.env.PROD) {
|
2021-10-26 20:53:17 +02:00
|
|
|
// error(err)
|
2021-09-11 17:53:03 +02:00
|
|
|
// } else {
|
2021-10-26 20:53:17 +02:00
|
|
|
// console.error(err, vm, info)
|
|
|
|
error(err)
|
2021-09-11 17:53:03 +02:00
|
|
|
// }
|
2021-08-20 15:46:41 +02:00
|
|
|
}
|
|
|
|
|
2021-10-09 16:04:19 +02:00
|
|
|
if (import.meta.env.DEV) {
|
2021-10-26 20:53:17 +02:00
|
|
|
app.config.warnHandler = (msg, vm, info) => {
|
2021-10-09 16:04:19 +02:00
|
|
|
error(msg)
|
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
2021-08-19 20:09:45 +02:00
|
|
|
app.use(store)
|
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')
|