main.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 { useVxeTable } from "@/plugins/vxeTable";
  10. import { useElementPlus } from "@/plugins/elementPlus";
  11. import { injectResponsiveStorage } from "@/utils/responsive";
  12. import Table from "@pureadmin/table";
  13. import PureDescriptions from "@pureadmin/descriptions";
  14. // 引入重置样式
  15. import "./style/reset.scss";
  16. // 导入公共样式
  17. import "./style/index.scss";
  18. // 一定要在main.ts中导入tailwind.css,防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题
  19. import "./style/tailwind.css";
  20. import "element-plus/dist/index.css";
  21. // 导入字体图标
  22. import "./assets/iconfont/iconfont.js";
  23. import "./assets/iconfont/iconfont.css";
  24. import global from "./global/index.js";
  25. window.vueGlobal = global
  26. const app = createApp(App);
  27. // 自定义指令
  28. import * as directives from "@/directives";
  29. Object.keys(directives).forEach(key => {
  30. app.directive(key, (directives as { [key: string]: Directive })[key]);
  31. });
  32. // 全局注册@iconify/vue图标库
  33. import {
  34. IconifyIconOffline,
  35. IconifyIconOnline,
  36. FontIcon
  37. } from "./components/ReIcon";
  38. app.component("IconifyIconOffline", IconifyIconOffline);
  39. app.component("IconifyIconOnline", IconifyIconOnline);
  40. app.component("FontIcon", FontIcon);
  41. // 全局注册按钮级别权限组件
  42. import { Auth } from "@/components/ReAuth";
  43. import { Perms } from "@/components/RePerms";
  44. app.component("Auth", Auth);
  45. app.component("Perms", Perms);
  46. // 全局注册vue-tippy
  47. import "tippy.js/dist/tippy.css";
  48. import "tippy.js/themes/light.css";
  49. import VueTippy from "vue-tippy";
  50. app.use(VueTippy);
  51. getPlatformConfig(app).then(async config => {
  52. setupStore(app);
  53. app.use(router);
  54. await router.isReady();
  55. injectResponsiveStorage(app, config);
  56. app
  57. .use(MotionPlugin)
  58. .use(useI18n)
  59. .use(useElementPlus)
  60. .use(Table)
  61. .use(useVxeTable)
  62. .use(PureDescriptions)
  63. .use(useEcharts);
  64. app.mount("#app");
  65. });
  66. // 兼容低版本浏览器不支持 Object.hasOwn 的问题
  67. if (!Object.hasOwn) {
  68. Object.hasOwn = function(obj, prop) {
  69. // 等价于 Object.prototype.hasOwnProperty.call(obj, prop)
  70. return Object.prototype.hasOwnProperty.call(obj, prop);
  71. };
  72. }
  73. export default app