index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/common'
  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 { BASE_URL, BASE_SEAL_API, REPORT_PATH, INTRANET_URL } from '@/constant'
  40. import env from '@/env'
  41. import { BASE_API, SYSTEM_URL } from '@/api/baseUrl'
  42. export default {
  43. async install (Vue, options) {
  44. // 设置为 false 以阻止 vue 在启动时生成生产提示。
  45. // https://cn.vuejs.org/v2/api/#productionTip
  46. Vue.config.productionTip = false
  47. // 当前环境
  48. Vue.prototype.$nodeEnv = env.NODE_ENV
  49. // 当前环境变量
  50. Vue.prototype.$env = env
  51. // onlyofficeUrl,开发环境使用当前环境api,生产环境固定使用INTRANET_URL
  52. Vue.prototype.$onlyofficeApi = env.NODE_ENV === 'development' ? BASE_API() : `${INTRANET_URL}ibps` + SYSTEM_URL()
  53. // 当前的 baseUrl 简化代码中 env.VUE_APP_PUBLIC_PATH 取值
  54. Vue.prototype.$baseUrl = env.VUE_APP_PUBLIC_PATH || '/'
  55. // 构建时间
  56. Vue.prototype.$buildTime = env.VUE_APP_BUILD_TIME
  57. Vue.prototype.$ibpsUrl = env.VUE_APP_BASE_API_0_0_TEST
  58. Vue.prototype.$reportFilePath = REPORT_PATH
  59. // 格式化参数
  60. const getParams = (params) => {
  61. const parts = params.split('&')
  62. const result = []
  63. parts.forEach((item, index) => {
  64. const [key, value] = item.split('=')
  65. // 第一个参数转换=为%3D,后续参数不转换=
  66. if (index === 0) {
  67. result.push(`${key}%3D${encodeURIComponent(value)}`)
  68. } else {
  69. result.push(`${key}=${encodeURIComponent(value)}`)
  70. }
  71. })
  72. return result.join('&')
  73. }
  74. const downloadReport = (src, where, type = 6) => {
  75. // 目前可用type 6:生成报表的pdf文件【默认】 7:生成报表的word文件 3:生成报表的excel文件
  76. return `${BASE_URL}demo/reportServlet?action=${type}&file=${encodeURIComponent(src)}.rpx&print=1&srcType=file&paramString=${getParams(where)}`
  77. }
  78. const timer = setInterval(() => { // 定时循环添加参数
  79. if (getToken()) {
  80. // 报表路径
  81. console.log('报表路径')
  82. Vue.prototype.$reportPath = `${BASE_URL}demo/reportJsp/showReport.jsp?access_token=${getToken()}&rpx=${REPORT_PATH}/`
  83. Vue.prototype.$getReportFile = downloadReport // 通过方法函数,拼接url,并将字符串格式化
  84. Vue.prototype.$getSealUri = `${BASE_SEAL_API}no/getSealFile/` // 微签 回显获取文件地址
  85. Vue.prototype.$getFileDow = `${BASE_URL}ibps/platform/v3/file/download?attachmentId=` // 文件下载地址
  86. clearInterval(timer) // 添加成功后即删除定时任务
  87. }
  88. }, 500)
  89. // 获得用户设置的全局尺寸
  90. const size = await store.dispatch('ibps/db/get', {
  91. dbName: 'sys',
  92. path: 'size.value',
  93. defaultValue: setting.system.size,
  94. user: true
  95. })
  96. // 注册Element UI
  97. Vue.use(ElementUI, {
  98. size,
  99. i18n: (key, value) => i18n.t(key, value)
  100. })
  101. // 注册全局过滤器(register global utility filters. )
  102. Object.keys(filters).forEach(key => {
  103. Vue.filter(key, filters[key])
  104. })
  105. // 设置拼音指令
  106. Vue.directive('pinyin', pinyin)
  107. Vue.directive('sticky', sticky)
  108. Vue.directive('load-more', loadMore)
  109. // 插件
  110. Vue.use(pluginError)
  111. Vue.use(pluginLog)
  112. Vue.use(pluginOpen)
  113. // 使用帮助类
  114. Vue.prototype.$utils = Utils
  115. Vue.prototype.$common = common
  116. // 快速打印 log
  117. Vue.prototype.$log = Utils.log
  118. }
  119. }