main.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import Vue from 'vue'
  2. import Cookies from 'js-cookie'
  3. import Element from 'element-ui'
  4. import './assets/styles/element-variables.scss'
  5. import '@/assets/styles/index.scss' // global css
  6. import '@/assets/styles/yongtian.scss' // yongtian css
  7. import App from './App'
  8. import store from './store'
  9. import router from './router'
  10. import directive from './directive' //directive
  11. import Print from '@/assets/js/print.js' // 引入附件的js文件
  12. Vue.use(Print) // 注册
  13. import './assets/icons' // icon
  14. import './permission' // permission control
  15. import { getDicts } from "@/api/system/dict/data";
  16. import { getConfigKey } from "@/api/system/config";
  17. import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, downloadBlob, handleTree } from "@/utils/yongtian";
  18. import Pagination from "@/components/Pagination";
  19. // 自定义表格工具组件
  20. import RightToolbar from "@/components/RightToolbar"
  21. // 富文本组件
  22. import Editor from "@/components/Editor"
  23. // 文件上传组件
  24. import FileUpload from "@/components/FileUpload"
  25. // 图片上传组件
  26. import ImageUpload from "@/components/ImageUpload"
  27. // 字典标签组件
  28. import DictTag from '@/components/DictTag'
  29. // 头部标签组件
  30. import VueMeta from 'vue-meta'
  31. // echarts
  32. import echarts from 'echarts'
  33. import {set } from 'nprogress'
  34. //公共变量
  35. // import { BASEPATH } from "@/assets/js/common.js";
  36. //创建自定义指令
  37. Vue.directive('down', {
  38. inserted: (el, binding) => {
  39. el.style.cssText = 'cursor: pointer;color:#46a6ff;'
  40. // setTimeout(() => {
  41. el.addEventListener('click', () => {
  42. let link = document.createElement('a')
  43. let url = binding.value
  44. // 这里是将url转成blob地址,
  45. fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
  46. link.href = URL.createObjectURL(blob)
  47. link.download = ''
  48. document.body.appendChild(link)
  49. link.click()
  50. })
  51. })
  52. // }, 500)
  53. }
  54. })
  55. // 全局方法挂载
  56. Vue.prototype.getDicts = getDicts
  57. Vue.prototype.getConfigKey = getConfigKey
  58. Vue.prototype.parseTime = parseTime
  59. Vue.prototype.resetForm = resetForm
  60. Vue.prototype.addDateRange = addDateRange
  61. Vue.prototype.selectDictLabel = selectDictLabel
  62. Vue.prototype.selectDictLabels = selectDictLabels
  63. Vue.prototype.download = download
  64. Vue.prototype.downloadBlob = downloadBlob
  65. Vue.prototype.handleTree = handleTree
  66. Vue.prototype.$echarts = echarts
  67. // Vue.prototype.BASEPATH = BASEPATH
  68. Vue.prototype.msgSuccess = function(msg, time) {
  69. this.$message({ showClose: true, message: msg, type: "success", duration: time || 3000 });
  70. }
  71. Vue.prototype.msgError = function(msg) {
  72. this.$message({ showClose: true, message: msg, type: "error" });
  73. }
  74. Vue.prototype.msgInfo = function(msg) {
  75. this.$message.info(msg);
  76. }
  77. // 全局组件挂载
  78. Vue.component('DictTag', DictTag)
  79. Vue.component('Pagination', Pagination)
  80. Vue.component('RightToolbar', RightToolbar)
  81. Vue.component('Editor', Editor)
  82. Vue.component('FileUpload', FileUpload)
  83. Vue.component('ImageUpload', ImageUpload)
  84. Vue.use(directive)
  85. Vue.use(VueMeta)
  86. /**
  87. * If you don't want to use mock-server
  88. * you want to use MockJs for mock api
  89. * you can execute: mockXHR()
  90. *
  91. * Currently MockJs will be used in the production environment,
  92. * please remove it before going online! ! !
  93. */
  94. Vue.use(Element, {
  95. size: Cookies.get('size') || 'medium' // set element-ui default size
  96. })
  97. Vue.config.productionTip = false
  98. new Vue({
  99. el: '#app',
  100. router,
  101. store,
  102. render: h => h(App)
  103. })