main.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import Vue from 'vue'
  2. import 'normalize.css/normalize.css' // A modern alternative to CSS resets
  3. import ElementUI from 'element-ui'
  4. import 'element-ui/lib/theme-chalk/index.css'
  5. // import locale from 'element-ui/lib/locale/lang/en' // lang i18n
  6. import echarts from 'echarts'
  7. import '@/styles/index.scss' // global css
  8. import '@/customIcons/icon.css' // 自定义icon
  9. import App from './App.vue'
  10. import store from './store'
  11. import router from './router'
  12. import '@/icons' // icon
  13. import '@/permission' // permission control
  14. /**
  15. * If you don't want to use mock-server
  16. * you want to use MockJs for mock api
  17. * you can execute: mockXHR()
  18. *
  19. * Currently MockJs will be used in the production environment,
  20. * please remove it before going online ! ! !
  21. */
  22. Vue.prototype.$echarts = echarts
  23. // if (process.env.NODE_ENV === 'production') {
  24. // const { mockXHR } = require('../mock')
  25. // mockXHR()
  26. // }
  27. Vue.directive('tableHeight', {
  28. update(el, binding) {
  29. function changeElHeight() {
  30. let height = 0
  31. if (!binding.value) {
  32. const navbarHeight = 46
  33. const tabsHeight = 62
  34. const searchHeight = document.querySelector('.app-container>.filter-container') ? document.querySelector('.app-container>.filter-container').offsetHeight : 0
  35. const pageHeight = document.querySelector('.app-container>.pagination-container') ? 75 : 20
  36. const otherHeight = document.querySelector('.app-container>.other-container') ? document.querySelector('.app-container>.other-container').offsetHeight : 0
  37. height = navbarHeight + tabsHeight + searchHeight + pageHeight + otherHeight
  38. } else {
  39. height = binding.value
  40. }
  41. el.style.height = `${window.innerHeight - height > 230 ? window.innerHeight - height : 230}px`
  42. }
  43. changeElHeight()
  44. window.onresize = () => {
  45. changeElHeight()
  46. }
  47. }
  48. })
  49. // set ElementUI lang to EN
  50. // Vue.use(ElementUI, { locale })
  51. // 如果想要中文版 element-ui,按如下方式声明
  52. Vue.use(ElementUI)
  53. Vue.prototype.common = {
  54. seamingImgUrl(url) {
  55. if (!url) return ''
  56. // return url.startsWith('https://') ? url : 'https://www.tuanfengkeji.cn:9527/dts-admin-api/admin/storage/fetch/' + url
  57. if (url.startsWith('http://')) {
  58. return url.replace('http://', 'https://')
  59. } else if (url.startsWith('https://')) {
  60. return url
  61. } else if (url.startsWith('//')) {
  62. return 'https:' + url
  63. }
  64. // https://tuanfengkeji.oss-cn-beijing.aliyuncs.com/tfshop/
  65. // https://jufeng-shop-1317254189.cos.ap-guangzhou.myqcloud.com/
  66. return 'https://jufeng-shop-1317254189.cos.ap-guangzhou.myqcloud.com/' + url
  67. }
  68. }
  69. Vue.config.productionTip = false
  70. new Vue({
  71. el: '#app',
  72. router,
  73. store,
  74. render: (h) => h(App)
  75. })