Parcourir la source

1、登录切换前端配置

yfh il y a 3 semaines
Parent
commit
8a4bf2d781

+ 3 - 3
src/components/LiveVideoUpload/index.vue

@@ -65,7 +65,7 @@
 <script>
 import { uploadObject } from "@/utils/cos.js";
 import Pagination from "@/components/Pagination";
-
+import Vue from "vue";
 export default {
   components: {
     Pagination
@@ -214,9 +214,9 @@ export default {
         console.log("isPrivate=======>", this.isPrivate)
         let line_1 = '';
         if (this.isPrivate === 0) {
-          line_1 = `${ this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+          line_1 = `${ Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         } else {
-          line_1 = `${ this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+          line_1 = `${ Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         }
 
         let urlPathWithoutFirstSlash = data.urlPath.substring(1);

+ 5 - 5
src/components/LiveVideoUpload/single.vue

@@ -126,7 +126,7 @@ import Pagination from "@/components/Pagination";
 // import { listVideoResource } from '@/api/course/videoResource';
 import { listLiveVideo, getLiveVideo, delLiveVideo, addLiveVideo, updateLiveVideo, exportLiveVideo } from "@/api/live/liveVideo";
 import Hls from 'hls.js';
-
+import Vue from "vue";
 export default {
   components: {
     Pagination
@@ -344,9 +344,9 @@ export default {
         console.log("isPrivate=======>",this.isPrivate)
         let line_1='' ;
         if (this.isPrivate===0){
-          line_1 = `${ this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+          line_1 = `${ Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         }else {
-          line_1 = `${ this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+          line_1 = `${ Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         }
         line_1 = line_1.replace(/\.mp4$/, '.m3u8');
 
@@ -372,9 +372,9 @@ export default {
         console.log("华为OBS返回========>",data);
         let line_2='' ;
         if (this.isPrivate===0){
-          line_2 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
+          line_2 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
         }else {
-          line_2 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
+          line_2 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
         }
         // this.$emit("update:videoUrl", data);
         this.$emit("update:line_2", line_2);

+ 5 - 5
src/components/VideoUpload/index.vue

@@ -150,7 +150,7 @@ import { uploadToOBS } from "@/utils/obs.js";
 import Pagination from "@/components/Pagination";
 import { listVideoResource } from '@/api/course/videoResource';
 import { getCateListByPid, getCatePidList } from '@/api/course/userCourseCategory'
-
+import Vue from "vue";
 export default {
   components: {
     Pagination
@@ -335,9 +335,9 @@ export default {
         console.log("isPrivate=======>",this.isPrivate)
         let line_1='' ;
         if (this.isPrivate===0){
-          line_1 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+          line_1 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         }else {
-          line_1 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+          line_1 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         }
 
         let urlPathWithoutFirstSlash = data.urlPath.substring(1);
@@ -361,9 +361,9 @@ export default {
         console.log("华为OBS返回========>",data);
         let line_2='' ;
         if (this.isPrivate===0){
-          line_2 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
+          line_2 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
         }else {
-          line_2 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
+          line_2 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
         }
         // this.$emit("update:videoUrl", data);
         this.$emit("update:line_2", line_2);

+ 0 - 1
src/main.js

@@ -124,7 +124,6 @@ async function initRuntimeConfig() {
     Object.keys(mapping).forEach(key => {
       Vue.prototype.$runtimeConfig[key] = form[mapping[key]] ?? null
     })
-    console.log('runtimeConfig:', Vue.prototype.$runtimeConfig)
   } catch (e) {
     console.error('初始化运行时配置失败', e)
   }

+ 9 - 8
src/utils/cos.js

@@ -1,14 +1,15 @@
 import COS from "cos-js-sdk-v5"
 import { getTmpSecretKey } from "@/api/common"
+import Vue from "vue";
 
 console.log("环境变量:", process.env)
 console.log("NODE_ENV:", process.env.NODE_ENV)
-console.log("VUE_APP_COS_BUCKET:", process.env.VUE_APP_COS_BUCKET)
-console.log("VUE_APP_COS_REGION:", process.env.VUE_APP_COS_REGION)
+console.log("VUE_APP_COS_BUCKET:", Vue.prototype.$runtimeConfig.VUE_APP_COS_BUCKET)
+console.log("VUE_APP_COS_REGION:", Vue.prototype.$runtimeConfig.VUE_APP_COS_REGION)
 
 const config = {
-  Bucket: process.env.VUE_APP_COS_BUCKET,
-  Region: this.$runtimeConfig.VUE_APP_COS_REGION,
+  Bucket: Vue.prototype.$runtimeConfig.VUE_APP_COS_BUCKET,
+  Region: Vue.prototype.$runtimeConfig.VUE_APP_COS_REGION,
 }
 console.log("COS配置:", config)
 
@@ -50,11 +51,11 @@ export const uploadObject = async (file, onProgress, type, callBackUp) => {
     const videoKey = `/userVideo/${uploadDay}/${upload_file_name}`
     const courseKey = `/course/${uploadDay}/${upload_file_name}`
     let liveKey;
-    console.log("LIVE_PATH value:", this.$runtimeConfig.VUE_APP_LIVE_PATH);  // 添加这行查看实际值
-    console.log("Type of LIVE_PATH:", typeof this.$runtimeConfig.VUE_APP_LIVE_PATH);  // 查看类型
+    console.log("LIVE_PATH value:", Vue.prototype.$runtimeConfig.VUE_APP_LIVE_PATH);  // 添加这行查看实际值
+    console.log("Type of LIVE_PATH:", typeof Vue.prototype.$runtimeConfig.VUE_APP_LIVE_PATH);  // 查看类型
 // 检查是否是空字符串或只有空格
-    if (this.$runtimeConfig.VUE_APP_LIVE_PATH && this.$runtimeConfig.VUE_APP_LIVE_PATH.trim() !== '') {
-      liveKey = `${this.$runtimeConfig.VUE_APP_LIVE_PATH.trim()}/${uploadDay}/${upload_file_name}`;
+    if (Vue.prototype.$runtimeConfig.VUE_APP_LIVE_PATH && Vue.prototype.$runtimeConfig.VUE_APP_LIVE_PATH.trim() !== '') {
+      liveKey = `${Vue.prototype.$runtimeConfig.VUE_APP_LIVE_PATH.trim()}/${uploadDay}/${upload_file_name}`;
     } else {
       liveKey = `/course/${uploadDay}/${upload_file_name}`;
     }

+ 2 - 1
src/utils/hsy.js

@@ -1,6 +1,7 @@
 import TTUploader from 'tt-uploader'
+import Vue from "vue";
 import { HsyAssumeRoleService } from '@/api/course/userVideo'
-const  spaceName = this.$runtimeConfig.VUE_APP_HSY_SPACE
+const  spaceName = Vue.prototype.$runtimeConfig.VUE_APP_HSY_SPACE
 export const uploadToHSY = async (file, onProgress, type, callBackUp) => {
   try {
     const res = await HsyAssumeRoleService()

+ 5 - 5
src/utils/obs.js

@@ -1,11 +1,11 @@
 import ObsClient from "esdk-obs-browserjs/src/obs"
-
+import Vue from "vue";
 export const uploadToOBS = async (file, progressCallback, type, cancelCallback) => {
   try {
     const obsClient = new ObsClient({
-      access_key_id:  this.$runtimeConfig.VUE_APP_OBS_ACCESS_KEY_ID,
-      secret_access_key:  this.$runtimeConfig.VUE_APP_OBS_SECRET_ACCESS_KEY,
-      server:  this.$runtimeConfig.VUE_APP_OBS_SERVER,
+      access_key_id:  Vue.prototype.$runtimeConfig.VUE_APP_OBS_ACCESS_KEY_ID,
+      secret_access_key:  Vue.prototype.$runtimeConfig.VUE_APP_OBS_SECRET_ACCESS_KEY,
+      server:  Vue.prototype.$runtimeConfig.VUE_APP_OBS_SERVER,
       timeout: 1200,
     })
 
@@ -46,7 +46,7 @@ export const uploadToOBS = async (file, progressCallback, type, cancelCallback)
       })*/
       obsClient.putObject(
         {
-          Bucket: this.$runtimeConfig.VUE_APP_OBS_BUCKET,
+          Bucket: Vue.prototype.$runtimeConfig.VUE_APP_OBS_BUCKET,
           Key: key,
           Body: file,
           ProgressCallback: callback,

+ 2 - 1
src/views/components/his/followMsgDetails.vue

@@ -173,7 +173,7 @@
         <el-descriptions-item label="问诊备注"><span v-if="reportItem!=null">{{reportItem.companyUserRemark}}</span></el-descriptions-item>
       </el-descriptions>
       <div class="desct">
-        ${this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}
+        ${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}
       </div>
       <el-descriptions :column="3" border  >
         <el-descriptions-item label="患者姓名" ><span v-if="reportItem.patientJson!=null">{{JSON.parse(reportItem.patientJson).patientName}}</span></el-descriptions-item>
@@ -252,6 +252,7 @@
 </template>
 
 <script>
+import Vue from "vue";
 import { getDrugReport} from "@/api/his/drugReport";
 import { getPatientMobile,getInquiryOrderReportByOrderId} from "@/api/his/inquiryOrderReport";
 import {msgList,getMsgFollow} from "@/api/his/storeOrder";

+ 3 - 2
src/views/components/index/statisticsDashboard.vue

@@ -576,6 +576,7 @@ import {
   watchCourseTopTen, watchEndPlayTrend,getWatchCourseStatisticsData
 } from "@/api/statistics/statistics";
 import dayjs from 'dayjs';
+import Vue from "vue";
 import { listDept } from '@/api/system/dept'
 import { listCompany } from '@/api/his/company'
 
@@ -985,8 +986,8 @@ export default {
       viewerType: '0',
       viewerChart: null,
       dealerChartNew: null,
-      userTypeText: this.$runtimeConfig.VUE_APP_COURSE_DEFAULT==1?"会员":"企微",
-      userType: this.$runtimeConfig.VUE_APP_COURSE_DEFAULT,
+      userTypeText: Vue.prototype.$runtimeConfig.VUE_APP_COURSE_DEFAULT==1?"会员":"企微",
+      userType: Vue.prototype.$runtimeConfig.VUE_APP_COURSE_DEFAULT,
       dealerChart: null,
       // 分公司数量
       dealderCount: 0,

+ 1 - 2
src/views/course/courseWatchLog/index.vue

@@ -665,7 +665,6 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import {getCompanyList} from "../../../api/company/company";
 import {treeselectByCompanyId} from "../../../api/company/companyDept";
 Vue.use(Calendar)
-
 export default {
   name: "CourseWatchLog",
   components: {Treeselect },
@@ -842,7 +841,7 @@ export default {
         periodETime:null,
         scheduleStartTime: null,
         scheduleEndTime: null,
-        sendType:this.$runtimeConfig.VUE_APP_COURSE_DEFAULT,
+        sendType:Vue.prototype.$runtimeConfig.VUE_APP_COURSE_DEFAULT,
         isVip: null,
         sopId: null, // sopId
         watchType:null,

+ 6 - 5
src/views/course/videoResource/index.vue

@@ -781,6 +781,7 @@
 </template>
 
 <script>
+import Vue from "vue";
 import {
   addVideoResource,
   deleteVideoResource,
@@ -1377,7 +1378,7 @@ export default {
           }
         });
 
-        let line_1 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+        let line_1 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         form.fileKey = data.urlPath.substring(1);
         form.videoUrl = line_1;
         form.line1 = line_1;
@@ -1474,9 +1475,9 @@ export default {
         );
         console.log("上传火山云返回参数",data)
 
-        form.line2 = `${this.$runtimeConfig.VUE_APP_VIDEO_URL}/${data.SourceInfo.FileName}`;
+        form.line2 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_URL}/${data.SourceInfo.FileName}`;
         this.form.hsyVid = data.Vid
-        this.form.hsyVodUrl = this.$runtimeConfig.VUE_APP_VIDEO_URL+"/"+data.SourceInfo.FileName
+        this.form.hsyVodUrl = Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_URL+"/"+data.SourceInfo.FileName
         console.log("this.form",this.form)
         this.$message.success('线路二上传成功');
         return { success: true, url: form.line2 };
@@ -2272,7 +2273,7 @@ export default {
           this.uploadCancellationTokens.set(tempVideo.tempId, tokens);
         });
 
-        let line_1 = `${this.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+        let line_1 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         tempVideo.fileKey = data.urlPath.substring(1);
         tempVideo.videoUrl = line_1;
         tempVideo.line1 = line_1;
@@ -2320,7 +2321,7 @@ export default {
           this.uploadCancellationTokens.set(tempVideo.tempId, tokens);
         });
         console.log("批量上传返回参数",data)
-        tempVideo.line2 = `${this.$runtimeConfig.VUE_APP_VIDEO_URL}/${data.SourceInfo.FileName}`;
+        tempVideo.line2 = `${Vue.prototype.$runtimeConfig.VUE_APP_VIDEO_URL}/${data.SourceInfo.FileName}`;
         tempVideo.hsyVid = data.Vid;
 
         return { success: true, url: tempVideo.line2};

+ 2 - 2
src/views/live/liveConfig/index.vue

@@ -111,7 +111,7 @@ import Preview from './preview.vue'
 import LiveCoupon from './liveCoupon.vue'
 import Barrage from './barrage.vue'
 import { listLive, getLive, delLive, addLive, updateLive, exportLive,selectCompanyTalent,handleShelfOrUn,handleDeleteSelected } from "@/api/live/live";
-
+import Vue from "vue";
 
 export default {
   name: 'LiveConfig',
@@ -135,7 +135,7 @@ export default {
       liveInfo: {},
       socket:null,
       currentComponent: WatchReward,
-      liveWsUrl: this.$runtimeConfig.VUE_APP_LIVE_WS_URL + '/app/webSocket',
+      liveWsUrl: Vue.prototype.$runtimeConfig.VUE_APP_LIVE_WS_URL + '/app/webSocket',
       menuList:[
         { name: '观看奖励', label: '观看奖励', index: 'watchReward'},
         { name: '直播预告', label: '直播预告', index: 'preview'},

+ 2 - 2
src/views/live/liveConsole/LiveConsole.vue

@@ -268,7 +268,7 @@ import { listLiveSingleMsg,delLiveMsg } from '@/api/live/liveMsg'
 import { getLive } from '@/api/live/live'
 import { consoleList } from '@/api/live/task'
 import ScreenScale from './ScreenScale.vue'; // 路径根据实际位置调整
-
+import Vue from "vue";
 
 export default {
   components: {
@@ -348,7 +348,7 @@ export default {
         hasPrev: false
       },
       loadMsgMaxPage: 2,
-      liveWsUrl: this.$runtimeConfig.VUE_APP_LIVE_WS_URL + '/app/webSocket',
+      liveWsUrl: Vue.prototype.$runtimeConfig.VUE_APP_LIVE_WS_URL + '/app/webSocket',
       alDisplayList: [],
       onlineDisplayList: [],    // 在线用户显示列表
       offlineDisplayList: [],   // 离线用户显示列表

+ 2 - 2
src/views/live/liveConsole/index-backup.vue

@@ -270,7 +270,7 @@ import LiveRedConf from '@/views/live/liveConfig/liveRedConf.vue'
 import LiveGoods from '@/views/live/liveConfig/goods.vue'
 import LiveLiveCoupon from '@/views/live/liveConfig/liveCoupon.vue'
 import echarts from 'echarts'
-
+import Vue from "vue";
 export default {
   name: "LiveConsole",
   components: { LiveLotteryConf,LiveRedConf },
@@ -288,7 +288,7 @@ export default {
       status: 0,
       loadMsgMaxPage: 2,
       liveVideo: {},
-      liveWsUrl: this.$runtimeConfig.VUE_APP_LIVE_WS_URL + '/app/webSocket',
+      liveWsUrl: Vue.prototype.$runtimeConfig.VUE_APP_LIVE_WS_URL + '/app/webSocket',
       userParams:{
         pageNum: 1,
         pageSize: 10,

+ 39 - 1
src/views/login.vue

@@ -94,7 +94,8 @@ import Cookies from "js-cookie";
 import { encrypt, decrypt } from '@/utils/jsencrypt'
 import WechatLoginDialog from "@/views/WechatLoginDialog.vue";
 import { setToken } from "@/utils/auth";
-
+import {getConfigByKey} from "@/api/system/config";
+import Vue from 'vue'
 export default {
   name: "Login",
   components: { WechatLoginDialog },
@@ -154,7 +155,42 @@ export default {
     this.getCookie();
   },
   methods: {
+// 重新加载运行时配置
+    async reloadRuntimeConfig() {
+
+      try {
+        const res = await getConfigByKey('his.adminUi.config')
+
+        const configValue = res?.data?.configValue
+        if (!configValue) return
+
+        // 后端配置 JSON
+        const form = JSON.parse(configValue)
+
+        // 直接更新全局配置
+        const config = {
+          VUE_APP_OBS_ACCESS_KEY_ID: form.obsAccessKeyId || '',
+          VUE_APP_OBS_SECRET_ACCESS_KEY: form.obsSecretAccessKey || '',
+          VUE_APP_OBS_SERVER: form.obsServer || '',
+          VUE_APP_OBS_BUCKET: form.obsBucket || '',
+          VUE_APP_VIDEO_LINE_1: form.videoLinePrimary || '',
+          VUE_APP_VIDEO_LINE_2: form.videoLineSecondary || '',
+          VUE_APP_VIDEO_URL: form.volcanoVideoDomain || '',
+          VUE_APP_HSY_SPACE: form.volcanoVodSpace || '',
+          VUE_APP_LIVE_PATH: form.livePath || '/live',
+          VUE_APP_COS_BUCKET: form.cosBucket || '',
+          VUE_APP_LIVE_WS_URL: form.liveWebSocketUrl || '',
+          VUE_APP_COURSE_DEFAULT: form.courseDefaultType || '1',
+          VUE_APP_COS_REGION: form.cosRegion || ''
+        }
+
+        // 更新到全局
+        Vue.prototype.$runtimeConfig = config
 
+      } catch (error) {
+        console.error('重新加载运行时配置异常:', error)
+      }
+    },
     getCode() {
       getCodeImg().then(res => {
         this.codeUrl = "data:image/gif;base64," + res.img;
@@ -201,6 +237,8 @@ export default {
               } else {
                 this.$router.push({ path: this.redirect || "/" });
               }
+              this.reloadRuntimeConfig()
+
             })
             .catch(() => {
               this.loading = false;