main.js 2.3 KB
/*
 * @Descripttion:
 * @version:
 * @Author: limin
 * @Date: 2021-06-07 14:12:32
 * @LastEditors: limin
 * @LastEditTime: 2021-06-29 15:35:47
 */
// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
// import 'core-js/stable'
// import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import api from './api'
import { fetchConfig, cfg } from '@/config'
import { axsinit } from './plugins/axios'
import 'components'
import './filters'
import '@/assets/css/index.scss'
import { bus, tools, store as local } from './utils'
import { global } from '@/mixins'
// Vue.mixin(global)
// 全局引入按需引入UI库 vant
import { components } from '@/plugins/vant'
components.forEach(component => Vue.use(component))

Vue.prototype.api = api
Vue.prototype.bus = bus
Vue.prototype.tools = tools
Vue.prototype.local = local
Vue.prototype.to = function (name, params) {
  if (name === -1) {
    router.go(-1)
    return
  }
  router.push({ name, params})
}
// 移动端适配 rem
// import 'lib-flexible/flexible.js'

import 'vue-easytable/libs/theme-default/index.css'
import VueEasytable from 'vue-easytable'
Vue.use(VueEasytable)
Vue.config.productionTip = false
// import VConsole from 'vconsole'
// const vConsole = new VConsole()
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
Vue.use(preview, {
  maxSpreadZoom: 1, // 预览图最大的倍数,默认是2倍
  fullscreenEl: false, // 是否显示右上角全屏按钮
  tapToClose: true, // 点击滑动区域应关闭图库
  shareEl: false, // 是否显示分享按钮
  zoomEl: false, // 是否显示放大缩小按钮
  counterEl: false, // 是否显示左上角图片数量按钮
  arrowEl: true, // 如图的左右箭头(pc浏览器模拟手机时)
  tapToToggleControls: true, // 点击应切换控件的可见性
  clickToCloseNonZoomable: true // 点击图片应关闭图库,仅当图像小于视口的大小时
})
fetchConfig().then(({ request, cdn }) => {
  // 从配置服务器获取动态配置
  // 设置 js中可以访问 $cdn
  Vue.prototype.$cdn = cdn
  Vue.use(cfg)
  axsinit(request)
  new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
  })
})