main.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { createApp } from "vue";
  2. import ElementPlus from "element-plus";
  3. import "element-plus/lib/theme-chalk/index.css";
  4. import locale from "element-plus/lib/locale/lang/zh-cn";
  5. import App from "./App.vue";
  6. import router from "@/router";
  7. import "reset-css";
  8. import store from "@/store";
  9. import "./styles/element-variables.scss";
  10. import mitt from "mitt"
  11. //全局注册Nprogress加载指示器
  12. import NProgress from "nprogress";
  13. import "nprogress/nprogress.css";
  14. NProgress.configure({ showSpinner: false, easing: "ease", speed: 500 });
  15. const app = createApp(App);
  16. console.warn("环境", import.meta.env);
  17. // 开发环境开启devtool
  18. if (import.meta.env.MODE === "development") {
  19. app.config.devtools = true;
  20. }
  21. app.config.errorHandler = (err, vm, info) => {
  22. console.error("Vue错误:", err, vm, info);
  23. };
  24. app.config.warnHandler = function (msg, vm, trace) {
  25. // console.warn("Vue警告:", msg, vm, trace);
  26. };
  27. app.config.performance = true;
  28. //全局注册组件
  29. import AdminLayout from "@/layouts/AdminLayout.vue";
  30. app.component("AdminLayout", AdminLayout);
  31. import AppTagsViewSwitcher from "@/layouts/TagsViewSwitcher/index.vue";
  32. app.component("AppTagsViewSwitcher", AppTagsViewSwitcher);
  33. import AppSideBar from "@/layouts/AppSideBar/index.vue";
  34. app.component("AppSideBar", AppSideBar);
  35. import AppBreadcrumb from "@/layouts/Breadcrumb/index.vue";
  36. app.component("AppBreadcrumb", AppBreadcrumb);
  37. import AppHeader from "@/layouts/AppHeader/index.vue";
  38. app.component("AppHeader", AppHeader);
  39. import MobileAppHeader from "@/layouts/MobileAppHeader/index.vue";
  40. app.component("MobileAppHeader", MobileAppHeader);
  41. import MobileAppSideBar from "@/layouts/MobileAppSideBar/index.vue";
  42. app.component("MobileAppSideBar", MobileAppSideBar);
  43. app.use(ElementPlus, { locale });
  44. app.use(router);
  45. app.use(store);
  46. window.$app = app
  47. app.config.globalProperties.$bus = new mitt()
  48. app.mount("#app");