Browse Source

环境检测websocket地址替换

Michael Wang 3 năm trước cách đây
mục cha
commit
4848946d99
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      src/features/OnlineExam/CheckComputer.vue

+ 8 - 2
src/features/OnlineExam/CheckComputer.vue

@@ -116,7 +116,7 @@ store.exam.WEIXIN_ANSWER_ENABLED = true;
 useWXSocket();
 onMounted(async () => {
   const examRecordDataId = store.user.id;
-  const response = await httpApp.post(
+  const response = await httpApp.post<string>(
     "/api/ecs_oe_student/examControl/getQrCode",
     {
       examRecordDataId,
@@ -125,7 +125,13 @@ onMounted(async () => {
       testEnv: true,
     }
   );
-  wechat.qrValue = response.data;
+  let origin = window.location.origin;
+  if (import.meta.env.DEV) {
+    origin = import.meta.env.VITE_CONFIG_API_SERVER as string;
+  }
+  const toReplaceOrigin = new URL(response.data).origin;
+
+  wechat.qrValue = response.data.replace(toReplaceOrigin, origin);
   const trueExamRecordDataId = decodeURIComponent(wechat.qrValue).match(
     /&examRecordDataId=(\d+)/
   )![1];