main.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import { createApp } from "vue";
  2. import Cookies from "js-cookie";
  3. import ElementPlus, { ElSelect } from "element-plus";
  4. import locale from "element-plus/lib/locale/lang/zh-cn"; // 中文语言
  5. import "@/assets/styles/index.scss"; // global css
  6. import App from "./App";
  7. import store from "./store";
  8. import router from "./router";
  9. import directive from "./directive"; // directive
  10. import useUserStore from "/src/store/modules/user";
  11. // 注册指令
  12. import plugins from "./plugins"; // plugins
  13. import { download, post, postFile, get, getFile, postUploadFile, postUploadAndDownloadFile } from "/src/utils/request";
  14. // svg图标
  15. import "virtual:svg-icons-register";
  16. import SvgIcon from "/src/components/SvgIcon";
  17. import elementIcons from "/src/components/SvgIcon/svgicon";
  18. import "./permission"; // permission control
  19. import { useDict } from "/src/utils/dict";
  20. import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from "/src/utils/ruoyi";
  21. import { createPinia } from "pinia"; //引入pinia
  22. import piniaPluginPersist from "pinia-plugin-persist"; //引入pinia数据持久化插件
  23. import VueLazyLoad from "vue-lazyload";
  24. // 按钮防抖
  25. import preReClick from "./directive/preReClick.js";
  26. import {
  27. dictKeyValue,
  28. dictValueLabel,
  29. moneyFormat,
  30. calculationWeek,
  31. getDict,
  32. getDictOne,
  33. getPdf,
  34. getPdfTransverseA4,
  35. translateIntoEnglish,
  36. random,
  37. deepClone,
  38. timeInterval,
  39. compareTime,
  40. downloadFile,
  41. NumberToChinese,
  42. } from "/src/utils/util";
  43. import "@/utils/table2excel";
  44. // 分页组件
  45. import Pagination from "/src/components/Pagination";
  46. // 自定义树选择组件
  47. import TreeSelect from "/src/components/TreeSelect";
  48. // 多语言
  49. import i18n from "/src/lang/index";
  50. // 打印
  51. import print from "vue3-print-nb";
  52. const app = createApp(App);
  53. // 全局方法挂载
  54. app.config.globalProperties.useDict = useDict;
  55. app.config.globalProperties.get = get;
  56. app.config.globalProperties.post = post;
  57. app.config.globalProperties.postFile = postFile;
  58. app.config.globalProperties.postUploadFile = postUploadFile;
  59. app.config.globalProperties.postUploadAndDownloadFile = postUploadAndDownloadFile;
  60. app.config.globalProperties.getFile = getFile;
  61. app.config.globalProperties.download = download;
  62. app.config.globalProperties.parseTime = parseTime;
  63. app.config.globalProperties.resetForm = resetForm;
  64. app.config.globalProperties.handleTree = handleTree;
  65. app.config.globalProperties.addDateRange = addDateRange;
  66. app.config.globalProperties.selectDictLabel = selectDictLabel;
  67. app.config.globalProperties.selectDictLabels = selectDictLabels;
  68. app.config.globalProperties.t = i18n.global.t;
  69. //字典回显
  70. app.config.globalProperties.dictKeyValue = dictKeyValue;
  71. app.config.globalProperties.dictValueLabel = dictValueLabel;
  72. app.config.globalProperties.moneyFormat = moneyFormat;
  73. app.config.globalProperties.calculationWeek = calculationWeek;
  74. app.config.globalProperties.getDict = getDict;
  75. app.config.globalProperties.getDictOne = getDictOne;
  76. app.config.globalProperties.getPdf = getPdf;
  77. app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4;
  78. app.config.globalProperties.translateIntoEnglish = translateIntoEnglish;
  79. app.config.globalProperties.random = random;
  80. app.config.globalProperties.deepClone = deepClone;
  81. app.config.globalProperties.timeInterval = timeInterval;
  82. app.config.globalProperties.compareTime = compareTime;
  83. app.config.globalProperties.downloadFile = downloadFile;
  84. app.config.globalProperties.NumberToChinese = NumberToChinese;
  85. app.config.globalProperties.useUserStore = useUserStore;
  86. // 全局组件挂载
  87. app.component("Pagination", Pagination);
  88. app.component("TreeSelect", TreeSelect);
  89. app.use(router);
  90. app.use(store);
  91. app.use(plugins);
  92. app.use(i18n);
  93. app.use(elementIcons);
  94. app.use(print);
  95. app.component("svg-icon", SvgIcon);
  96. app.use(createPinia().use(piniaPluginPersist)); //安装插件
  97. app.use(VueLazyLoad, {
  98. preLoad: 1.3,
  99. error: "./assets/images/empty.png",
  100. attempt: 1,
  101. listenEvents: ["scroll"],
  102. });
  103. directive(app);
  104. ElSelect.props.filterable = {
  105. type: Boolean,
  106. default: true,
  107. };
  108. ElSelect.props.clearable = {
  109. type: Boolean,
  110. default: true,
  111. };
  112. // 使用element-plus 并且设置全局的大小
  113. app.use(ElementPlus, {
  114. locale: locale,
  115. // 支持 large、default、small
  116. size: Cookies.get("size") || "default",
  117. });
  118. app._context.components.ElDialog.props.closeOnClickModal.default = false;
  119. app.use(preReClick);
  120. app.mount("#app");