deason 6 anos atrás
pai
commit
4914673db0

+ 5 - 8
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/utils/ElectronUtils.java

@@ -39,16 +39,13 @@ public class ElectronUtils {
             if (path.indexOf(":") > 0 && path.startsWith("/")) {
                 path = path.replaceFirst("/", "");
             }
-            String[] cmd = new String[]{WIN_PREFIX + String.format(script, url, path)};
-            return executeCommand(cmd, "GBK");
+            String cmd = WIN_PREFIX + String.format(script, url, path);
+            return executeCommand(new String[]{cmd}, "GBK");
         } else {
+            String prefix = "export DISPLAY=':99.0' && Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &";
+            String cdDir = "cd /usr/local/nodejs/node_global/bin";
             String cmd = LINUX_PREFIX + String.format(script, url, path);
-            String[] commands = new String[]{
-                    "/bin/sh", "-c",
-                    "export DISPLAY=':99.0'",
-                    "Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &",
-                    "cd /usr/local/nodejs/node_global/bin", cmd
-            };
+            String[] commands = new String[]{"/bin/sh", "-c", cdDir + " && " + cmd};
             log.debug(Arrays.toString(commands));
             return executeCommand(commands, "UTF-8");
         }