main.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { createApp } from 'vue'
  2. import App from './App.vue'
  3. import { createPinia } from 'pinia'
  4. import ElementPlus from 'element-plus'
  5. import moment from 'moment'
  6. import 'element-plus/dist/index.css'
  7. import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  8. import router from '@/router'
  9. // 全局样式
  10. import '@/styles/index.scss'
  11. // i18n
  12. import { setupI18n } from '@/lang'
  13. // svg
  14. import 'virtual:svg-icons-register'
  15. import svgIcon from '@/icons/SvgIcon.vue'
  16. // 自定义指令
  17. import { setupDirective } from '@/directive/index.js'
  18. // 日期格式使用中文(即:一周从周一开始算)
  19. import 'dayjs/locale/zh-cn'
  20. // 全局图片替换
  21. import { checkFileUrl } from '@/utils/index.js'
  22. moment.locale('zh-cn', {
  23. longDateFormat: {
  24. LT: 'HH:mm',
  25. LTS: 'HH:mm:ss',
  26. L: 'YYYY-MM-DD',
  27. LL: 'YYYY-MM-DD HH:mm:ss'
  28. },
  29. week: {
  30. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  31. dow: 1, // 星期一, 是一个星期的第一天
  32. doy: 4 // 1月4日所在的的一周是一年的第一周
  33. }
  34. })
  35. const app = createApp(App)
  36. app.config.globalProperties.checkFileUrl = checkFileUrl
  37. /**
  38. * 打开窗口方法
  39. * @param {*} params 路由跳转参数
  40. * @param {*} target window.open的target参数
  41. * @param {*} windowFeatures window.open的windowFeatures参数
  42. */
  43. router.open = (params, target = '_blank', windowFeatures) => {
  44. const routerRes = router.resolve(params)
  45. window.open(routerRes.href, target, windowFeatures)
  46. }
  47. // router
  48. app.use(router)
  49. // pinia
  50. const pinia = createPinia()
  51. app.use(pinia)
  52. // i18n
  53. app.use(setupI18n)
  54. app.component('SvgIcon', svgIcon)
  55. // 注册指令(directive)
  56. setupDirective(app)
  57. // element-plus
  58. app.use(ElementPlus)
  59. for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  60. app.component(key, component)
  61. }
  62. app.mount('#app')