You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.ts 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // import 'babel-polyfill';
  2. // import 'require';
  3. //#pragma warning(disable:18)
  4. import { createApp, createVNode } from 'vue'
  5. import App from './App.vue'
  6. import router from './router/index' //路由
  7. //element-plus 组件相关
  8. import ElementPlus, { valueEquals } from 'element-plus'
  9. import 'element-plus/dist/index.css'
  10. import zhCn from 'element-plus/es/locale/lang/zh-cn'
  11. import * as EleIcons from '@element-plus/icons-vue'
  12. //fragment
  13. // import Fragment from 'vue-fragment'
  14. //全局样式
  15. import './style/main.css'
  16. import { isValidKey } from '@/utils/utils'
  17. //请求
  18. import * as request from '@/api/index'
  19. //全局配置
  20. import { system } from '@/config'
  21. //https://xiaoman.blog.csdn.net/article/details/123338137?spm=1001.2014.3001.5502
  22. import { createPinia } from 'pinia' //一个观察者监听对象
  23. import { piniaPlugin } from '@/store/plug'
  24. //导出表格
  25. //import JsonExcel from 'vue-json-excel'
  26. import itemIoc from '@/layout/components/ItemIcon.vue'
  27. const app = createApp(App)
  28. //app.component('downloadExcel', JsonExcel)
  29. //全局注册请求
  30. app.config.globalProperties.$request = request
  31. app.config.globalProperties.$system = system
  32. //初始化pinia
  33. const pinia = createPinia()
  34. //注册pinia 插件
  35. pinia.use(piniaPlugin({
  36. key: "pinia"
  37. }))
  38. // 全局配置
  39. app.config.globalProperties.$ELEMENT = {
  40. size: 'medium', // 设置全局尺寸(可选)
  41. // 更多全局配置...
  42. input: {
  43. clearable: true, // 设置所有输入框的 clearable 为 true
  44. },
  45. };
  46. app.use(router).use(pinia).use(ElementPlus, {
  47. // 使用element-plus
  48. locale: zhCn,
  49. })
  50. import { directive } from '@/utils/trimDirective';
  51. directive(app);
  52. //全局图标组件
  53. for (const name in EleIcons) {
  54. if (isValidKey(name, EleIcons)) {
  55. app.component(name, EleIcons[name]) //添加图标组件
  56. }
  57. }
  58. // 下面为全局注册图标组件
  59. // 创建Icon组件
  60. const Icon: any = (props: { icon: string }) => {
  61. const { icon } = props
  62. return createVNode(EleIcons[icon as keyof typeof EleIcons])
  63. }
  64. // 注册Icon组件
  65. app.component('icon-tab', Icon)
  66. app.component('item-ioc', itemIoc)
  67. app.mount('#app')