import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import './assets/common.less'

import dataV from '@jiaminghi/data-view'
import scroll from 'vue-seamless-scroll'
import api from './api'

Vue.config.productionTip = false
Vue.prototype.$api = api
Vue.use(ElementUI)
function resizeFont() {
  const designWidth = 1920; // 设计稿宽度，例如iPhone 6的宽度
  const maxWidth = 1920; // 最大支持宽度
  const screenWidth = Math.min(window.innerWidth, maxWidth);
  const scale = screenWidth / designWidth;
  document.documentElement.style.fontSize = `${100 * scale}px`;
}
// 初始调用
resizeFont();
// 监听窗口大小变化
window.addEventListener('resize', resizeFont);
let fontSize = function (res) {
  let clientWidth =
    window.innerWidth ||
    document.documentElement.clientWidth ||
    document.body.clientWidth;
  if (!clientWidth) return;
  let fontSize = 100 * (clientWidth / 1920);
  return res * fontSize;
}
Vue.prototype.$fontSize = fontSize
Vue.use(dataV)
Vue.use(scroll)
Vue.use(scroll, { componentName: 'scroll-seamless' })
new Vue({
  render: h => h(App)
}).$mount('#app')
