Răsfoiți Sursa

fix Project2.exe 不能模糊匹配进程的问题

Michael Wang 3 ani în urmă
părinte
comite
f2d4be659e
2 a modificat fișierele cu 33 adăugiri și 18 ștergeri
  1. 9 2
      src/features/Login/Login.vue
  2. 24 16
      src/utils/nativeExe.js

+ 9 - 2
src/features/Login/Login.vue

@@ -994,14 +994,21 @@ export default {
           return;
         }
         if (typeof nodeRequire !== "undefined") {
-          const hasSun = nodeCheckRemoteDesktop();
-          if (hasSun) {
+          const res = nodeCheckRemoteDesktop();
+          if (res.hasSun) {
             if (applicationNames) {
               applicationNames += ",sunloginclient";
             } else {
               applicationNames = "sunloginclient";
             }
           }
+          if (res.hasTodesk) {
+            if (applicationNames) {
+              applicationNames += ",todesk";
+            } else {
+              applicationNames = "todesk";
+            }
+          }
         }
         if (applicationNames && applicationNames.trim()) {
           let names = applicationNames

+ 24 - 16
src/utils/nativeExe.js

@@ -83,24 +83,32 @@ export function nodeCheckRemoteDesktop() {
     action: "nodeCheckRemoteDesktop",
   });
 
-  const appList = window
-    .nodeRequire("child_process")
-    .execSync("cmd /c chcp 65001>nul && tasklist /FO CSV")
-    .toString();
-  // console.debug(appList);
-  if (!appList) return false;
+  try {
+    const appList = window
+      .nodeRequire("child_process")
+      .execSync("cmd /c chcp 65001>nul && tasklist /FO CSV")
+      .toString();
+    // console.debug(appList);
+
+    if (!appList) return {};
 
-  if (
-    (appList.match(/sunloginclient/gi) &&
-      appList.match(/sunloginclient/gi).length > 0) ||
-    (appList.match(/向日葵/gi) && appList.match(/向日葵/gi).length > 0) ||
-    (appList.match(/选择免安装运行,截图识别/gi) &&
-      appList.match(/选择免安装运行,截图识别/gi).length > 0)
-  ) {
-    return true;
-  } else {
-    return false;
+    if (
+      (appList.match(/sunloginclient/gi) &&
+        appList.match(/sunloginclient/gi).length > 0) ||
+      (appList.match(/向日葵/gi) && appList.match(/向日葵/gi).length > 0) ||
+      (appList.match(/选择免安装运行,截图识别/gi) &&
+        appList.match(/选择免安装运行,截图识别/gi).length > 0)
+    ) {
+      return { hasSun: true };
+    }
+
+    if (appList.match(/todesk/gi) && appList.match(/todesk/gi).length > 0) {
+      return { hasTodesk: true };
+    }
+  } catch (error) {
+    console.log(error);
   }
+  return {};
 }
 
 let previousAppList = [];