fix browserview failed to hide in story view

This commit is contained in:
an-lee
2024-01-10 19:52:03 +08:00
parent 4384a60e0c
commit c9a9b2a3a9
2 changed files with 19 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import { app, BrowserWindow, protocol, net } from "electron";
import { app, BrowserWindow, globalShortcut, protocol, net } from "electron";
import path from "path";
import settings from "@main/settings";
import "@main/i18n";
@@ -50,6 +50,10 @@ app.on("ready", async () => {
});
mainWindow.init();
globalShortcut.register("CommandOrControl+Shift+I", () => {
mainWindow.win.webContents.toggleDevTools();
});
});
// Quit when all windows are closed, except on macOS. There, it's common

View File

@@ -21,7 +21,7 @@ import { AudibleProvider, TedProvider } from "@main/providers";
import { FfmpegDownloader } from "@main/ffmpeg";
log.initialize({ preload: true });
const logger = log.scope("WINDOW");
const logger = log.scope("window");
const audibleProvider = new AudibleProvider();
const tedProvider = new TedProvider();
@@ -147,7 +147,15 @@ main.init = () => {
const view = mainWindow.getBrowserView();
if (!view) return;
view.setBounds({ x: 0, y: 0, width: 0, height: 0 });
const bounds = view.getBounds();
logger.debug("current view bounds", bounds);
view.setBounds({
x: -bounds.width,
y: -bounds.height,
width: 0,
height: 0,
});
});
ipcMain.handle(
@@ -161,8 +169,11 @@ main.init = () => {
height: number;
}
) => {
const view = mainWindow.getBrowserView();
if (!view) return;
logger.debug("view-show", bounds);
mainWindow.getBrowserView()?.setBounds(bounds);
view.setBounds(bounds);
}
);