import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Element from 'element-ui'
import 'normalize.css/normalize.css' // CSS重置
import '@/styles/element-ui.scss'; // element样式
import '@/styles/index.scss' // 全局样式
import '@/icons' // icon
import IndexDB from '@/utils/indexedDB'
import * as filters from './filters/filters'
import storage from "@/utils/storage";
import axios from "@/axios";
import eventBus from "@/utils/eventBus";
// import VueAMap from "vue-amap";
import PageHeader from '@/components/PageHeader'
import PageFooter from '@/components/PageFooter'
import Pagination from '@/components/Pagination'
import FormClear from '@/components/FormClear'
import TextLabel from '@/components/TextLabel'

// 自定义组件注册
Vue.component(PageHeader.name, PageHeader)
Vue.component(PageFooter.name, PageFooter)
Vue.component(Pagination.name, Pagination)
Vue.component(FormClear.name, FormClear)
Vue.component(TextLabel.name, TextLabel)

// Element
// large / medium / small / mini
Vue.use(Element, {size: 'medium'});

// 全局加载中样式
Vue.prototype.loading = () => Vue.prototype.$loading({
    lock: true,
    body: true,
    text: 'Loading',
    spinner: 'el-icon-loading',
    background: 'rgba(0, 0, 0, 0.7)',
    customClass:'z-index-top'
});

// 数据库操作
Vue.use(IndexDB);

// 全局过滤器
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
})

// 数据存储
Vue.use(storage);

// 网络请求对象
Vue.use(axios);

// 事件总线
Vue.use(eventBus);

// 设置为 false 以阻止 vue 在启动时生成生产提示。默认为true
Vue.config.productionTip = false;

// 取消 Vue 所有的日志与警告。默认值：false
Vue.config.silent = process.env.NODE_ENV === 'production'

// 配置是否允许 vue-devtools 检查代码。默认开发为true，生产为false
Vue.config.devtools = process.env.NODE_ENV !== 'production'

// 实际打包时应该不引入mock !!! 这里不能使用 import 代替 require
// if (process.env.NODE_ENV !== 'production') require('@/mock');

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app');

Array.prototype.remove = function (val) {
    const index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
    return index;
};

// 高德地图 https://lbs.amap.com/api/javascript-api/guide/services/geolocation
// Vue.use(VueAMap);
//
// VueAMap.initAMapApiLoader({
//     key: 'db292361ccae610e5123dea77ef5caf7',
//     plugin: [
//         // "AMap.Autocomplete",
//         "AMap.Geolocation",
//         "AMap.PlaceSearch",
//         "AMap.PolyEditor",
//         // "AMap.Scale",
//         "AMap.Geocoder",
//         'AMap.ToolBar'
//     ],
//     v: "1.4.4"
// });

// import {AMapManager} from "vue-amap";
// Vue.prototype.$aMapManager = new AMapManager();
// import {lazyAMapApiLoaderInstance} from "vue-amap";
// lazyAMapApiLoaderInstance.load().then(() => {
//     Vue.prototype.$geocoder = new AMap.Geocoder({extensions: "all"});
// });

