main.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 '@/styles/index.scss' // global css
  7. import '@/customIcons/icon.css' // 自定义icon
  8. import App from './App'
  9. import store from './store'
  10. import router from './router'
  11. import '@/icons' // icon
  12. import '@/permission' // permission control
  13. // if (process.env.NODE_ENV === 'production') {
  14. // const { mockXHR } = require('../mock')
  15. // mockXHR()
  16. // }
  17. Vue.directive('tableHeight', {
  18. update(el, binding) {
  19. function changeElHeight() {
  20. let height = 0
  21. if (!binding.value) {
  22. const navbarHeight = 46
  23. const tabsHeight = 62
  24. const searchHeight = document.querySelector('.app-container>.filter-container') ? document.querySelector('.app-container>.filter-container').offsetHeight : 0
  25. const pageHeight = document.querySelector('.app-container>.pagination-container') ? 75 : 20
  26. const otherHeight = document.querySelector('.app-container>.other-container') ? document.querySelector('.app-container>.other-container').offsetHeight : 0
  27. height = navbarHeight + tabsHeight + searchHeight + pageHeight + otherHeight
  28. } else {
  29. height = binding.value
  30. }
  31. el.style.height = `${window.innerHeight - height > 230 ? window.innerHeight - height : 230}px`
  32. }
  33. changeElHeight()
  34. window.onresize = () => {
  35. changeElHeight()
  36. }
  37. }
  38. })
  39. // set ElementUI lang to EN
  40. // Vue.use(ElementUI, { locale })
  41. // 如果想要中文版 element-ui,按如下方式声明
  42. Vue.use(ElementUI)
  43. Vue.prototype.common = {
  44. seamingImgUrl(url) {
  45. if (!url) return ''
  46. // return url.startsWith('https://') ? url : 'https://www.tuanfengkeji.cn:9527/dts-admin-api/admin/storage/fetch/' + url
  47. if (url.startsWith('http://')) {
  48. return url.replace('http://', 'https://')
  49. } else if (url.startsWith('https://')) {
  50. return url
  51. } else if (url.startsWith('//')) {
  52. return 'https:' + url
  53. }
  54. // https://tuanfengkeji.oss-cn-beijing.aliyuncs.com/tfshop/
  55. // https://jufeng-shop-1317254189.cos.ap-guangzhou.myqcloud.com/
  56. return 'https://jufeng-shop-1317254189.cos.ap-guangzhou.myqcloud.com/' + url
  57. }
  58. }
  59. Vue.config.productionTip = false
  60. new Vue({
  61. el: '#app',
  62. router,
  63. store,
  64. render: (h) => h(App)
  65. })