browserWindows.ts: Fix SetThumbarButtons

This commit is contained in:
softworkz
2025-11-09 02:37:18 +01:00
parent dc27511aa5
commit 8dcc3721eb
3 changed files with 37 additions and 6 deletions

View File

@@ -524,8 +524,21 @@ module.exports = (socket, app) => {
});
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons) => {
thumbarButtons.forEach(thumbarButton => {
const imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString());
thumbarButton.icon = electron_1.nativeImage.createFromPath(imagePath);
const originalIconPath = thumbarButton.icon.toString();
const path = require('path');
const fs = require('fs');
let imagePath = originalIconPath;
if (!path.isAbsolute(originalIconPath)) {
imagePath = path.join(__dirname.replace('api', ''), 'bin', originalIconPath);
}
const { nativeImage } = require('electron');
if (fs.existsSync(imagePath)) {
thumbarButton.icon = nativeImage.createFromPath(imagePath);
}
else {
// Fallback to empty image to avoid failure
thumbarButton.icon = nativeImage.createEmpty();
}
thumbarButton.click = () => {
electronSocket.emit('thumbarButtonClicked', thumbarButton['id']);
};
@@ -576,8 +589,14 @@ module.exports = (socket, app) => {
getWindowById(id).setFocusable(focusable);
});
socket.on('browserWindowSetParentWindow', (id, parent) => {
const child = getWindowById(id);
if (!parent) {
// Clear parent: make this window top-level
child.setParentWindow(null);
return;
}
const browserWindow = electron_1.BrowserWindow.fromId(parent.id);
getWindowById(id).setParentWindow(browserWindow);
child.setParentWindow(browserWindow);
});
socket.on('browserWindowGetParentWindow', (id) => {
const browserWindow = getWindowById(id).getParentWindow();

File diff suppressed because one or more lines are too long

View File

@@ -665,8 +665,20 @@ export = (socket: Socket, app: Electron.App) => {
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons: Electron.ThumbarButton[]) => {
thumbarButtons.forEach(thumbarButton => {
const imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString());
thumbarButton.icon = nativeImage.createFromPath(imagePath);
const originalIconPath = thumbarButton.icon.toString();
const path = require('path');
const fs = require('fs');
let imagePath = originalIconPath;
if (!path.isAbsolute(originalIconPath)) {
imagePath = path.join(__dirname.replace('api', ''), 'bin', originalIconPath);
}
const { nativeImage } = require('electron');
if (fs.existsSync(imagePath)) {
thumbarButton.icon = nativeImage.createFromPath(imagePath);
} else {
// Fallback to empty image to avoid failure
thumbarButton.icon = nativeImage.createEmpty();
}
thumbarButton.click = () => {
electronSocket.emit('thumbarButtonClicked', thumbarButton['id']);
};