main.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import './assets/main.css'
  2. import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  3. import { createApp } from 'vue'
  4. import ElementPlus from 'element-plus'
  5. import 'element-plus/dist/index.css'
  6. import { createPinia } from 'pinia'
  7. import Cookies from 'js-cookie';
  8. import 'normalize.css/normalize.css';
  9. import moment from 'moment';
  10. import Echarts from 'echarts';
  11. import App from './App.vue'
  12. import router from './router'
  13. import zhCn from "element-plus/es/locale/lang/zh-cn"
  14. // import './permission' // permission control
  15. // import permission from '@/directive/permission/index.js' // 权限判断指令
  16. import piniaPersist from 'pinia-plugin-persist'
  17. import MyPlugin from '@/utils/print' // 打印
  18. const app = createApp(App)
  19. //pinia持久化
  20. const pinia = createPinia()
  21. pinia.use(piniaPersist)
  22. for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  23. app.component(key, component)
  24. }
  25. // 设置全局属性
  26. app.config.globalProperties.$echarts = Echarts;
  27. //设置全局方法
  28. app.config.globalProperties.dateFormatA = function (row, column) {
  29. let date = row[column.property];
  30. if (this.isEmptyObjVue(date)) {
  31. return '';
  32. }
  33. return moment(date).format('YYYY-MM-DD HH:mm:ss');
  34. };
  35. app.config.globalProperties.formateTime = function (date) {
  36. if (this.isEmptyObjVue(date)) {
  37. return '';
  38. }
  39. return moment(date).format('YYYY-MM-DD HH:mm:ss');
  40. };
  41. app.config.globalProperties.formateDay = function (date) {
  42. if (this.isEmptyObjVue(date)) {
  43. return '';
  44. }
  45. return moment(date).format('YYYY-MM-DD');
  46. };
  47. // 判空
  48. app.config.globalProperties.isEmptyObjVue = function (obj) {
  49. if (obj == null || obj == undefined || ("" + obj) == "") {
  50. return true;
  51. }
  52. return false;
  53. };
  54. //分页插件
  55. zhCn.el.pagination.total = "共:"+`{total}`+"条"
  56. zhCn.el.pagination.goto = "跳转至"
  57. // 注册全局指令
  58. // app.directive('permission', permission);
  59. // 使用 Print 插件
  60. app.use(MyPlugin);
  61. // 使用 ElementPlus 插件
  62. app.use(ElementPlus, {
  63. size: Cookies.get('size') || 'medium', // set element-ui default size
  64. locale: zhCn
  65. });
  66. app.use(pinia)
  67. app.use(router)
  68. // console.log('环境变量:', import.meta.env);
  69. app.mount('#app')