您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

main.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* eslint-disable prefer-template */
  2. import Vue from 'vue';
  3. import EvaIcons from 'vue-eva-icons';
  4. import axios from 'axios';
  5. import App from './App.vue';
  6. import router from './router';
  7. import store from './store';
  8. Vue.use(EvaIcons);
  9. Vue.config.productionTip = false;
  10. Vue.prototype.$http = axios;
  11. const token = localStorage.getItem('token');
  12. if (token) {
  13. Vue.prototype.$http.defaults.headers.common.Authorization = token;
  14. }
  15. router.beforeEach((to, from, next) => {
  16. if (to.matched.some(record => record.meta.requiresAuth)) {
  17. if (store.getters.isLoggedIn) {
  18. next();
  19. return;
  20. }
  21. next('/users/login');
  22. } else {
  23. next();
  24. }
  25. });
  26. Vue.filter('toCurrency', (value) => {
  27. if (typeof value !== 'number') {
  28. return value;
  29. }
  30. const formatter = new Intl.NumberFormat('en-US', {
  31. minimumFractionDigits: 2,
  32. });
  33. return `R ${formatter.format(value)}`;
  34. });
  35. Vue.filter('toDate', value => value.substring(0, value.length > 9 ? 10 : value.length));
  36. new Vue({
  37. render: h => h(App),
  38. router,
  39. store,
  40. }).$mount('#app');