main.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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/common.scss'
  7. import App from './App'
  8. import store from './store'
  9. import router from './router'
  10. import directive from './directive' //directive
  11. import elementDirective from './directive/select'
  12. import './assets/icons' // icon
  13. import './permission' // permission control
  14. import { getDicts } from "@/api/system/dict/data";
  15. import { getConfigKey } from "@/api/system/config";
  16. import {cloneObject, parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/common";
  17. import Pagination from "@/components/Pagination";
  18. // 自定义表格工具组件
  19. import RightToolbar from "@/components/RightToolbar"
  20. // 富文本组件
  21. import Editor from "@/components/Editor"
  22. // 文件上传组件
  23. import FileUpload from "@/components/FileUpload"
  24. // 图片上传组件
  25. import ImageUpload from "@/components/ImageUpload"
  26. // 字典标签组件
  27. import DictTag from '@/components/DictTag'
  28. // 头部标签组件
  29. import VueMeta from 'vue-meta'
  30. import * as echarts from "echarts";
  31. import { getConfigByKey } from '@/api/system/config'
  32. import moment from 'moment'
  33. Vue.prototype.$moment = moment
  34. Vue.prototype.$runtimeConfig = {}
  35. // 全局方法挂载
  36. import { VueJsonp } from 'vue-jsonp'
  37. Vue.use(VueJsonp)
  38. // 全局配置
  39. Vue.prototype.logImg = require(process.env.VUE_APP_LOG_URL)
  40. Vue.prototype.cloneObject = cloneObject
  41. Vue.prototype.getDicts = getDicts
  42. Vue.prototype.getConfigKey = getConfigKey
  43. Vue.prototype.parseTime = parseTime
  44. Vue.prototype.resetForm = resetForm
  45. Vue.prototype.addDateRange = addDateRange
  46. Vue.prototype.selectDictLabel = selectDictLabel
  47. Vue.prototype.selectDictLabels = selectDictLabels
  48. Vue.prototype.download = download
  49. Vue.prototype.handleTree = handleTree
  50. Vue.prototype.echarts = echarts
  51. Vue.prototype.msgSuccess = function (msg) {
  52. this.$message({ showClose: true, message: msg, type: "success" });
  53. }
  54. Vue.prototype.msgError = function (msg) {
  55. this.$message({ showClose: true, message: msg, type: "error" });
  56. }
  57. Vue.prototype.msgInfo = function (msg) {
  58. this.$message.info(msg);
  59. }
  60. // 全局组件挂载
  61. Vue.component('DictTag', DictTag)
  62. Vue.component('Pagination', Pagination)
  63. Vue.component('RightToolbar', RightToolbar)
  64. Vue.component('Editor', Editor)
  65. Vue.component('FileUpload', FileUpload)
  66. Vue.component('ImageUpload', ImageUpload)
  67. import H5Editor from "@/components/H5Editor";
  68. Vue.component('H5Editor', H5Editor)
  69. Vue.use(directive)
  70. Vue.use(VueMeta)
  71. Vue.use(elementDirective)
  72. /**
  73. * If you don't want to use mock-server
  74. * you want to use MockJs for mock api
  75. * you can execute: mockXHR()
  76. *
  77. * Currently MockJs will be used in the production environment,
  78. * please remove it before going online! ! !
  79. */
  80. Vue.use(Element, {
  81. size: Cookies.get('size') || 'medium' // set element-ui default size
  82. })
  83. Vue.config.productionTip = false
  84. async function initRuntimeConfig() {
  85. try {
  86. const res = await getConfigByKey('his.adminUi.config')
  87. const configValue = res?.data?.configValue
  88. if (!configValue) return
  89. // 后端配置 JSON
  90. const form = JSON.parse(configValue)
  91. // 字段映射表(核心优化点)
  92. const mapping = {
  93. VUE_APP_OBS_ACCESS_KEY_ID: 'obsAccessKeyId',
  94. VUE_APP_OBS_SECRET_ACCESS_KEY: 'obsSecretAccessKey',
  95. VUE_APP_OBS_SERVER: 'obsServer',
  96. VUE_APP_OBS_BUCKET: 'obsBucket',
  97. VUE_APP_VIDEO_LINE_1: 'videoLinePrimary',
  98. VUE_APP_VIDEO_LINE_2: 'videoLineSecondary',
  99. VUE_APP_VIDEO_URL: 'volcanoVideoDomain',
  100. VUE_APP_HSY_SPACE: 'volcanoVodSpace',
  101. VUE_APP_LIVE_PATH: 'livePath',
  102. VUE_APP_COS_BUCKET: 'cosBucket',
  103. VUE_APP_LIVE_WS_URL: 'liveWebSocketUrl',
  104. VUE_APP_COURSE_DEFAULT: 'courseDefaultType',
  105. VUE_APP_COS_REGION: 'cosRegion'
  106. }
  107. // 写入运行时配置
  108. Object.keys(mapping).forEach(key => {
  109. Vue.prototype.$runtimeConfig[key] = form[mapping[key]] ?? null
  110. })
  111. } catch (e) {
  112. console.error('初始化运行时配置失败', e)
  113. }
  114. }
  115. async function bootstrap() {
  116. // await initRuntimeConfig()
  117. new Vue({
  118. el: '#app',
  119. router,
  120. store,
  121. render: h => h(App)
  122. })
  123. }
  124. bootstrap()