main.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import '@/assets/iconfont/iconfont.css'
  4. // element引入
  5. import Element from 'element-ui'
  6. import 'element-ui/lib/theme-chalk/index.css'
  7. // sdk引入
  8. import sdk from '@ct/iframe-connect-sdk'
  9. import router from './router'
  10. import store from './store'
  11. import EasyPlayer from '@/utils/EasyPlayer-component.min.js'
  12. import { pxToRemMixin } from './pxToRem.js'
  13. Vue.mixin(pxToRemMixin)
  14. Vue.config.productionTip = false
  15. // 挂载请求sdk
  16. const { iframeSDK, requestSDK, postMsgUtil } = sdk
  17. Vue.prototype.$iframeSDK = iframeSDK
  18. Vue.prototype.$requestSDK = requestSDK
  19. Vue.prototype.$postMsgUtil = postMsgUtil
  20. Vue.use(Element, { size: 'small' })
  21. Vue.component('EasyPlayer', EasyPlayer)
  22. Vue.prototype.isCross = true
  23. localStorage.setItem('isCross', true)
  24. postMsgUtil.listen('checkCrossResult', function ({ data }) {
  25. Vue.prototype.isCross = data !== 200
  26. localStorage.setItem('isCross', data !== 200)
  27. })
  28. const setRootFontSize = (direction = 'v') => {
  29. const htmlElement = document.documentElement
  30. const baseHeight = direction === 'v' ? 1080 : 1920
  31. const referenceHeight = 1032
  32. htmlElement.style.fontSize = direction === 'v' ? `calc((100vh / ${baseHeight}) * 100 * (${baseHeight} / ${referenceHeight}))` : `calc((100vw / ${baseHeight}) * 100)`
  33. }
  34. setRootFontSize('v')
  35. new Vue({
  36. router,
  37. store,
  38. beforeCreate() {
  39. Vue.prototype.$globalEventBus = this
  40. },
  41. render: (h) => h(App)
  42. }).$mount('#app')