浏览代码

Start using it

Manav Rathi 1 年之前
父节点
当前提交
72dea7eca6
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 5 1
      web/packages/next/global-electron.d.ts
  2. 2 3
      web/packages/next/log.ts

+ 5 - 1
web/packages/next/global-electron.d.ts

@@ -14,5 +14,9 @@ declare global {
      * {@link Electron}) that allow us to communicate with the Node.js layer of
      * our desktop app.
      */
-    const electron: Electron | undefined;
+    // This needs to be a var for it to be recognized as a property of
+    // globalThis, so we unfortunately need to hush eslint for the next line.
+    //
+    // eslint-disable-next-line no-var
+    var electron: Electron | undefined;
 }

+ 2 - 3
web/packages/next/log.ts

@@ -1,6 +1,4 @@
 import { inWorker } from "@/next/env";
-import isElectron from "is-electron";
-import ElectronAPIs from "./electron";
 import { isDevBuild } from "./env";
 import { logToDisk as webLogToDisk } from "./log-web";
 import { workerBridge } from "./worker/worker-bridge";
@@ -12,7 +10,8 @@ import { workerBridge } from "./worker/worker-bridge";
  * in the log that is saved on disk.
  */
 export const logToDisk = (message: string) => {
-    if (isElectron()) ElectronAPIs.logToDisk(message);
+    const electron = globalThis.electron;
+    if (electron) electron.logToDisk(message);
     else if (inWorker()) workerLogToDisk(message);
     else webLogToDisk(message);
 };