Browse Source

补充SLS错误日志

Michael Wang 5 years ago
parent
commit
730fe28bb9
2 changed files with 17 additions and 1 deletions
  1. 1 1
      src/features/OnlineExam/Examing/ExamingHome.vue
  2. 16 0
      src/utils/nativeExe.js

+ 1 - 1
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -874,7 +874,7 @@ export default {
               (this.__submitPaperEndTime - this.__submitPaperStartTime) / 1000
             ).toPrecision(1) + "秒",
           ]);
-          this.logger({ action: "交卷成功" });
+          this.logger({ action: "交卷成功", UA: navigator.userAgent });
           return;
         } else {
           this.$Message.error({

+ 16 - 0
src/utils/nativeExe.js

@@ -1,3 +1,5 @@
+import { createLog } from "@/utils/logger";
+
 export default function async(exeName, cb) {
   if (typeof nodeRequire == "undefined") {
     console.log("nodeRequire failed");
@@ -6,11 +8,21 @@ export default function async(exeName, cb) {
       window.location.pathname.replace(/\d+/g, ""),
       "不在Electron中,调用 " + exeName + " 失败",
     ]);
+    createLog({
+      page: window.location.pathname.replace(/\d+/g, ""),
+      action: "不在Electron中,调用 " + exeName + " 失败",
+    });
     throw "不在Electron中,调用 " + exeName + " 失败";
   }
   return new Promise(resolve => {
     window.nodeRequire("node-cmd").get(exeName, async (err, data, stderr) => {
       console.log(err, data, stderr); // 未免过多日志,此处后续可以关闭
+      createLog({
+        page: window.location.pathname.replace(/\d+/g, ""),
+        error: JSON.stringify(err),
+        data,
+        stderr: JSON.stringify(stderr),
+      });
       await new Promise(resolve2 => setTimeout(() => resolve2(), 1000));
       await cb();
       resolve();
@@ -26,6 +38,10 @@ export function fileExists(file) {
       window.location.pathname.replace(/\d+/g, ""),
       "不在Electron中,调用 fs 失败",
     ]);
+    createLog({
+      page: window.location.pathname.replace(/\d+/g, ""),
+      action: "不在Electron中,调用 fs 失败",
+    });
     throw "不在Electron中,调用 fs 失败";
   }
   return window.nodeRequire("fs").existsSync(file);