index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Element
  2. import ElementUI from 'element-ui'
  3. import 'element-ui/lib/theme-chalk/index.css'
  4. // A modern alternative to CSS resets
  5. import 'normalize.css/normalize.css'
  6. // flex 布局库
  7. import 'flex.css'
  8. // ibps平台字体库
  9. import '@/assets/fonts/iconfont.css'
  10. // :focus-visible https://github.com/WICG/focus-visible/blob/master/explainer.md
  11. import 'focus-visible'
  12. // Internationalization 国际化
  13. import i18n from '@/i18n'
  14. // store
  15. import store from '@/store'
  16. // 工具类
  17. import Utils from '@/utils/util'
  18. // 全局方法
  19. import common from '@/utils'
  20. // global filters 全局过滤
  21. import * as filters from '@/filters'
  22. // 拼音指令
  23. import pinyin from '@/directives/pinyin'
  24. // 置顶
  25. import sticky from '@/directives/sticky'
  26. // 加载更多
  27. import loadMore from '@/directives/load-more'
  28. import { getToken } from '@/utils/auth'
  29. // 通用组件
  30. import '@/components'
  31. // svg 图标
  32. import '@/assets/svg-icons'
  33. // 功能插件
  34. import pluginError from '@/plugins/error'
  35. import pluginLog from '@/plugins/log'
  36. import pluginOpen from '@/plugins/open'
  37. // 平台配置文件
  38. import setting from '@/setting.js'
  39. import env from '@/env'
  40. const BASE_URL = process.env.VUE_APP_BASE_URL
  41. export default {
  42. async install (Vue, options) {
  43. // 设置为 false 以阻止 vue 在启动时生成生产提示。
  44. // https://cn.vuejs.org/v2/api/#productionTip
  45. Vue.config.productionTip = false
  46. // 当前环境
  47. Vue.prototype.$nodeEnv = env.NODE_ENV
  48. // 当前环境变量
  49. Vue.prototype.$env = env
  50. // 当前的 baseUrl 简化代码中 env.VUE_APP_PUBLIC_PATH 取值
  51. Vue.prototype.$baseUrl = env.VUE_APP_PUBLIC_PATH || '/'
  52. // 构建时间
  53. Vue.prototype.$buildTime = env.VUE_APP_BUILD_TIME
  54. Vue.prototype.$ibpsUrl = env.VUE_APP_BASE_API_0_0_TEST
  55. const reportPath = '金通医学实验室管理系统'
  56. const downloadReport = (src, where, type = 6) => {
  57. // 目前可用type 6:生成报表的pdf文件【默认】 7:生成报表的word文件 3:生成报表的excel文件
  58. return `${BASE_URL}demo/reportServlet?action=${type}&file=${encodeURIComponent(reportPath + '/' + src)}&print=1&srcType=file&paramString=${encodeURIComponent(where)}`
  59. }
  60. const timer = setInterval(() => { // 定时循环添加参数
  61. if (getToken()) {
  62. // 报表路径
  63. Vue.prototype.$reportPath = `${BASE_URL}demo/reportJsp/showReport.jsp?access_token=${getToken()}&rpx=${reportPath}/`
  64. Vue.prototype.$getReportFile = downloadReport // 通过方法函数,拼接url,并将字符串格式化
  65. clearInterval(timer) // 添加成功后即删除定时任务
  66. }
  67. }, 500)
  68. // 获得用户设置的全局尺寸
  69. const size = await store.dispatch('ibps/db/get', {
  70. dbName: 'sys',
  71. path: 'size.value',
  72. defaultValue: setting.system.size,
  73. user: true
  74. })
  75. // 注册Element UI
  76. Vue.use(ElementUI, {
  77. size,
  78. i18n: (key, value) => i18n.t(key, value)
  79. })
  80. // 注册全局过滤器(register global utility filters. )
  81. Object.keys(filters).forEach(key => {
  82. Vue.filter(key, filters[key])
  83. })
  84. // 设置拼音指令
  85. Vue.directive('pinyin', pinyin)
  86. Vue.directive('sticky', sticky)
  87. Vue.directive('load-more', loadMore)
  88. // 插件
  89. Vue.use(pluginError)
  90. Vue.use(pluginLog)
  91. Vue.use(pluginOpen)
  92. // 使用帮助类
  93. Vue.prototype.$utils = Utils
  94. Vue.prototype.$common = common
  95. // 快速打印 log
  96. Vue.prototype.$log = Utils.log
  97. }
  98. }