main.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import App from "./App.vue";
  2. import router from "./router";
  3. import { setupStore } from "@/store";
  4. import { useI18n } from "@/plugins/i18n";
  5. import { getPlatformConfig } from "./config";
  6. import { MotionPlugin } from "@vueuse/motion";
  7. import { useEcharts } from "@/plugins/echarts";
  8. import { createApp, type Directive } from "vue";
  9. import { useElementPlus } from "@/plugins/elementPlus";
  10. import { injectResponsiveStorage } from "@/utils/responsive";
  11. import Table from "@pureadmin/table";
  12. import PureDescriptions from "@pureadmin/descriptions";
  13. // 引入重置样式
  14. import "./style/reset.scss";
  15. // 导入公共样式
  16. import "./style/index.scss";
  17. // 一定要在main.ts中导入tailwind.css,防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题
  18. import "./style/tailwind.css";
  19. import "element-plus/dist/index.css";
  20. // 导入字体图标
  21. import "./assets/iconfont/iconfont.js";
  22. import "./assets/iconfont/iconfont.css";
  23. const app = createApp(App);
  24. // 自定义指令
  25. import * as directives from "@/directives";
  26. Object.keys(directives).forEach(key => {
  27. app.directive(key, (directives as { [key: string]: Directive })[key]);
  28. });
  29. // 全局注册`@iconify/vue`图标库
  30. import {
  31. IconifyIconOffline,
  32. IconifyIconOnline,
  33. FontIcon
  34. } from "./components/ReIcon";
  35. app.component("IconifyIconOffline", IconifyIconOffline);
  36. app.component("IconifyIconOnline", IconifyIconOnline);
  37. app.component("FontIcon", FontIcon);
  38. // 全局注册按钮级别权限组件
  39. import { Auth } from "@/components/ReAuth";
  40. app.component("Auth", Auth);
  41. // 全局注册`vue-tippy`
  42. import "tippy.js/dist/tippy.css";
  43. import "tippy.js/animations/perspective.css";
  44. import VueTippy from "vue-tippy";
  45. app.use(VueTippy, {
  46. defaultProps: { animation: "perspective" }
  47. });
  48. getPlatformConfig(app).then(async config => {
  49. setupStore(app);
  50. app.use(router);
  51. await router.isReady();
  52. injectResponsiveStorage(app, config);
  53. app
  54. .use(MotionPlugin)
  55. .use(useI18n)
  56. .use(useElementPlus)
  57. .use(Table)
  58. .use(PureDescriptions)
  59. .use(useEcharts);
  60. app.mount("#app");
  61. });