You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.1 KiB

  1. import Vue from 'vue'
  2. import Router from 'vue-router';
  3. import Resource from 'vue-resource';
  4. import i18n from 'vue-i18n';
  5. import locales from './locales/locales';
  6. import App from './app.vue';
  7. import IndexView from './components/index.vue';
  8. import Dashboard from './components/dashboard.vue';
  9. import auth from './services/auth';
  10. Vue.use(Resource);
  11. Vue.use(Router);
  12. var browserLanguage = (navigator.language || navigator.browserLanguage).split('-')[0];
  13. var lang = browserLanguage in locales ? browserLanguage : 'en';
  14. Vue.use(i18n, {
  15. lang: lang,
  16. locales: locales
  17. });
  18. Vue.http.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('token');
  19. auth.checkAuth();
  20. export var router = new Router();
  21. router.map({
  22. '/': {
  23. auth: true,
  24. component: Dashboard
  25. },
  26. '/presentation/': {
  27. component: IndexView
  28. }
  29. });
  30. router.redirect({
  31. '*': '/'
  32. });
  33. router.start(App, '#app');
  34. router.beforeEach(function (transition) {
  35. if (transition.to.auth && !auth.user.authenticated) {
  36. transition.redirect('/presentation/')
  37. } else {
  38. transition.next()
  39. }
  40. });