Skip to content
Snippets Groups Projects
Select Git revision
  • develop default protected
  • master
  • 1121-download
  • plugins-v3
  • 876-http-signature
  • plugins-v2
  • plugins
  • 0.21.2
  • 0.21.1
  • 0.21
  • 0.21-rc2
  • 0.21-rc1
  • 0.20.1
  • 0.20.0
  • 0.20.0-rc1
  • 0.19.1
  • 0.19.0
  • 0.19.0-rc2
  • 0.19.0-rc1
  • 0.18.3
  • 0.18.2
  • 0.18.1
  • 0.18
  • 0.17
  • 0.16.3
  • 0.16.2
  • 0.16.1
27 results

main.js

Blame
  • Forked from funkwhale / funkwhale
    7947 commits behind the upstream repository.
    main.js 1.45 KiB
    // The Vue build version to load with the `import` command
    // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
    import logger from '@/logging'
    
    logger.default.info('Loading environment:', process.env.NODE_ENV)
    logger.default.debug('Environment variables:', process.env)
    
    import Vue from 'vue'
    import App from './App'
    import router from './router'
    import VueResource from 'vue-resource'
    import auth from './auth'
    import VueLazyload from 'vue-lazyload'
    
    window.$ = window.jQuery = require('jquery')
    
    // this is absolutely dirty but at the moment, semantic UI does not
    // play really nice with webpack and I want to get rid of Google Fonts
    // require('./semantic/semantic.css')
    require('semantic-ui-css/semantic.js')
    
    Vue.use(VueResource)
    Vue.use(VueLazyload)
    Vue.config.productionTip = false
    
    Vue.http.interceptors.push(function (request, next) {
      // modify headers
      if (auth.user.authenticated) {
        request.headers.set('Authorization', auth.getAuthHeader())
      }
      next(function (response) {
        // redirect to login form when we get unauthorized response from server
        if (response.status === 401) {
          logger.default.warn('Received 401 response from API, redirecting to login form')
          router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
        }
      })
    })
    
    auth.checkAuth()
    /* eslint-disable no-new */
    new Vue({
      el: '#app',
      router,
      template: '<App/>',
      components: { App }
    })
    
    logger.default.info('Everything loaded!')