Michael Wang преди 3 години
родител
ревизия
ac12af6a8f
променени са 2 файла, в които са добавени 9 реда и са изтрити 2 реда
  1. 7 2
      src/features/OnlineExam/StartExamModal.vue
  2. 2 0
      src/utils/encDec.ts

+ 7 - 2
src/features/OnlineExam/StartExamModal.vue

@@ -246,12 +246,17 @@ async function enterExam() {
         {
           "axios-retry": { retries: 4 },
           noErrorMessage: true,
-          headers: { timestamp, "Content-Type": "text/plain" },
+          headers: {
+            timestamp,
+            "Content-Type": "text/plain",
+            accept: "text/plain",
+          },
+          responseType: "text",
+          transitional: { forcedJSONParsing: false },
         }
       );
 
       res.data = doDec(res.data, key);
-      // console.log(res.data);
       const newRes: {
         courseName: string;
         examRecordDataId: number;

+ 2 - 0
src/utils/encDec.ts

@@ -53,6 +53,7 @@ function getDecMethod(code: string) {
 /** 对原始字符串进行加密 */
 export function doEnc(rawStr: string, key: string) {
   const salt = getSalt();
+  if (!salt) return rawStr;
 
   const methods = salt.split("");
 
@@ -68,6 +69,7 @@ export function doEnc(rawStr: string, key: string) {
 /** 对加密字符串进行依次解密 */
 export function doDec(rawStr: string, key: string) {
   const salt = getSalt();
+  if (!salt) return rawStr;
 
   const methods = salt.split("");