Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

main.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* eslint-disable prefer-template */
  2. import Vue from "vue";
  3. import EvaIcons from "vue-eva-icons";
  4. import axios from "axios";
  5. import moment from "moment";
  6. import App from "./App.vue";
  7. import router from "./router";
  8. import store from "./store";
  9. import VModal from "vue-js-modal";
  10. import "font-awesome/css/font-awesome.min.css";
  11. import VueGeolocation from "vue-browser-geolocation";
  12. import * as VueGoogleMaps from "vue2-google-maps";
  13. Vue.use(VueGeolocation);
  14. Vue.use(VueGoogleMaps, {
  15. load: {
  16. key: "AIzaSyC1Ksf24t03oxHkQYb-DymF9HipgGP30ao",
  17. libraries: "places" // necessary for places input
  18. }
  19. });
  20. Vue.component("VueFontawesome", require("vue-fontawesome-icon/VueFontawesome.vue").default);
  21. Vue.use(EvaIcons);
  22. Vue.config.productionTip = false;
  23. // axios.defaults.baseURL = 'http://localhost:57260/';
  24. Vue.prototype.$axios = axios;
  25. Vue.prototype.$http = axios;
  26. const token = localStorage.getItem("token");
  27. if (token) {
  28. Vue.prototype.$http.defaults.headers.common.Authorization = token;
  29. }
  30. router.beforeEach((to, from, next) => {
  31. if (to.matched.some(record => record.meta.requiresAuth)) {
  32. if (store.getters.isLoggedIn) {
  33. next();
  34. return;
  35. }
  36. next("/users/login");
  37. } else {
  38. next();
  39. }
  40. });
  41. Vue.filter("toCurrency", value => {
  42. if (typeof value !== "number") {
  43. return value;
  44. }
  45. const formatter = new Intl.NumberFormat("en-US", {
  46. minimumFractionDigits: 2
  47. });
  48. return `R ${formatter.format(value)}`;
  49. });
  50. Vue.filter("toProper", value => {
  51. if (typeof value !== "string") {
  52. console.log(typeof value);
  53. return value;
  54. }
  55. value = value.replace(/([a-z])([A-Z])/g, "$1 $2");
  56. return value.charAt(0).toUpperCase() + value.slice(1);
  57. });
  58. Vue.filter("toDate", value => value.substring(0, value.length > 9 ? 10 : value.length));
  59. Vue.filter("toTime", value => moment(String(value)).format("hh:mm"));
  60. new Vue({
  61. render: h => h(App),
  62. router,
  63. store
  64. }).$mount("#app");
  65. Vue.use(VModal);