fix(electron): dev reload (#4911)

This commit is contained in:
Peng Xiao
2023-11-12 11:19:27 +08:00
committed by GitHub
parent 7525126d89
commit a8d89254ce
5 changed files with 16 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
import { shell } from 'electron';
import { app } from 'electron';
import log from 'electron-log';
export const logger = log.scope('main');
@@ -12,3 +13,7 @@ export async function revealLogFile() {
const filePath = getLogFilePath();
return await shell.openPath(filePath);
}
app.on('before-quit', () => {
log.transports.console.level = false;
});

View File

@@ -10,6 +10,9 @@ import { updaterSubjects } from './event';
const mode = process.env.NODE_ENV;
const isDev = mode === 'development';
// skip auto update in dev mode & internal
const disabled = buildType === 'internal' || isDev;
export const quitAndInstall = async () => {
autoUpdater.quitAndInstall();
};
@@ -17,7 +20,7 @@ export const quitAndInstall = async () => {
let lastCheckTime = 0;
export const checkForUpdates = async (force = true) => {
// check every 30 minutes (1800 seconds) at most
if (force || lastCheckTime + 1000 * 1800 < Date.now()) {
if (!disabled && (force || lastCheckTime + 1000 * 1800 < Date.now())) {
lastCheckTime = Date.now();
return await autoUpdater.checkForUpdates();
}
@@ -25,8 +28,7 @@ export const checkForUpdates = async (force = true) => {
};
export const registerUpdater = async () => {
// skip auto update in dev mode & internal
if (buildType === 'internal' || isDev) {
if (disabled) {
return;
}
@@ -43,7 +45,6 @@ export const registerUpdater = async () => {
channel: buildType,
// hack for custom provider
provider: 'custom' as 'github',
// @ts-expect-error - just ignore for now
repo: buildType !== 'internal' ? 'AFFiNE' : 'AFFiNE-Releases',
owner: 'toeverything',
releaseType: buildType === 'stable' ? 'release' : 'prerelease',