main.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { createApp } from "vue";
  2. import Cookies from "js-cookie";
  3. import ElementPlus 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 "@/store/modules/user";
  11. // 注册指令
  12. import plugins from "./plugins"; // plugins
  13. import { download, post, postTwo, get } from "@/utils/request";
  14. // svg图标
  15. import "virtual:svg-icons-register";
  16. import SvgIcon from "@/components/SvgIcon";
  17. import elementIcons from "@/components/SvgIcon/svgicon";
  18. import "./permission"; // permission control
  19. import { useDict } from "@/utils/dict";
  20. import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from "@/utils/ruoyi";
  21. import { createPinia } from 'pinia'//引入pinia
  22. import piniaPluginPersist from 'pinia-plugin-persist'//引入pinia数据持久化插件
  23. import {
  24. dictKeyValue,
  25. dictValueLabel,
  26. moneyFormat,
  27. calculationWeek,
  28. getDict,
  29. getDictOne,
  30. getPdf,
  31. getPdfTransverseA4,
  32. translateIntoEnglish,
  33. random,
  34. deepClone,
  35. timeInterval,
  36. compareTime,
  37. } from "@/utils/util";
  38. // 分页组件
  39. import Pagination from "@/components/Pagination";
  40. // 自定义树选择组件
  41. import TreeSelect from "@/components/TreeSelect";
  42. // 多语言
  43. import i18n from "@/lang/index";
  44. // 打印
  45. import print from "vue3-print-nb";
  46. const app = createApp(App);
  47. // 全局方法挂载
  48. app.config.globalProperties.useDict = useDict;
  49. app.config.globalProperties.get = get;
  50. app.config.globalProperties.post = post;
  51. app.config.globalProperties.postTwo = postTwo;
  52. app.config.globalProperties.download = download;
  53. app.config.globalProperties.parseTime = parseTime;
  54. app.config.globalProperties.resetForm = resetForm;
  55. app.config.globalProperties.handleTree = handleTree;
  56. app.config.globalProperties.addDateRange = addDateRange;
  57. app.config.globalProperties.selectDictLabel = selectDictLabel;
  58. app.config.globalProperties.selectDictLabels = selectDictLabels;
  59. app.config.globalProperties.t = i18n.global.t;
  60. //字典回显
  61. app.config.globalProperties.dictKeyValue = dictKeyValue;
  62. app.config.globalProperties.dictValueLabel = dictValueLabel;
  63. app.config.globalProperties.moneyFormat = moneyFormat;
  64. app.config.globalProperties.calculationWeek = calculationWeek;
  65. app.config.globalProperties.getDict = getDict;
  66. app.config.globalProperties.getDictOne = getDictOne;
  67. app.config.globalProperties.getPdf = getPdf;
  68. app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4;
  69. app.config.globalProperties.translateIntoEnglish = translateIntoEnglish;
  70. app.config.globalProperties.random = random;
  71. app.config.globalProperties.deepClone = deepClone;
  72. app.config.globalProperties.timeInterval = timeInterval;
  73. app.config.globalProperties.compareTime = compareTime;
  74. app.config.globalProperties.useUserStore = useUserStore;
  75. // 全局组件挂载
  76. app.component("Pagination", Pagination);
  77. app.component("TreeSelect", TreeSelect);
  78. app.use(router);
  79. app.use(store);
  80. app.use(plugins);
  81. app.use(i18n);
  82. app.use(elementIcons);
  83. app.use(print);
  84. app.component("svg-icon", SvgIcon);
  85. app.use(createPinia().use(piniaPluginPersist))//安装插件
  86. directive(app);
  87. // 使用element-plus 并且设置全局的大小
  88. app.use(ElementPlus, {
  89. locale: locale,
  90. // 支持 large、default、small
  91. size: Cookies.get("size") || "default",
  92. });
  93. app.mount("#app");