import Vue from 'vue'
// window.Vue = Vue
// loadJS('/cdn/libs/st-ui/st-ui.js')
import store from './store'
import router from './router'
import './directive'
// 核心文件
import App from './App'
import './components'
import '@/assets/less/component.less'
// import '@/assets/font/font.css'
import './assets/icon/iconfont.css'
import './assets/css/layout.css';
// vdr拖动缩放组件
import VueDraggableResizable from 'vue-draggable-resizable'
import 'vue-draggable-resizable/dist/VueDraggableResizable.css'
Vue.component('vue-draggable-resizable', VueDraggableResizable)
// script引入element use
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import "echarts";
import Chart from 'vue-echarts';
Vue.component('v-chart', Chart)
Vue.use(ElementUI, {
  size: 'small',
})
window.wsHost = (process.env.NODE_ENV==='development'?'10.102.1.181:9000':location.host)
// 暂时挂载到window 以支持项目之前的ELEMENT.Message写法
window.ELEMENT = ElementUI
// 事件总线
Vue.prototype.$EventBus = new Vue()
// 关闭生产模式的提示
Vue.config.productionTip = false

new Vue({
  el: '#app',
  store,
  router,
  render: (h) => h(App),
})
// 动态加载外部链接 使npm引入的vue 兼容原框架st-ui组件
function loadJS(url) {
  return new Promise((resolve) => {
    let script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;
    // IE
    if (script.readyState) {
      script.onreadystatechange = () => {
        if (script.readyState == 'loaded'
          || script.readyState == 'complete') {
          script.onreadystatechange = null;
          resolve();
        }
      };
    } else {
      // 其他浏览器
      script.onload = function () {
        resolve();
      };
    }
    document.getElementsByTagName('head')[0].appendChild(script);
  })
}
