|
@@ -1,6 +1,6 @@
|
|
|
import { createLog } from "@/utils/logger";
|
|
|
|
|
|
-export default function async(exeName, cb) {
|
|
|
+export default function checkRemote(exeName, cb) {
|
|
|
if (typeof nodeRequire == "undefined") {
|
|
|
console.log("nodeRequire failed");
|
|
|
window._hmt.push([
|
|
@@ -33,9 +33,34 @@ export default function async(exeName, cb) {
|
|
|
stderr: JSON.stringify(stderr),
|
|
|
stderrConverted: JSON.stringify(stderrConverted),
|
|
|
});
|
|
|
+
|
|
|
+ if (!exeName.includes(":") && err) {
|
|
|
+ const fs = window.nodeRequire("electron").remote.require("fs");
|
|
|
+
|
|
|
+ const path = window.nodeRequire("electron").remote.require("path");
|
|
|
+
|
|
|
+ const [exePath, exeParams] = exeName.split(" ");
|
|
|
+ const absPath = path.join(
|
|
|
+ window.nodeRequire("electron").remote.app.getAppPath(),
|
|
|
+ "../../",
|
|
|
+ exePath
|
|
|
+ );
|
|
|
+ if (fs.existsSync(absPath)) {
|
|
|
+ try {
|
|
|
+ await checkRemote([absPath, exeParams].join(" ").trim(), cb);
|
|
|
+ } catch (error) {
|
|
|
+ console.log("second try error", absPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
await new Promise((resolve2) => setTimeout(() => resolve2(), 1000));
|
|
|
- await cb();
|
|
|
- resolve();
|
|
|
+ try {
|
|
|
+ await cb();
|
|
|
+ } catch (e) {
|
|
|
+ console.log("call cb failed", e);
|
|
|
+ } finally {
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
}
|
|
@@ -56,3 +81,20 @@ export function fileExists(file) {
|
|
|
}
|
|
|
return window.nodeRequire("fs").existsSync(file);
|
|
|
}
|
|
|
+
|
|
|
+export function nodeCheckRemoteDesktop() {
|
|
|
+ createLog({
|
|
|
+ page: window.location.pathname,
|
|
|
+ action: "nodeCheckRemoteDesktop",
|
|
|
+ });
|
|
|
+
|
|
|
+ const appList = window
|
|
|
+ .nodeRequire("child_process")
|
|
|
+ .execSync("tasklist")
|
|
|
+ .toString();
|
|
|
+ if (appList && appList.match(/sunloginclient/gi).length > 0) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|