main.js 3.8 KB

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