刘洋 7 月之前
父节点
当前提交
393962dc78

+ 2 - 0
src/features/OnlineExam/Examing/TextQuestionView.vue

@@ -452,6 +452,7 @@ function photosReseted(urls: string[]) {
           </div>
         </div>
       </div>
+
       <div v-if="shouldFetchQrCode && isAudioAnswerType">
         <div>
           <div v-if="qrValue" style="display: flex">
@@ -507,6 +508,7 @@ function photosReseted(urls: string[]) {
           @onPhotosReseted="photosReseted"
         />
       </div>
+
       <div class="reset" style="padding-top: 20px">
         <span v-if="store.examShouldShowAnswer">
           <n-button type="success" @click="toggleShowAnswer">

+ 17 - 0
src/features/OnlineExam/Examing/UploadPhotos.vue

@@ -6,7 +6,17 @@ import Viewer from "viewerjs";
 import { watch } from "vue";
 import { store } from "@/store/store";
 import { Eye, TrashOutline, Checkmark } from "@vicons/ionicons5";
+import { useHandGetAnswer } from "./setups/useWXSocket";
+const { loading: handLoading, handler: handHandler } = useHandGetAnswer();
 
+const examQuestion = $computed(() => store.exam.currentQuestion);
+const examRecordDataId = store.exam.examRecordDataId;
+const handGetAnswer = () => {
+  handHandler({
+    examRecordDataId: examRecordDataId,
+    questionOrder: examQuestion.order,
+  });
+};
 const props = defineProps<{
   defaultList: string[];
   qrValue: string;
@@ -217,6 +227,13 @@ function prepareUpload() {
               {{ uploaded ? "已上传" : "已扫描" }}
               <n-icon :component="Checkmark" />
             </div>
+            <n-button
+              type="primary"
+              style="margin-top: 15px"
+              :loading="handLoading"
+              @click="handGetAnswer"
+              >手动同步小程序作答结果</n-button
+            >
           </div>
         </div>
         <div v-else>正在获取二维码...</div>

+ 57 - 1
src/features/OnlineExam/Examing/setups/useWXSocket.ts

@@ -1,7 +1,63 @@
 import { WEBSOCKET_FOR_AUDIO } from "@/constants/constants";
 import { useWebSocket } from "@/setups/useWebSocket";
 import { store } from "@/store/store";
-import { watch } from "vue";
+import { watch, ref } from "vue";
+import { httpApp } from "@/plugins/axiosApp";
+
+import { debounce, throttle } from "lodash-es";
+
+interface HandGetResult {
+  examRecordDataId: number;
+  questionOrder: number;
+  filePath: string;
+  status: "UNCONFIRMED" | "CONFIRMED" | "DISCARDED";
+  transferFileType: "PIC" | "AUDIO";
+}
+export const useHandGetAnswer = () => {
+  const loading = ref(false);
+  function handGetAnswer(data: {
+    examRecordDataId: number | string;
+    questionOrder: number | string;
+  }) {
+    loading.value = true;
+    httpApp
+      .post<any>(
+        `/api/ecs_oe_student/examControl/getUploadedFile?examRecordDataId=${data.examRecordDataId}&questionOrder=${data.questionOrder}`,
+        {},
+        {
+          setGlobalMask: true,
+        }
+      )
+      .then((res: { data: HandGetResult }) => {
+        console.log("手动获取小程序作答成功:", res);
+        store.setQuestionFileAnswerUrl({
+          order: res.data.questionOrder,
+          fileUrl: res.data.filePath,
+          transferFileType: res.data.transferFileType,
+        });
+
+        logger({
+          cnl: ["local", "server"],
+          pgn: "ExamRecordData",
+          dtl: "手动获取小程序作答成功",
+        });
+      })
+      .catch((err) => {
+        logger({
+          cnl: ["local", "server"],
+          pgn: "ExamRecordData",
+          dtl: "手动获取小程序作答失败",
+        });
+      })
+      .finally(() => {
+        loading.value = false;
+      });
+  }
+  return {
+    loading,
+    handler: throttle(handGetAnswer, 3000),
+  };
+};
 
 function onAudioAnswer(event: MessageEvent<string>) {
   let res: {

+ 3 - 9
src/features/UserLogin/UserLogin.vue

@@ -82,15 +82,9 @@ useExamShellStats();
 //#region cache faceapi json
 {
   const faceapiUrls = [
-    FACE_API_MODEL_PATH +
-      "tiny_face_detector_model-weights_manifest.json?v=" +
-      Date.now(),
-    FACE_API_MODEL_PATH +
-      "face_landmark_68_model-weights_manifest.json?v=" +
-      Date.now(),
-    FACE_API_MODEL_PATH +
-      "face_expression_model-weights_manifest.json?v=" +
-      Date.now(),
+    FACE_API_MODEL_PATH + "tiny_face_detector_model-weights_manifest.json",
+    FACE_API_MODEL_PATH + "face_landmark_68_model-weights_manifest.json",
+    FACE_API_MODEL_PATH + "face_expression_model-weights_manifest.json",
   ];
 
   for (const u of faceapiUrls) {

+ 1 - 0
src/plugins/axiosApp.ts

@@ -104,6 +104,7 @@ _axiosApp.interceptors.response.use(
     if (!error.response) {
       if (showErrorMessage && error?.message !== "canceled") {
         // "Network Error" 网络不通,直接返回
+        console.log("config", config);
         $message.error("网络连接异常,请检查网络设置。");
       }
       return Promise.reject(error);

+ 1 - 1
vite.config.ts

@@ -148,7 +148,7 @@ export default defineConfig({
         target: SERVER_URL,
         changeOrigin: true,
         secure: false,
-        ws: true,
+        ws: false,
       },
       "/admin": {
         target: SERVER_URL,