main.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import App from "./App.vue";
  2. import router from "./router";
  3. import { setupStore } from "@/store";
  4. import ElementPlus from "element-plus";
  5. import { getServerConfig } from "./config";
  6. import { createApp, Directive } from "vue";
  7. import { MotionPlugin } from "@vueuse/motion";
  8. import { useEcharts } from "@/plugins/echarts";
  9. import { injectResponsiveStorage } from "@/utils/responsive";
  10. import "virtual:svg-icons-register";
  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. import SvgIcon from "./components/SvgIcon/index.vue";
  36. app.component("IconifyIconOffline", IconifyIconOffline);
  37. app.component("IconifyIconOnline", IconifyIconOnline);
  38. app.component("FontIcon", FontIcon);
  39. app.component("SvgIcon", SvgIcon);
  40. // 全局注册按钮级别权限组件
  41. import { Auth } from "@/components/ReAuth";
  42. app.component("Auth", Auth);
  43. getServerConfig(app).then(async config => {
  44. setupStore(app);
  45. app.use(router);
  46. await router.isReady();
  47. injectResponsiveStorage(app, config);
  48. app
  49. .use(MotionPlugin)
  50. .use(ElementPlus)
  51. .use(Table)
  52. .use(PureDescriptions)
  53. .use(useEcharts);
  54. app.mount("#app");
  55. });