Explorar el Código

检测ToDesk远程桌面软件

Michael Wang hace 3 años
padre
commit
13d511c76c
Se han modificado 2 ficheros con 16 adiciones y 11 borrados
  1. 5 6
      src/features/UserLogin/useRemoteAppChecker.tsx
  2. 11 5
      src/utils/nativeMethods.ts

+ 5 - 6
src/features/UserLogin/useRemoteAppChecker.tsx

@@ -48,13 +48,12 @@ export function useRemoteAppChecker() {
     }
 
     try {
-      const hasSun = nodeCheckRemoteDesktop();
+      const { hasSun, hasTodesk } = nodeCheckRemoteDesktop();
       if (hasSun) {
-        if (applicationNames) {
-          applicationNames += ",sunloginclient";
-        } else {
-          applicationNames = "sunloginclient";
-        }
+        applicationNames = (applicationNames ? "" : ",") + "sunloginclient";
+      }
+      if (hasTodesk) {
+        applicationNames = (applicationNames ? "" : ",") + "todesk";
       }
     } catch (error) {
       logger({

+ 11 - 5
src/utils/nativeMethods.ts

@@ -99,11 +99,11 @@ export function fileExists(file: string): boolean {
   return fs.existsSync(file);
 }
 
-/** 检测当前运行的进程中是否有“向日葵” */
-export function nodeCheckRemoteDesktop(): boolean {
-  if (import.meta.env.DEV) return false;
+/** 检测当前运行的进程中是否有“向日葵”和"ToDesk" */
+export function nodeCheckRemoteDesktop() {
+  if (import.meta.env.DEV) return {};
   // FIXME: 在苹果电脑跳过检测
-  if (navigator.userAgent.includes("Macintosh")) return false;
+  if (navigator.userAgent.includes("Macintosh")) return {};
 
   logger({
     pgu: "AUTO",
@@ -119,7 +119,13 @@ export function nodeCheckRemoteDesktop(): boolean {
   // console.debug(appList);
 
   const regex = new RegExp("sunloginclient|选择免安装运行,截图识别", "gi");
-  return !!(appList?.match(regex) || []).length;
+  const hasSun = !!(appList?.match(regex) || []).length;
+
+  let hasTodesk = false;
+  if ((appList.match(/todesk/gi) || []).length > 0) {
+    hasTodesk = true;
+  }
+  return { hasSun, hasTodesk };
 }
 
 let previousAppList: string[] = [];