import * as ElIcons from "@element-plus/icons-vue";
import Axios from 'axios'
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import installElementPlus from "./plugins/element";
import plugins from "./plugins";
import "./assets/css/element-plus.scss";
import "./assets/css/layout.scss";
import ELMessage from 'element-plus'
import InfiniteScroll from './utils/lazyLoad'
import { dispatchEventStorage } from "@/utils/storage.js";
import DictTag from '@/components/DictTag/index'

// echart图表
// import * as echarts from 'echarts'
// Vue.prototype.$echarts = echarts
const app = createApp(App);
//注册自定义指令
app.use(InfiniteScroll)
Object.keys(ElIcons).forEach((key) => {
  //全局注册 element 图标
  app.component(key, ElIcons[key]);
});
app.config.globalProperties.$http = axios

//告诉前页面内的事件监听器内部是否会调用preventDefault函数来阻止事件的默认行为，以便浏览器根据这个信息更好地做出决策来优化页面性能
// import "default-passive-events";
import installDirective from "@/directives";

// 初始化样式表
import "@/styles/base.scss";

// import '@/styles/common.scss';
// 导入svgIcon
import installIcons from "@/icons";

//导入路由鉴权
import "./permission";

//全局属性(v2过滤器)
import installFilter from "@/filters";
//事件总线
import mitt from "mitt";

import {
  resetForm
} from "@/utils/validate";
import {
  getDict,
  setCascader
} from '@/utils/dict';
import axios from "axios";

//挂载全局方法
app.config.globalProperties.resetForm = resetForm;
app.config.globalProperties.$dict = getDict; //字典公共函数
app.config.globalProperties.$message = ELMessage; //element提示组件
app.config.globalProperties.$set = setCascader; //设置级联选择器回显
app.config.globalProperties.mittBus = new mitt(); //配置事件总线
app.component('DictTag', DictTag); //字典组件

installElementPlus(app);
installIcons(app);
installFilter(app);
installDirective(app);
app.use(store).use(ELMessage).use(router).use(dispatchEventStorage).use(plugins).mount("#app");
