|
@@ -1,3 +1,5 @@
|
|
|
+import { createLog } from "@/utils/logger";
|
|
|
+
|
|
|
export default function async(exeName, cb) {
|
|
|
if (typeof nodeRequire == "undefined") {
|
|
|
console.log("nodeRequire failed");
|
|
@@ -6,11 +8,21 @@ export default function async(exeName, cb) {
|
|
|
window.location.pathname.replace(/\d+/g, ""),
|
|
|
"不在Electron中,调用 " + exeName + " 失败",
|
|
|
]);
|
|
|
+ createLog({
|
|
|
+ page: window.location.pathname.replace(/\d+/g, ""),
|
|
|
+ action: "不在Electron中,调用 " + exeName + " 失败",
|
|
|
+ });
|
|
|
throw "不在Electron中,调用 " + exeName + " 失败";
|
|
|
}
|
|
|
return new Promise(resolve => {
|
|
|
window.nodeRequire("node-cmd").get(exeName, async (err, data, stderr) => {
|
|
|
console.log(err, data, stderr); // 未免过多日志,此处后续可以关闭
|
|
|
+ createLog({
|
|
|
+ page: window.location.pathname.replace(/\d+/g, ""),
|
|
|
+ error: JSON.stringify(err),
|
|
|
+ data,
|
|
|
+ stderr: JSON.stringify(stderr),
|
|
|
+ });
|
|
|
await new Promise(resolve2 => setTimeout(() => resolve2(), 1000));
|
|
|
await cb();
|
|
|
resolve();
|
|
@@ -26,6 +38,10 @@ export function fileExists(file) {
|
|
|
window.location.pathname.replace(/\d+/g, ""),
|
|
|
"不在Electron中,调用 fs 失败",
|
|
|
]);
|
|
|
+ createLog({
|
|
|
+ page: window.location.pathname.replace(/\d+/g, ""),
|
|
|
+ action: "不在Electron中,调用 fs 失败",
|
|
|
+ });
|
|
|
throw "不在Electron中,调用 fs 失败";
|
|
|
}
|
|
|
return window.nodeRequire("fs").existsSync(file);
|