/*
 * @Date: 2023-06-18 10:09:15
 * @LastEditors: zhubj
 * @LastEditTime: 2023-06-19 16:48:14
 * @Description: 头部注释
 * @FilePath: \own-vue3-vuecli-template\src\main.js
 */
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import utils from '@/utils/index.js'
import store from './store'
import axios from 'axios'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import * as echarts from 'echarts'

import L from "leaflet"
import "leaflet/dist/leaflet.css"
import "leaflet-contextmenu"
import icon from "leaflet/dist/images/marker-icon.png" // 引入leaflet默认图标

import './permission' // permission control

const debounce = (fn, delay) => {
    let timer = null;
    return function () {
      let context = this;
      let args = arguments;
      clearTimeout(timer);
      timer = setTimeout(function () {
        fn.apply(context, args);
      }, delay);
    }
  }
   
  const _ResizeObserver = window.ResizeObserver;
  window.ResizeObserver = class ResizeObserver extends _ResizeObserver{
    constructor(callback) {
      callback = debounce(callback, 16);
      super(callback);
    }
  }


const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.config.globalProperties.$utils = utils;
app.config.globalProperties.$echarts = echarts;
app.config.globalProperties.$axios = axios;
app.config.globalProperties.icoName = icon
app.use(L);
app.use(store).use(router).use(ElementPlus, { size: 'small',locale: zhCn }).mount('#app')
