yanghao 2 недель назад
Родитель
Сommit
b7559008ee
3 измененных файлов с 62 добавлено и 103 удалено
  1. 46 86
      src/views/flow/index.vue
  2. 14 15
      src/views/index.vue
  3. 2 2
      src/views/login.vue

+ 46 - 86
src/views/flow/index.vue

@@ -418,101 +418,62 @@ const getById = (tab) => {
 const go = async (item) => {
   if (userStore.getUser.username && getAccessToken()) {
     if (item.type === "OA") {
-      const res = await ssoLogin({
-        username: userStore.getUser.username,
-      });
-      if (res) {
-        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();
-        let isMobile = ua2.indexOf("dingtalk") > -1;
-
-        if (ua2.includes("dingtalk") || ua2.includes("dingtalkwork")) {
-          if (isMobile && !isDesktop) {
-            const targetUrl = item.appUrl;
-            if (targetUrl) {
-              dd.biz.util.openLink({
-                url: targetUrl,
-                onSuccess: () => {},
-                onFail: (err) => {
-                  // loading.close();
-                  ElMessage.error("打开链接失败,请重试");
-                },
-              });
-            } else {
-              const targetUrl1 = item.indexUrl + "?ssoToken=" + res + "#/main";
-              const targetUrl2 = item.flowUrl;
-
-              dd.biz.util.openLink({
-                url: targetUrl1,
-                onSuccess: () => {
-                  setTimeout(() => {
-                    dd.biz.util.openLink({
-                      url: targetUrl2,
-                      onSuccess: () => {},
-                      onFail: (err) => {
-                        ElMessage.error("跳转失败,请重试");
-                      },
-                    });
-                  }, 2000);
-                },
-                onFail: (err) => {
-                  ElMessage.error("打开链接失败,请重试");
-                },
-              });
-            }
-          } else if (isDesktop) {
-            // const newTab = window.open("", "_blank");
-            // newTab.location.href =
-            //   item.indexUrl + "?ssoToken=" + res + "#/main";
-
-            // setTimeout(() => {
-            //   newTab.location.href = item.flowUrl;
-            //   setTimeout(() => {
-            //     // loading.close();
-            //   }, 500);
-            // }, 100);
+      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();
+      let isMobile = ua2.indexOf("dingtalk") > -1;
+
+      if (ua2.includes("dingtalk") || ua2.includes("dingtalkwork")) {
+        if (isMobile && !isDesktop) {
+          const targetUrl = item.appUrl;
+          if (targetUrl) {
+            const res = await ssoLogin({
+              workcode: userStore.getUser.username,
+              uri: targetUrl,
+            });
             dd.biz.util.openLink({
-              url: item.indexUrl + "?ssoToken=" + res + "#/main",
-              onSuccess: () => {
-                setTimeout(() => {
-                  dd.biz.util.openLink({
-                    url: item.flowUrl,
-                    onSuccess: () => {},
-                    onFail: (err) => {
-                      ElMessage.error("跳转失败,请重试");
-                    },
-                  });
-                }, 2000);
-              },
+              url: JSON.parse(res).ssoUrl,
+              onSuccess: () => {},
               onFail: (err) => {
+                // loading.close();
                 ElMessage.error("打开链接失败,请重试");
               },
             });
           } else {
-            console.log("❌ 非钉钉环境");
+            const res = await ssoLogin({
+              workcode: userStore.getUser.username,
+              uri: item.flowUrl,
+            });
+
+            dd.biz.util.openLink({
+              url: JSON.parse(res).ssoUrl,
+              onSuccess: () => {},
+              onFail: (err) => {
+                ElMessage.error("打开链接失败,请重试");
+              },
+            });
           }
-        } else {
-          // 浏览器环境
-          const loading = ElLoading.service({
-            lock: true,
-            text: "正在跳转,请稍候...",
-            background: "rgba(0, 0, 0, 0.7)",
+        } else if (isDesktop) {
+          const res = await ssoLogin({
+            workcode: userStore.getUser.username,
+            uri: item.flowUrl,
           });
 
-          const newTab = window.open("", "_blank");
-          newTab.location.href = item.indexUrl + "?ssoToken=" + res + "#/main";
-
-          setTimeout(() => {
-            newTab.location.href = item.flowUrl;
-            setTimeout(() => {
-              loading.close();
-            }, 500);
-          }, 100);
+          dd.biz.util.openLink({
+            url: JSON.parse(res).ssoUrl, // 先跳你的 SSO 链接
+            onSuccess: () => {},
+          });
         }
+      } else {
+        const res = await ssoLogin({
+          workcode: userStore.getUser.username,
+          uri: item.flowUrl,
+        });
+
+        window.open(JSON.parse(res).ssoUrl, "_blank");
       }
     }
 
@@ -591,7 +552,6 @@ const handleDetailClick = (task, categoryTitle) => {
   let isMobile = ua2.indexOf("dingtalk") > -1;
 
   if (isMobile) {
-    // 示例:根据类型跳转
     if (task.name === "OA" && categoryTitle === "我的待办") {
       // router.push({
       //   path: "/mobile-todo-list",

+ 14 - 15
src/views/index.vue

@@ -1070,8 +1070,6 @@ const handlePortalAppClick = async (app: PortalApp) => {
 
       let ua2 = navigator.userAgent.toLowerCase();
       let isMobile = ua2.indexOf("dingtalk") > -1;
-
-      const res = await ssoLogin({ username: userStore.getUser.username });
       if (ua2.includes("dingtalk") || ua2.includes("dingtalkwork")) {
         if (isMobile && !isDesktop) {
           dd.biz.util.openLink({
@@ -1080,21 +1078,22 @@ const handlePortalAppClick = async (app: PortalApp) => {
             onSuccess: () => {},
           });
         } else if (isDesktop) {
-          if (res) {
-            window.open(
-              `https://yfoa.keruioil.com/wui/index.html?ssoToken=${res}#/main`,
-              "_blank",
-            );
-          }
+          const res = await ssoLogin({
+            workcode: userStore.getUser.username,
+            uri: `https://yfoa.keruioil.com/wui/index.html`,
+          });
+          dd.biz.util.openLink({
+            url: JSON.parse(res).ssoUrl, // 先跳你的 SSO 链接
+            onSuccess: () => {},
+          });
         }
       } else {
-        // 浏览器
-        if (res) {
-          window.open(
-            `https://yfoa.keruioil.com/wui/index.html?ssoToken=${res}#/main`,
-            "_blank",
-          );
-        }
+        const res = await ssoLogin({
+          workcode: userStore.getUser.username,
+          uri: `https://yfoa.keruioil.com/wui/index.html`,
+        });
+
+        window.open(JSON.parse(res).ssoUrl, "_blank");
       }
     } else {
       router.push({ path: "/login" });

+ 2 - 2
src/views/login.vue

@@ -21,7 +21,7 @@
         <h1 class="text-2xl font-bold text-center text-black/90">登录</h1>
 
         <!-- 用户名密码登陆 -->
-        <div>
+        <!-- <div>
           <el-form
             :model="form"
             :rules="rules"
@@ -62,7 +62,7 @@
               >
             </div>
           </div>
-        </div>
+        </div> -->
 
         <!-- 钉钉登陆 -->
         <div class="text-center">