import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import {myMessage } from '@/utils/messageOnce.js';
import '@/utils/directives.js'
import selectscroll from '@/utils/selectscroll.js';
import 'element-ui/lib/theme-chalk/index.css'
import './styles/element-variables.scss'
import enLang from 'element-ui/lib/locale/lang/zh-CN' // 如果使用中文语言包请默认支持，无需额外引入，请删除该依赖
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import 'default-passive-events'
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log
import Viewer from 'v-viewer'

import "viewerjs/dist/viewer.css"
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999,
    navbar: true,
    toolbar: true,
    button: true,
    title: false,
    url(image) {
      // 修改图片放大时的图片路径，这里_300是我缩略图和大图的区别
      return image.src.replace('_300', '')
    }
  }
})

import {
  getMenuId
} from '@/utils/menuName'
import * as filters from './filters' // global filters
import SuperFlow from 'vue-super-flow'
import 'vue-super-flow/lib/index.css'


import scroll from "vue-seamless-scroll"
import loadingTem from "@/components/loadingTem"
import load from '@/components/Loading'
import axios from 'axios'
import VueQr from "vue-qr"
Vue.component('vue-qr',VueQr)
Vue.prototype.$axios = axios;
Vue.component("loadingTem", loadingTem);
Vue.component('load', load)
Vue.use(SuperFlow)
Vue.use(scroll)
Vue.prototype.$getMenuId = getMenuId;
Vue.use(selectscroll);
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the development environment only,
 * it's disabled in production
 */
if (process.env.NODE_ENV === 'development') {
  const {
    mockXHR
  } = require('../mock')
  mockXHR()
}

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  locale: enLang // 如果使用中文，无需设置，请删除
})

// 重写message方法
Vue.prototype.$message = myMessage;

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false;

// 全局自定义指令
Vue.directive('selffocus', {
  inserted(el, binding) {
    el.querySelector('input').focus()
  }
})

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

//resize window rem
import resizeWindow from '@/utils/resizewindow.js';
resizeWindow(1920, 1920, 1200);
