Files
filegator/frontend/main.js
Milos Stojanovic 261607e1d3 initial commit
2019-06-13 18:52:40 +02:00

65 lines
1.6 KiB
JavaScript

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Buefy from 'buefy'
import shared from './mixins/shared'
import axios from 'axios'
import api from './api/api'
import '@fortawesome/fontawesome-free/css/all.css'
import '@fortawesome/fontawesome-free/css/fontawesome.css'
//TODO: import './registerServiceWorker'
Vue.config.productionTip = false
Vue.config.baseURL =
process.env.VUE_APP_API_ENDPOINT
? process.env.VUE_APP_API_ENDPOINT
: window.location.origin+window.location.pathname+'?r='
axios.defaults.withCredentials = true
axios.defaults.baseURL = Vue.config.baseURL
axios.defaults.headers['Content-Type'] = 'application/json'
Vue.use(Buefy, {
defaultIconPack: 'fas',
})
Vue.mixin(shared)
new Vue({
router,
store,
render: h => h(App),
created: function() {
api.getConfig()
.then(ret => {
this.$store.commit('setConfig', ret.data.data)
api.getUser()
.then((user) => {
this.$store.commit('initialize')
this.$store.commit('setUser', user)
this.$router.push('/')
})
.catch(error => {
this.$notification.open({
message: this.lang('Something went wrong'),
type: 'is-danger',
queue: false,
indefinite: true,
})
})
})
.catch(() => {
this.$notification.open({
message: this.lang('Something went wrong'),
type: 'is-danger',
queue: false,
indefinite: true,
})
})
},
}).$mount('#app')