Explorar o código

判断钉钉pc端

yanghao hai 3 días
pai
achega
66476abe92
Modificáronse 1 ficheiros con 19 adicións e 12 borrados
  1. 19 12
      src/views/index.vue

+ 19 - 12
src/views/index.vue

@@ -981,18 +981,21 @@ const handlePortalAppClick = async (app: PortalApp) => {
 
   if (app.label === "客户管理(CRM)") {
     if (userStore.getUser.username && getAccessToken()) {
-      const ua = window.navigator.userAgent.toLowerCase();
-      const isMobileDing =
-        ua.includes("dingtalk") && !ua.includes("dingtalk-pc");
-      const isPcDing = ua.includes("dingtalk-pc");
+      const ua = window.navigator.userAgent; // const ua = navigator.userAgent;
+      const isDesktop =
+        ua.includes("DingTalk") &&
+        (ua.includes("Windows") || ua.includes("Macintosh"));
+
+      let ua2 = navigator.userAgent.toLowerCase();
+      var isMobile = ua2.indexOf("dingtalk") > -1;
       if (ua.includes("dingtalk") || ua.includes("dingtalkwork")) {
-        if (isMobileDing) {
+        if (isMobile && !isDesktop) {
           dd.biz.util.openLink({
             url: "https://crm-tencent.xiaoshouyi.com/bff/spa/crmh5/index.html#/neo/startPage",
 
             onSuccess: () => {},
           });
-        } else {
+        } else if (isDesktop) {
           window.open(
             `https://crm-tencent.xiaoshouyi.com/global/sso/callback/00APEB9EEEA9B2E338B686B7ECFA8585808C.action?token=${getAccessToken()}`,
             "_blank",
@@ -1078,18 +1081,22 @@ const handlePortalAppClick = async (app: PortalApp) => {
       const res = await ehrLogin({
         username: userStore.getUser.username,
       });
-      const ua = window.navigator.userAgent.toLowerCase();
-      const isMobileDing =
-        ua.includes("dingtalk") && !ua.includes("dingtalk-pc");
-      const isPcDing = ua.includes("dingtalk-pc");
+      const ua = window.navigator.userAgent;
+      const isDesktop =
+        ua.includes("DingTalk") &&
+        (ua.includes("Windows") || ua.includes("Macintosh"));
+
+      let ua2 = navigator.userAgent.toLowerCase();
+      var isMobile = ua2.indexOf("dingtalk") > -1;
+
       if (ua.includes("dingtalk") || ua.includes("dingtalkwork")) {
-        if (isMobileDing) {
+        if (isMobile && !isDesktop) {
           dd.biz.util.openLink({
             url: `${res.ehrUrl}/gateway/login/free?loginfree_licence=${res.licence}&signature=${res.sign}&redirect_url=/proxy/h5/home`,
 
             onSuccess: () => {},
           });
-        } else {
+        } else if (isDesktop) {
           window.open(
             `${res.ehrUrl}/gateway/login/free?loginfree_licence=${res.licence}&signature=${res.sign}&redirect_url=${res.redirect}`,
             "_blank",