ソースを参照

chore: 更新API地址并移除冗余代码

更新服务端API地址为香港域名
移除浏览器检测函数和冗余的登录参数处理
清理注释并简化重试逻辑
lsc 2 週間 前
親
コミット
212534603b
1 ファイル変更、17 行追加、55 行削除
  1. 17 55
      js/liyuan/Onload2.js

+ 17 - 55
js/liyuan/Onload2.js

@@ -33,18 +33,18 @@ U.MD.D.LocalStorage = null;
  */
  */
 window.onload = function () {
 window.onload = function () {
     U.MD.D.Load();
     U.MD.D.Load();
-    // U.MD.U.L.login();
+    U.MD.U.L.login();
     //U.MD.D.isLogin();
     //U.MD.D.isLogin();
     // U.MD.D.fullscreen();
     // U.MD.D.fullscreen();
     U.MD.D.stopSafari();
     U.MD.D.stopSafari();
 
 
-    const params = ['type', 'courseid', 'orgnum', 'classcode', 'state', 'form'].reduce((acc, key) => {
+    const params = ['type', 'courseid', 'orgnum', 'classcode'].reduce((acc, key) => {
         const value = U.UF.C.queryString(key);
         const value = U.UF.C.queryString(key);
         if (value) acc[key] = value;
         if (value) acc[key] = value;
         return acc;
         return acc;
     }, {});
     }, {});
     U.MD.D.I.openApplication('liyuanLogin', params);
     U.MD.D.I.openApplication('liyuanLogin', params);
-    
+
     let _hashSearch = "?" + (window.location.hash.split("?")[1] || "");
     let _hashSearch = "?" + (window.location.hash.split("?")[1] || "");
     let shareCourseId = U.UF.C.queryString("shareCourseId", _hashSearch);
     let shareCourseId = U.UF.C.queryString("shareCourseId", _hashSearch);
     let _shareType = U.UF.C.queryString("type", _hashSearch);
     let _shareType = U.UF.C.queryString("type", _hashSearch);
@@ -61,19 +61,19 @@ window.onload = function () {
 }
 }
 
 
 US.Config = {
 US.Config = {
-    server: '//beta.api.cocorobo.cn/api/',
-    api: '//beta.api.cocorobo.cn/',
+    server: '//cloud.api.cocorobo.hk/api/',
+    api: '//cloud.api.cocorobo.hk/',
     chat: "//chat.api.cocorobo.cn/",
     chat: "//chat.api.cocorobo.cn/",
     edu: '//api.edu.cocorobo.cn/edu/',
     edu: '//api.edu.cocorobo.cn/edu/',
     origin: '//cocorobo.cn',
     origin: '//cocorobo.cn',
     pbl: "//pbl.cocorobo.cn/api/pbl/",
     pbl: "//pbl.cocorobo.cn/api/pbl/",
-    // bpbl:"//pbl.cocorobo.cn",//正式链接
-    bpbl:"//beta.pbl.cocorobo.cn",//测试链接
+    // bpbl:"//pbl.cocorobo.cn",//正式鏈接
+    // bpbl:"//beta.pbl.cocorobo.cn",//測試鏈接
+    bpbl:"//pbl.cocorobo.hk",//hk鏈接
     // pbl: "http://localhost:7003/api/pbl/",
     // pbl: "http://localhost:7003/api/pbl/",
     basename: '',
     basename: '',
     type:1,
     type:1,
-    // background:'url("/img/icon/bgImg4.png")'
-    background:''
+    background:'url("/img/icon/bgImg4.png")'
 }
 }
 /**
 /**
  * 供外部调用的window.onload函数云端系统启动项
  * 供外部调用的window.onload函数云端系统启动项
@@ -346,7 +346,7 @@ U.MD.D.getuser = function () {
             if (!panId && _cookie && loginType != 1 && !_loginInFlight) {
             if (!panId && _cookie && loginType != 1 && !_loginInFlight) {
                 _loginInFlight = true;
                 _loginInFlight = true;
                 U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
                 U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
-                    _loginInFlight = false;
+                    _loginInFlight = false;     
                     if (res.value && res.value[0] && res.value[0][0]) {
                     if (res.value && res.value[0] && res.value[0][0]) {
                         var _user = res.value[0][0];
                         var _user = res.value[0][0];
                         U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
                         U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
@@ -704,7 +704,7 @@ U.MD.D.getuser = function () {
         US.userInfo = {}
         US.userInfo = {}
         _loginInFlight = true;
         _loginInFlight = true;
         U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
         U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
-            _loginInFlight = false;
+            _loginInFlight = false;     
             if (res.value && res.value[0] && res.value[0][0]) {
             if (res.value && res.value[0] && res.value[0][0]) {
                 var _user = res.value[0][0];
                 var _user = res.value[0][0];
                 U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
                 U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
@@ -723,9 +723,7 @@ U.MD.D.getuser = function () {
                 }, [], { "type": "GET", "withCredentials": true });
                 }, [], { "type": "GET", "withCredentials": true });
             }else {
             }else {
                 window.onbeforeunload = null
                 window.onbeforeunload = null
-                if(LoginState){
-                    window.location.reload();
-                }
+                window.location.reload();
             }
             }
         }, [], { "type": "GET", "withCredentials": true });
         }, [], { "type": "GET", "withCredentials": true });
     }else if(LoginState && _cookie && !isPanL && !_loginInFlight){
     }else if(LoginState && _cookie && !isPanL && !_loginInFlight){
@@ -734,7 +732,7 @@ U.MD.D.getuser = function () {
         isPanL = true
         isPanL = true
         _loginInFlight = true;
         _loginInFlight = true;
         U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
         U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
-            _loginInFlight = false;
+            _loginInFlight = false;     
             if (res.value && res.value[0] && res.value[0][0]) {
             if (res.value && res.value[0] && res.value[0][0]) {
                 isPanL = false
                 isPanL = false
             }else if(res.status && res.status.status != 0){
             }else if(res.status && res.status.status != 0){
@@ -1032,8 +1030,8 @@ function loginPan(userInfo, userId) {
   let vip_member = $(".vip_member")[0];
   let vip_member = $(".vip_member")[0];
   vip_member && (vip_member.innerHTML = vMember);
   vip_member && (vip_member.innerHTML = vMember);
 
 
-//   addOp('','cocoflowLogin','')
-//   addOp('','cocoflowOpen','')
+  addOp('','cocoflowLogin','')
+  addOp('','cocoflowOpen','')
 //   U.A.Request(
 //   U.A.Request(
 //     US.Config.pbl + "addLoginOperation",
 //     US.Config.pbl + "addLoginOperation",
 //     [userId],
 //     [userId],
@@ -1241,7 +1239,6 @@ function loginSet(userInfo, res){
     //     U.MD.D.I.openApplication("appStore")
     //     U.MD.D.I.openApplication("appStore")
     // }
     // }
 
 
-    // let shareCourseId = window.location.href.indexOf("?shareCourseId=")!=-1?window.location.href.split("?shareCourseId=")[1].toString():''
     let _hashSearch = "?" + (window.location.hash.split("?")[1] || "");
     let _hashSearch = "?" + (window.location.hash.split("?")[1] || "");
     let shareCourseId = U.UF.C.queryString("shareCourseId", _hashSearch);
     let shareCourseId = U.UF.C.queryString("shareCourseId", _hashSearch);
     let _shareType = U.UF.C.queryString("type", _hashSearch);
     let _shareType = U.UF.C.queryString("type", _hashSearch);
@@ -1281,16 +1278,11 @@ function selectUser(uid, callback) {
     const requestUser = () => {
     const requestUser = () => {
         U.A.Request(`${US.Config.pbl}selectUser?userid=${uid}`, [], function (res) {
         U.A.Request(`${US.Config.pbl}selectUser?userid=${uid}`, [], function (res) {
             if(res && res.value && res.value.length && res.value[0].length && res.value[0][0].userid){
             if(res && res.value && res.value.length && res.value[0].length && res.value[0][0].userid){
-                if(U.UF.C.queryString('form') == 'desktop') {
-                    window.location.href=`cocorobo://auth/callback?apiKey=${res.value[0][0].apikey}&state=${U.UF.C.queryString('state')}&userid=${res.value[0][0].userid}&username=${res.value[0][0].username}&schoolname=${res.value[0][0].schoolName}`
-                }
                 if (callback) callback(res);
                 if (callback) callback(res);
             }else {
             }else {
                 U.alert("获取用户信息失败,正在重试!")
                 U.alert("获取用户信息失败,正在重试!")
                 LoginState = false
                 LoginState = false
-                setTimeout(() => {
-                    requestUser();
-                }, 10000);
+                requestUser();
             }
             }
         }, [], { "type": "GET", "withCredentials": true });
         }, [], { "type": "GET", "withCredentials": true });
     };
     };
@@ -1300,9 +1292,7 @@ function selectUser(uid, callback) {
     } catch (error) {
     } catch (error) {
         U.alert("登录失败,正在重试!")
         U.alert("登录失败,正在重试!")
         LoginState = false
         LoginState = false
-        setTimeout(() => {
-            requestUser();
-        }, 10000);
+        requestUser();
     }
     }
 }
 }
 
 
@@ -1313,34 +1303,6 @@ function addOp(text,type,time){
         }, [], { "type": "POST", "withCredentials": true });
         }, [], { "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) => {
 U.MD.D.addOp3 = async (userTime, loadTime, object, status) => {
     let browser = detectBrowser()
     let browser = detectBrowser()