Remove electron-reload, replace with more light-weight electron-reload

Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
This commit is contained in:
Hung-Han (Henry) Chen committed 2021-01-07 11:22:47 +08:00
1 parent 63ce210c9a
commit 6079235fb6
4 files changed
+44 -74

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
import path from "path";
import logger from "./logger";
/**
* Use electron-reload to watch changes of main.js
* and reload electron windows if /static/build/main.js changes
* The dependency is not bundled to the production build.
*/
export const reload = async () => {
if (process.env.NODE_ENV === "development") {
// eslint-disable-next-line
require("electron-reload")(`${process.cwd()}/static/build/main.js`, {
electron: path.join(process.cwd(), "node_modules", ".bin", "electron"),
hardResetMethod: "exit"
});
logger.info(`🔍 electron-reloadelectron-reload watching for main.js change......"`);
}
};
+3
View File
@@ -8,6 +8,7 @@ import { initMenu } from "./menu";
import { initTray } from "./tray";
import { Singleton } from "../common/utils";
import { ClusterFrameInfo, clusterFrameMap } from "../common/cluster-frames";
import { reload } from "./reload";
export class WindowManager extends Singleton {
protected mainWindow: BrowserWindow;
@@ -74,6 +75,8 @@ export class WindowManager extends Singleton {
appEventBus.emit({name: "app", action: "blur"});
});
await reload();
// clean up
this.mainWindow.on("closed", () => {
this.windowState.unmanage();