2023-01-04 15:54:09 +00:00
|
|
|
import './polyfills'
|
2022-05-20 20:26:09 +00:00
|
|
|
import {createApp} from 'vue'
|
2021-08-19 18:09:45 +00:00
|
|
|
|
2022-09-23 10:55:53 +00:00
|
|
|
import pinia from './pinia'
|
2018-09-06 17:46:09 +00:00
|
|
|
import router from './router'
|
2022-09-23 10:55:53 +00:00
|
|
|
import App from './App.vue'
|
2021-08-25 10:28:29 +00:00
|
|
|
import {error, success} from './message'
|
2020-05-09 19:39:46 +00:00
|
|
|
import {VERSION} from './version.json'
|
2021-04-22 12:26:48 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
// Notifications
|
2021-08-20 13:46:41 +00:00
|
|
|
import Notifications from '@kyvg/vue3-notification'
|
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
// PWA
|
|
|
|
import './registerServiceWorker'
|
|
|
|
|
2021-06-23 23:24:57 +00:00
|
|
|
// i18n
|
2023-06-12 16:01:56 +00:00
|
|
|
import {getBrowserLanguage, i18n, setLanguage} from './i18n'
|
2020-09-05 20:35:52 +00:00
|
|
|
|
2022-04-13 17:40:50 +00:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
API_URL: string;
|
|
|
|
SENTRY_ENABLED: boolean;
|
|
|
|
SENTRY_DSN: string;
|
2023-04-12 08:39:10 +00:00
|
|
|
PROJECT_INFINITE_NESTING_ENABLED: boolean;
|
2023-06-02 11:51:29 +00:00
|
|
|
ALLOW_ICON_CHANGES: boolean;
|
2023-08-23 16:13:29 +00:00
|
|
|
CUSTOM_LOGO_URL?: string;
|
2022-04-13 17:40:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-09 19:39:46 +00:00
|
|
|
console.info(`Vikunja frontend version ${VERSION}`)
|
|
|
|
|
2020-10-11 10:13:35 +00: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 16:26:33 +00:00
|
|
|
// Make sure the api url does not contain a / at the end
|
2023-08-23 19:56:08 +00:00
|
|
|
if (window.API_URL.endsWith('/')) {
|
2023-08-24 09:27:31 +00:00
|
|
|
window.API_URL = window.API_URL.slice(0, -1)
|
2020-05-10 16:26:33 +00:00
|
|
|
}
|
|
|
|
|
2021-08-19 18:09:45 +00:00
|
|
|
// directives
|
2021-11-22 21:36:17 +00:00
|
|
|
import focus from '@/directives/focus'
|
2023-03-10 13:46:23 +00:00
|
|
|
import {VTooltip} from 'floating-vue'
|
2022-10-04 11:28:33 +00:00
|
|
|
import 'floating-vue/dist/style.css'
|
2021-11-13 20:28:29 +00:00
|
|
|
import shortcut from '@/directives/shortcut'
|
2021-11-22 21:36:17 +00:00
|
|
|
import cypress from '@/directives/cypress'
|
2021-10-26 18:53:17 +00:00
|
|
|
|
2021-08-19 18:09:45 +00:00
|
|
|
// global components
|
2022-09-22 15:31:13 +00:00
|
|
|
import FontAwesomeIcon from '@/components/misc/Icon'
|
2021-11-23 07:08:21 +00:00
|
|
|
import Button from '@/components/input/button.vue'
|
2022-04-18 17:04:10 +00:00
|
|
|
import Modal from '@/components/misc/modal.vue'
|
2021-11-23 07:08:21 +00:00
|
|
|
import Card from '@/components/misc/card.vue'
|
2021-10-26 18:53:17 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
// We're loading the language before creating the app so that it won't fail to load when the user's
|
|
|
|
// language file is not yet loaded.
|
2023-06-12 16:01:56 +00:00
|
|
|
const browserLanguage = getBrowserLanguage()
|
|
|
|
setLanguage(browserLanguage).then(() => {
|
2023-03-10 13:46:23 +00:00
|
|
|
const app = createApp(App)
|
2021-08-20 13:46:41 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
app.use(Notifications)
|
2021-10-09 14:04:19 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
app.directive('focus', focus)
|
|
|
|
app.directive('tooltip', VTooltip)
|
|
|
|
app.directive('shortcut', shortcut)
|
|
|
|
app.directive('cy', cypress)
|
2021-10-26 18:53:17 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
app.component('icon', FontAwesomeIcon)
|
|
|
|
app.component('x-button', Button)
|
|
|
|
app.component('modal', Modal)
|
|
|
|
app.component('card', Card)
|
2021-10-26 18:53:17 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
app.config.errorHandler = (err, vm, info) => {
|
|
|
|
if (import.meta.env.DEV) {
|
|
|
|
console.error(err, vm, info)
|
|
|
|
}
|
2021-10-17 21:32:21 +00:00
|
|
|
error(err)
|
2023-03-10 13:46:23 +00:00
|
|
|
}
|
2021-10-09 14:04:19 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
if (import.meta.env.DEV) {
|
|
|
|
app.config.warnHandler = (msg) => {
|
|
|
|
error(msg)
|
|
|
|
throw(msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://stackoverflow.com/a/52076738/15522256
|
|
|
|
window.addEventListener('error', (err) => {
|
|
|
|
error(err)
|
|
|
|
throw err
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('unhandledrejection', (err) => {
|
|
|
|
// event.promise contains the promise object
|
|
|
|
// event.reason contains the reason for the rejection
|
|
|
|
error(err)
|
|
|
|
throw err
|
|
|
|
})
|
|
|
|
}
|
2021-08-20 13:46:41 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
app.config.globalProperties.$message = {
|
|
|
|
error,
|
|
|
|
success,
|
|
|
|
}
|
2021-10-26 18:53:17 +00:00
|
|
|
|
2023-03-10 13:46:23 +00:00
|
|
|
if (window.SENTRY_ENABLED) {
|
2023-06-18 12:49:25 +00:00
|
|
|
try {
|
2023-06-18 13:01:49 +00:00
|
|
|
import('./sentry').then(sentry => sentry.default(app, router))
|
2023-06-18 12:49:25 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error('Could not enable Sentry tracking', e)
|
|
|
|
}
|
2023-03-10 13:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.use(pinia)
|
|
|
|
app.use(router)
|
|
|
|
app.use(i18n)
|
2021-08-19 18:09:45 +00:00
|
|
|
|
2022-12-02 15:16:15 +00:00
|
|
|
app.mount('#app')
|
2023-03-10 13:46:23 +00:00
|
|
|
})
|