lsc 1 month ago
parent
commit
367fbabf7a
1 changed files with 59 additions and 2 deletions
  1. 59 2
      js/liyuan/Onload.js

+ 59 - 2
js/liyuan/Onload.js

@@ -54,8 +54,8 @@ US.Config = {
     edu: '//api.edu.cocorobo.cn/edu/',
     origin: '//cocorobo.cn',
     pbl: "//pbl.cocorobo.cn/api/pbl/",
-    // bpbl:"//pbl.cocorobo.cn",//正式链接
-    bpbl:"//beta.pbl.cocorobo.cn",//测试链接
+    bpbl:"//pbl.cocorobo.cn",//正式链接
+    // bpbl:"//beta.pbl.cocorobo.cn",//测试链接
     // pbl: "http://localhost:7003/api/pbl/",
     basename: '',
     type:1,
@@ -1256,3 +1256,60 @@ function addOp(text,type,time){
         }, [], { "type": "POST", "withCredentials": true });
     }
 }
+
+function detectBrowser() {
+    const ua = navigator.userAgent;
+  
+    // 按优先级顺序检测
+    if (ua.includes("Edg/") || ua.includes("Edge/")) {
+        return "Microsoft Edge";
+    } else if (ua.includes("Firefox")) {
+        return "Mozilla Firefox";
+    } else if (ua.includes("Trident") || ua.includes("MSIE")) {
+        return "Internet Explorer";
+    } else if (ua.includes("360EE")) {
+        return "360 Browser (极速模式)";
+    } else if (ua.includes("360SE")) {
+        return "360 Browser (安全模式)";
+    } else if (ua.includes("SLBrowser")) {
+        return "QQ Browser";
+    } else if (ua.includes("UCBrowser")) {
+        return "UC Browser";
+    } else if (ua.includes("Opera") || ua.includes("OPR/")) {
+        return "Opera";
+    } else if (ua.includes("Chrome") && !ua.includes("Edg/")) {
+        return "Google Chrome";
+    } else if (ua.includes("Safari/") && !ua.includes("Chrome")) {
+        return "Safari";
+    } else {
+        return "Other Browser";
+    }
+}
+
+U.MD.D.addOp3 = async (userTime, loadTime, object, status) => {
+    let browser = detectBrowser()
+    let _time = new Date().toLocaleString('zh-CN', { hour12: false, timeZone: 'Asia/Shanghai' }).replace(/\//g, '-');
+    let params = {
+        userid: US.userInfo.userid,
+        username: US.userInfo.name,
+        accountNumber: US.userInfo.accountNumber,
+        org: US.userInfo.orgName,
+        school: US.userInfo.schoolName,
+        role: US.userInfo.type == '1' ? '老师' : '学生',
+        browser: browser,
+        userTime: userTime == '1' ? _time : userTime, // 使用时间 1次的就1 其次传秒
+        loadTime: loadTime, //load的时间没有就“”
+        object: JSON.stringify(object), //执行信息传json
+        status: status, //成功返回success。失败返回error的信息
+    }
+    fetch("https://pbl.cocorobo.cn/api/mongo/updateUserData2P", { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params) }).then(res => {
+        if (res.status == 200) {
+            console.log('保存成功')
+        } else {
+            console.log('保存失败')
+        }
+    }).catch(e => {
+        console.log('保存失败')
+        console.log(e);
+    })
+}