Browse Source

1、调整登录更改配置

yfh 3 tuần trước cách đây
mục cha
commit
a0c9350a88
1 tập tin đã thay đổi với 28 bổ sung0 xóa
  1. 28 0
      src/views/login.vue

+ 28 - 0
src/views/login.vue

@@ -96,6 +96,9 @@ import { encrypt, decrypt } from '@/utils/jsencrypt'
 import { getFirstLogin } from "@/api/login";
 import WechatLoginDialog from "@/views/WechatLoginDialog";
 import { setToken } from "@/utils/auth";
+import {getConfigByKey} from "@/api/system/config";
+import Vue from 'vue'
+
 export default {
   name: "Login",
   components: { WechatLoginDialog  },
@@ -152,6 +155,30 @@ 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_LIVE_WS_URL: form.liveWebSocketUrl || '',
+          VUE_APP_COURSE_DEFAULT: form.courseDefaultType || '1',
+        }
+        // 更新到全局
+        Vue.prototype.$runtimeConfig = config
+
+      } catch (error) {
+        console.error('重新加载运行时配置异常:', error)
+      }
+    },
     checkFirstLogin() {
       getFirstLogin().then(res => {
         if (res.code === 200 && res.data) {
@@ -228,6 +255,7 @@ export default {
                 this.checkFirstLogin();
               }
             })
+          this.reloadRuntimeConfig()
             .catch(res => {
               console.log("登录失败")
               console.log(res)