ソースを参照

oa 钉钉pc跳转

yanghao 3 週間 前
コミット
6a1c927fe6
1 ファイル変更27 行追加21 行削除
  1. 27 21
      src/views/index.vue

+ 27 - 21
src/views/index.vue

@@ -761,8 +761,14 @@ const handleSearch = () => {
 };
 
 const handleQuickAccessCommand = (command: string) => {
+  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;
+
   const routeMap: Record<string, string> = {
     "todo-oa": "/todo-list?type=oa",
     "done-oa": "/oa-done-list?type=oa",
@@ -785,32 +791,32 @@ const handleQuickAccessCommand = (command: string) => {
 
   let target = null;
 
-  console.log("执行快捷访问:", command);
-  if (isMobile) {
-    if (command === "todo-oa") {
-      dd.biz.util.openLink({
-        url: `https://yfding.keruioil.com:9443/wxapi/wxclientmenu/61c40c87c45346ce9695f223ea823278`,
+  if (ua2.includes("dingtalk") || ua2.includes("dingtalkwork")) {
+    if (isMobile && !isDesktop) {
+      if (command === "todo-oa" || command === "done-oa") {
+        dd.biz.util.openLink({
+          url: `https://yfding.keruioil.com:9443/wxapi/wxclientmenu/61c40c87c45346ce9695f223ea823278`,
 
-        onSuccess: () => {},
-      });
-      return;
-    }
-
-    if (command === "done-oa") {
-      dd.biz.util.openLink({
-        url: `https://yfding.keruioil.com:9443/wxapi/wxclientmenu/61c40c87c45346ce9695f223ea823278`,
-
-        onSuccess: () => {},
-      });
-      return;
+          onSuccess: () => {},
+        });
+        return;
+      } else {
+        target = routeMap2[command];
+      }
+    } else if (isDesktop) {
+      target = routeMap[command];
     }
-  }
-
-  if (isMobile && command !== "todo-oa" && command !== "done-oa") {
-    target = routeMap2[command];
   } else {
+    // 浏览器环境
     target = routeMap[command];
   }
+
+  console.log(
+    "🚀 ~ file: index.vue ~ line 91 ~ handleQuickAccessCommand ~ target",
+    target,
+  );
+
+  // 跳转
   if (target) {
     router.push(target);
   }